oauth

package
v0.0.0-...-27a81c3 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2019 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckAuthRequired

func CheckAuthRequired(notaryURL, hostName, repoName string, official bool) (*http.Response, error)

CheckAuthRequired - checks if the given image needs to be authenticated to fetch metadata or not and returns the response

Types

type Challenge

type Challenge struct {
	// Scheme is the auth-scheme according to RFC 2617
	Scheme string

	// Parameters are the auth-params according to RFC 2617
	Parameters map[string]string
}

Challenge carries information from a WWW-Authenticate response header. See RFC 2617.

func ResponseChallenges

func ResponseChallenges(resp *http.Response) []Challenge

ResponseChallenges takes in the response and it is unauthorized returns a challenge containing realm and service information

type TokenResponse

type TokenResponse struct {
	Token        string    `json:"token,omitempty"`
	AccessToken  string    `json:"access_token,omitempty"`
	RefreshToken string    `json:"refresh_token,omitempty"`
	ExpiresIn    int       `json:"expires_in,omitempty"`
	IssuedAt     time.Time `json:"issued_at,omitempty"`
}

TokenResponse is a generic OAuth2 token response

func Request

func Request(token string, repo string, username string, challengeSlice []Challenge) (*TokenResponse, error)

Request is a helper for getting an OAuth token from the Registry OAuth Service. Takes the following as input:

token               - Auth token being used for the request
repo                - Repo you are requesting access too e.g. bainsy88/busybox
username            - Username for the OAuth request, identifies the type of token being passed in. Valid usernames are token (for registry token), iambearer, iamapikey, bearer (UAA bearer (legacy)), iamrefresh
service             - The service you are retrieving the OAuth token for. Current services are either "notary" or "registry"
hostname            - Hostname of the registry you wish to call e.g. https://registry.ng.bluemix.net

Returns:

*auth.TokenResponse - Details of the type is here https://github.ibm.com/alchemy-registry/registry-types/tree/master/auth#type-tokenresponse
                      Token is the element you will need to forward to the registry/notary as part of a Bearer Authorization Header
error

Jump to

Keyboard shortcuts

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