auth

package
v1.2.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2020 License: Apache-2.0 Imports: 21 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// AllValidClaims is a list of the claims expected from a JWT token
	AllValidClaims = []string{
		apiProductListClaim, audienceClaim, clientIDClaim, applicationNameClaim,
		scopeClaim, expClaim, developerEmailClaim,
	}
)
View Source
var ErrBadAuth = errors.New("permission denied")

ErrBadAuth is an error because of incorrect auth

View Source
var ErrInternalError = errors.New("internal error")

ErrInternalError is an error because of internal error

View Source
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 interface {
	Close()
	Authenticate(ctx context.Context, apiKey string, claims map[string]interface{}, apiKeyClaimKey string) (*Context, error)
}

A Manager wraps all things related to auth processing

func NewManager

func NewManager(options Options) (Manager, error)

NewManager constructs a new Manager and begins an update loop to periodically refresh JWT credentials if options.pollInterval > 0. Call Close() when done.

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
	// Org is organization
	Org string
	// Env is environment
	Env string
}

Options allows us to specify options for how this auth manager will run

Jump to

Keyboard shortcuts

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