oauth

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetHTTPClient

func GetHTTPClient(customFile string) *http.Client

GetHTTPClient gets an http client to use for getting an oauth token Takes the following as input:

customFile - Path to custom ca certificate

Returns:

*http.Client

Types

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, writeAccessRequired bool, service string, hostname string) (*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
writeAccessRequired - Whether or not you require write (push and delete) access as well as read (pull)
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://icr.io

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