Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // AllValidClaims is a list of the claims expected from a JWT token AllValidClaims = []string{ apiProductListClaim, audienceClaim, clientIDClaim, applicationNameClaim, scopesClaim, expClaim, developerEmailClaim, } )
var ErrBadAuth = errors.New("permission denied")
ErrBadAuth is an error because of incorrect auth
var ErrInternalError = errors.New("internal error")
ErrInternalError is an error because of internal error
var ErrNoAuth = errors.New("missing authentication")
ErrNoAuth is an error because of missing auth
Functions ¶
This section is empty.
Types ¶
type APIKeyRequest ¶
type APIKeyRequest struct {
APIKey string `json:"apiKey"`
}
APIKeyRequest is the request to Apigee's verifyAPIKey API
type APIKeyResponse ¶
type APIKeyResponse struct {
Token string `json:"token"`
}
APIKeyResponse is the response from Apigee's verifyAPIKey API
type Context ¶
type Context struct { context.Context ClientID string AccessToken string Application string APIProducts []string Expires time.Time DeveloperEmail string Scopes []string APIKey string }
A Context wraps all the various information that is needed to make requests through the Apigee adapter.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
An Manager handles all things related to authentication.
func NewManager ¶
NewManager constructs a new Manager and begins an update loop to periodically refresh JWT credentials if options.pollInterval > 0. Call Close() when done.
func (*Manager) Authenticate ¶
func (m *Manager) Authenticate(ctx context.Context, apiKey string, claims map[string]interface{}, apiKeyClaimKey string) (*Context, error)
Authenticate constructs an Apigee context from an existing context and either a set of JWT claims, or an Apigee API key. The following logic applies: 1. If JWT w/ API Key - use API Key in claims 2. API Key - use API Key 3. Has JWT token - use JWT claims If any method is provided but fails, the next available one(s) will be attempted. If all provided methods fail, the request will be rejected.
type Options ¶
type Options struct { // PollInterval sets refresh rate of JWT credentials, disabled if = 0 PollInterval time.Duration // Client is a configured HTTPClient Client *http.Client // APIKeyCacheDuration is the length of time APIKeys are cached when unable to refresh APIKeyCacheDuration time.Duration }
Options allows us to specify options for how this auth manager will run