authorizer

package
v0.7.6 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2022 License: MIT Imports: 17 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAccessClaims

func GetAccessClaims(encodedToken string, keys []JWKey, claims *AccessTokenClaims) error

GetAccessClaims fills claims with Access type token data.

func GetBaseClaims

func GetBaseClaims(encodedToken string, keys []JWKey, claims *BaseTokenClaims) error

GetStandardClaims fills claims with standard token type data.

func GetIDClaims

func GetIDClaims(encodedToken string, keys []JWKey, claims *IDTokenClaims) error

GetIDClaims fills claims with ID type token data.

Types

type AccessTokenClaims

type AccessTokenClaims struct {
	AuthTime int64  `json:"auth_time"`
	Scope    string `json:"scope"`
	Username string `json:"username"`
	BaseTokenClaims
}

AccessTokenClaims represents claims stored in Access type JW token.

type BaseTokenClaims

type BaseTokenClaims struct {
	TokenUse string `json:"token_use"`
	jwt.StandardClaims
}

BaseTokenClaims is a common structure for token data.

type Context

type Context struct {
	Region            string
	ApplicationID     string
	Stage             string
	AllowedUserPoolID string
	CognitoClients    []string
	DecryptionKeys    []JWKey
}

Context is a preset of data needed to build a response.

type ContextBuilder

type ContextBuilder interface {
	BuildContext(encodedToken string) (map[string]interface{}, error)
}

ContextBuilder interface for building context passed to resource server.

type IDTokenClaims

type IDTokenClaims struct {
	EmailVerified   bool   `json:"email_verified"`
	AuthTime        int64  `json:"auth_time"`
	CognitoUsername string `json:"cognito:username"`
	GivenName       string `json:"given_name"`
	Email           string `json:"email"`
	BaseTokenClaims
}

IDTokenClaims represents claims stored in ID type JW token

type JWKey

type JWKey struct {
	Algorithm string `json:"alg"`
	Exponent  string `json:"e"`
	KeyID     string `json:"kid"`
	KeyType   string `json:"kty"`
	N         string `json:"n"`
	Use       string `json:"use"`
}

JWKey struct holds information about JSON web key.

func GetDecryptionKeys

func GetDecryptionKeys(region, userPoolID string) ([]JWKey, error)

GetDecryptionKeys gets JW token description keys from AWS Cognito service.

func RequestKeys

func RequestKeys(url string) ([]JWKey, error)

RequestKeys retrieves decryption keys from external service.

type PolicyBuilder

type PolicyBuilder interface {
	BuildPolicy(encodedToken string) (events.APIGatewayCustomAuthorizerPolicy, error)
}

PolicyBuilder interface for building API GW custom authorizer policy.

type ResponseBuilder

type ResponseBuilder struct {
	Context        *Context
	PolicyBuilder  PolicyBuilder
	ContextBuilder ContextBuilder
}

ResponseBuilder struct for building proper custom authorizer response.

func (ResponseBuilder) BuildResponse

func (b ResponseBuilder) BuildResponse(encodedToken string) (events.APIGatewayCustomAuthorizerResponse, error)

BuildResponse builds a proper custom authorizer response based on context, policy and context builders.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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