oauth

package
v0.0.0-...-793517a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 21, 2019 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client - may be used as an HTTP client that automatically authenticates using oauth.

func NewClient

func NewClient(user, pass string, skipVerify bool, url *url.URL) *Client

NewClient - creates and returns a *Client ready to use. If skipVerify is true, it will skip verification of the remote TLS certificate.

func (*Client) Do

func (c *Client) Do(req *http.Request) (*http.Response, error)

Do - passes through to the underlying http.Client instance

func (*Client) Getv2

func (c *Client) Getv2() error

Getv2 - makes a GET request to the registry's /v2/ endpoint. If a 401 Unauthorized response is received, this method attempts to obtain an oauth token and tries again with the new token. If a username and password are available, they are used with Basic Auth in the request to the token service. This method is goroutine-safe.

func (*Client) Getv2WithScope

func (c *Client) Getv2WithScope(imageNames []string) error

Getv2WithScope - makes a GET request to the registry's /v2/ endpoint. If a 401 Unauthorized response is received, this method attempts to obtain an oauth token with the given imageNames as scopes and tries again with the new token. If a username and password are available, they are used with Basic Auth in the request to the token service. This method is goroutine-safe.

func (*Client) NewRequest

func (c *Client) NewRequest(path string) (*http.Request, error)

NewRequest - creates and returns a *http.Request assuming the GET method. The base URL configured on the Client gets used with its Path component replaced by the path argument. If a token is available, it is added to the request automatically. "Accept: application/json" is added to all requests. The caller should customize the request as necessary before using it.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL