Documentation
¶
Index ¶
- Constants
- Variables
- func NewTokenCLI(creds Credentials, state string) (token *oauth2.Token, err error)
- type Credentials
- func (creds *Credentials) Inflate() error
- func (creds *Credentials) NewClient(ctx context.Context) (*http.Client, error)
- func (creds *Credentials) NewClientCLI(oauth2State string) (*http.Client, error)
- func (creds *Credentials) NewSimpleClient(ctx context.Context) (*httpsimple.SimpleClient, error)
- func (creds *Credentials) NewSimpleClientHTTP(httpClient *http.Client) (*httpsimple.SimpleClient, error)
- func (creds *Credentials) NewToken() (*oauth2.Token, error)
- func (creds *Credentials) NewTokenCLI(oauth2State string) (*oauth2.Token, error)
- type CredentialsBasicAuth
- type CredentialsHeaderQuery
- type CredentialsJWT
- type CredentialsOAuth2
- func (oc *CredentialsOAuth2) AppNameAndVersion() string
- func (oc *CredentialsOAuth2) AuthCodeURL(state string, opts ...oauth2.AuthCodeOption) string
- func (oc *CredentialsOAuth2) Config() oauth2.Config
- func (oc *CredentialsOAuth2) ConfigClientCredentials() clientcredentials.Config
- func (oc *CredentialsOAuth2) Exchange(code string) (*oauth2.Token, error)
- func (oc *CredentialsOAuth2) InflateURL(apiURLPath string) string
- func (oc *CredentialsOAuth2) IsGrantType(grantType string) bool
- func (oc *CredentialsOAuth2) NewClient(ctx context.Context) (*http.Client, error)
- func (oc *CredentialsOAuth2) NewToken(ctx context.Context) (*oauth2.Token, error)
- func (oc *CredentialsOAuth2) PasswordRequestBody() url.Values
- type CredentialsSet
- type Options
Constants ¶
const ( TypeBasic = "basic" TypeHeaderQuery = "headerquery" TypeOAuth2 = "oauth2" TypeJWT = "jwt" )
const ( SigningMethodES256 = "ES256" SigningMethodES384 = "ES384" SigningMethodES512 = "ES512" SigningMethodHS256 = "HS256" SigningMethodHS384 = "HS384" SigningMethodHS512 = "HS512" )
Variables ¶
var ( ErrJWTNotSupported = errors.New("jwt is not supported for function") ErrBasicAuthNotPopulated = errors.New("basic auth is not populated") ErrJWTNotPopulated = errors.New("jwt is not populated") ErrOAuth2NotPopulated = errors.New("oauth2 is not populated") ErrTypeNotSupported = errors.New("credentials type not supported") )
Functions ¶
func NewTokenCLI ¶ added in v0.16.0
func NewTokenCLI(creds Credentials, state string) (token *oauth2.Token, err error)
Types ¶
type Credentials ¶
type Credentials struct {
Service string `json:"service,omitempty"`
Type string `json:"type,omitempty"`
Subdomain string `json:"subdomain,omitempty"`
Basic CredentialsBasicAuth `json:"basic,omitempty"`
OAuth2 CredentialsOAuth2 `json:"oauth2,omitempty"`
JWT CredentialsJWT `json:"jwt,omitempty"`
Token *oauth2.Token `json:"token,omitempty"`
HeaderQuery CredentialsHeaderQuery `json:"headerquery,omitempty"`
Additional url.Values `json:"additional,omitempty"`
}
func NewCredentialsJSON ¶
func NewCredentialsJSON(credsData, accessToken []byte) (Credentials, error)
func ReadCredentialsFromFile ¶
func ReadCredentialsFromFile(credentialsSetFilename, accountKey string, inclAccountsOnError bool) (Credentials, error)
func (*Credentials) Inflate ¶
func (creds *Credentials) Inflate() error
func (*Credentials) NewClientCLI ¶ added in v0.14.2
func (creds *Credentials) NewClientCLI(oauth2State string) (*http.Client, error)
func (*Credentials) NewSimpleClient ¶
func (creds *Credentials) NewSimpleClient(ctx context.Context) (*httpsimple.SimpleClient, error)
func (*Credentials) NewSimpleClientHTTP ¶ added in v0.14.0
func (creds *Credentials) NewSimpleClientHTTP(httpClient *http.Client) (*httpsimple.SimpleClient, error)
func (*Credentials) NewTokenCLI ¶ added in v0.14.2
func (creds *Credentials) NewTokenCLI(oauth2State string) (*oauth2.Token, error)
NewTokenCLI retrieves a token using CLI approach for OAuth 2.0 authorization code or password grant.
type CredentialsBasicAuth ¶ added in v0.14.0
type CredentialsBasicAuth struct {
Username string `json:"username,omitempty"`
Password string `json:"password,omitempty"`
Encoded string `json:"encoded,omitempty"`
ServerURL string `json:"serverURL,omitempty"`
AllowInsecure bool `json:"allowInsecure,omitempty"`
}
func (*CredentialsBasicAuth) NewClient ¶ added in v0.14.0
func (c *CredentialsBasicAuth) NewClient() (*http.Client, error)
func (*CredentialsBasicAuth) NewSimpleClient ¶ added in v0.16.0
func (c *CredentialsBasicAuth) NewSimpleClient() (httpsimple.SimpleClient, error)
type CredentialsHeaderQuery ¶ added in v0.16.0
type CredentialsHeaderQuery struct {
ServerURL string `json:"serverURL,omitempty"`
Header http.Header `json:"header,omitempty"`
Query url.Values `json:"query,omitempty"`
AllowInsecure bool `json:"allowInsecure,omitempty"`
}
func (*CredentialsHeaderQuery) NewClient ¶ added in v0.16.0
func (c *CredentialsHeaderQuery) NewClient() *http.Client
func (*CredentialsHeaderQuery) NewSimpleClient ¶ added in v0.16.0
func (c *CredentialsHeaderQuery) NewSimpleClient() httpsimple.SimpleClient
type CredentialsJWT ¶ added in v0.12.0
type CredentialsJWT struct {
Issuer string `json:"issuer,omitempty"`
PrivateKey string `json:"privateKey,omitempty"`
SigningMethod string `json:"signingMethod,omitempty"`
}
func (*CredentialsJWT) StandardToken ¶ added in v0.12.0
type CredentialsOAuth2 ¶ added in v0.12.0
type CredentialsOAuth2 struct {
ServerURL string `json:"serverURL,omitempty"`
ApplicationID string `json:"applicationID,omitempty"`
ClientID string `json:"clientID,omitempty"`
ClientSecret string `json:"clientSecret,omitempty"`
Endpoint oauth2.Endpoint `json:"endpoint,omitempty"`
RedirectURL string `json:"redirectURL,omitempty"`
AppName string `json:"applicationName,omitempty"`
AppVersion string `json:"applicationVersion,omitempty"`
OAuthEndpointID string `json:"oauthEndpointID,omitempty"`
AccessTokenTTL int64 `json:"accessTokenTTL,omitempty"`
RefreshTokenTTL int64 `json:"refreshTokenTTL,omitempty"`
GrantType string `json:"grantType,omitempty"`
PKCE bool `json:"pkce"`
Username string `json:"username,omitempty"`
Password string `json:"password,omitempty"`
JWT string `json:"jwt,omitempty"`
Token *oauth2.Token `json:"token,omitempty"`
OtherParams map[string][]string `json:"otherParams,omitempty"`
Scopes []string `json:"scopes,omitempty"`
}
CredentialsOAuth2 supports OAuth 2.0 authorization_code, password, and client_credentials grant flows.
func NewCredentialsOAuth2Env ¶ added in v0.12.0
func NewCredentialsOAuth2Env(envPrefix string) CredentialsOAuth2
func (*CredentialsOAuth2) AppNameAndVersion ¶ added in v0.12.0
func (oc *CredentialsOAuth2) AppNameAndVersion() string
func (*CredentialsOAuth2) AuthCodeURL ¶ added in v0.12.0
func (oc *CredentialsOAuth2) AuthCodeURL(state string, opts ...oauth2.AuthCodeOption) string
func (oc *CredentialsOAuth2) AuthCodeURL(state string, opts url.Values) string {
func (*CredentialsOAuth2) Config ¶ added in v0.12.0
func (oc *CredentialsOAuth2) Config() oauth2.Config
func (*CredentialsOAuth2) ConfigClientCredentials ¶ added in v0.12.0
func (oc *CredentialsOAuth2) ConfigClientCredentials() clientcredentials.Config
func (*CredentialsOAuth2) Exchange ¶ added in v0.12.0
func (oc *CredentialsOAuth2) Exchange(code string) (*oauth2.Token, error)
func (*CredentialsOAuth2) InflateURL ¶ added in v0.12.0
func (oc *CredentialsOAuth2) InflateURL(apiURLPath string) string
func (*CredentialsOAuth2) IsGrantType ¶ added in v0.12.0
func (oc *CredentialsOAuth2) IsGrantType(grantType string) bool
func (*CredentialsOAuth2) NewClient ¶ added in v0.12.0
NewClient returns a `*http.Client` for applications using `client_credentials` grant. The client can be modified using context, e.g. ignoring bad certs or otherwise.
func (*CredentialsOAuth2) NewToken ¶ added in v0.12.0
NewToken retrieves an `*oauth2.Token` when the requisite information is available. Note this uses `clientcredentials.Config.Token()` which doesn't always work. In This situation, use `goauth.TokenClientCredentials()` as an alternative.
func (*CredentialsOAuth2) PasswordRequestBody ¶ added in v0.12.0
func (oc *CredentialsOAuth2) PasswordRequestBody() url.Values
type CredentialsSet ¶
type CredentialsSet struct {
Credentials map[string]Credentials `json:"credentials,omitempty"`
}
func ReadFileCredentialsSet ¶
func ReadFileCredentialsSet(credentialsSetFilename string, inflateEndpoints bool) (CredentialsSet, error)
func (*CredentialsSet) Accounts ¶
func (set *CredentialsSet) Accounts() []string
func (*CredentialsSet) Get ¶
func (set *CredentialsSet) Get(key string) (Credentials, error)
func (*CredentialsSet) Inflate ¶
func (set *CredentialsSet) Inflate() error
func (*CredentialsSet) Keys ¶
func (set *CredentialsSet) Keys() []string
type Options ¶
type Options struct {
CredsPath string `long:"creds" description:"Environment File Path" required:"true"`
Account string `long:"account" description:"Environment Variable Name"`
Token string `long:"token" description:"Token"`
CLI []bool `long:"cli" description:"CLI"`
}
Options is a struct to be used with `github.com/jessevdk/go-flags`. It can be embedded in another struct.