Documentation ¶
Index ¶
- Constants
- 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(httpClient *http.Client) (*httpsimple.SimpleClient, error)
- func (creds *Credentials) NewToken() (*oauth2.Token, error)
- func (creds *Credentials) NewTokenCli(oauth2State string) (*oauth2.Token, error)
- type CredentialsSet
- type JWTCredentials
- type OAuth2Credentials
- func (oc *OAuth2Credentials) AppNameAndVersion() string
- func (oc *OAuth2Credentials) AuthCodeURL(state string, opts ...oauth2.AuthCodeOption) string
- func (oc *OAuth2Credentials) Config() oauth2.Config
- func (oc *OAuth2Credentials) ConfigClientCredentials() clientcredentials.Config
- func (oc *OAuth2Credentials) Exchange(code string) (*oauth2.Token, error)
- func (oc *OAuth2Credentials) InflateURL(apiUrlPath string) string
- func (oc *OAuth2Credentials) IsGrantType(grantType string) bool
- func (oc *OAuth2Credentials) NewClient(ctx context.Context) (*http.Client, error)
- func (oc *OAuth2Credentials) NewToken(ctx context.Context) (*oauth2.Token, error)
- func (oc *OAuth2Credentials) PasswordRequestBody() url.Values
- type Options
Constants ¶
const ( TypeOAuth2 = "oauth2" TypeJWT = "jwt" )
const ( SigningMethodES256 = "ES256" SigningMethodES384 = "ES384" SigningMethodES512 = "ES512" SigningMethodHS256 = "HS256" SigningMethodHS384 = "HS384" SigningMethodHS512 = "HS512" )
Variables ¶
This section is empty.
Functions ¶
func NewTokenCli ¶
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"` OAuth2 OAuth2Credentials `json:"oauth2,omitempty"` JWT JWTCredentials `json:"jwt,omitempty"` Token *oauth2.Token `json:"token,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 ¶
func (creds *Credentials) NewClientCli(oauth2State string) (*http.Client, error)
func (*Credentials) NewSimpleClient ¶
func (creds *Credentials) NewSimpleClient(httpClient *http.Client) (*httpsimple.SimpleClient, error)
func (*Credentials) NewTokenCli ¶
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 CredentialsSet ¶
type CredentialsSet struct {
Credentials map[string]Credentials
}
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()
func (*CredentialsSet) Keys ¶
func (set *CredentialsSet) Keys() []string
type JWTCredentials ¶
type JWTCredentials struct { Issuer string `json:"issuer,omitempty"` PrivateKey string `json:"privateKey,omitempty"` SigningMethod string `json:"signingMethod,omitempty"` }
func (*JWTCredentials) StandardToken ¶
type OAuth2Credentials ¶
type OAuth2Credentials struct { ServerURL string `json:"serverURL,omitempty"` ApplicationID string `json:"applicationID,omitempty"` ClientID string `json:"clientID,omitempty"` ClientSecret string `json:"clientSecret,omitempty"` OAuth2Endpoint oauth2.Endpoint `json:"oauth2Endpoint,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"` Username string `json:"username,omitempty"` Password string `json:"password,omitempty"` OtherParams map[string][]string `json:"otherParams,omitempty"` Scopes []string `json:"scopes,omitempty"` }
OAuth2Credentials supports OAuth 2.0 authorization_code, password, and client_credentials grant flows.
func NewOAuth2CredentialsEnv ¶ added in v0.10.2
func NewOAuth2CredentialsEnv(envPrefix string) OAuth2Credentials
func (*OAuth2Credentials) AppNameAndVersion ¶
func (oc *OAuth2Credentials) AppNameAndVersion() string
func (*OAuth2Credentials) AuthCodeURL ¶
func (oc *OAuth2Credentials) AuthCodeURL(state string, opts ...oauth2.AuthCodeOption) string
func (*OAuth2Credentials) Config ¶
func (oc *OAuth2Credentials) Config() oauth2.Config
func (*OAuth2Credentials) ConfigClientCredentials ¶
func (oc *OAuth2Credentials) ConfigClientCredentials() clientcredentials.Config
func (*OAuth2Credentials) Exchange ¶
func (oc *OAuth2Credentials) Exchange(code string) (*oauth2.Token, error)
func (*OAuth2Credentials) InflateURL ¶
func (oc *OAuth2Credentials) InflateURL(apiUrlPath string) string
func (*OAuth2Credentials) IsGrantType ¶
func (oc *OAuth2Credentials) IsGrantType(grantType string) bool
func (*OAuth2Credentials) NewClient ¶
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 (*OAuth2Credentials) NewToken ¶
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 (*OAuth2Credentials) PasswordRequestBody ¶
func (oc *OAuth2Credentials) PasswordRequestBody() url.Values
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.