Documentation ¶
Overview ¶
Package jwtcognito is an easy to use, small package designed to parse request headers and look for JWTs provided by AWS Cognito to either check if they are valid or get some data from them.
Index ¶
- func GetClaims(request *http.Request, jwks *jwk.Set, info CognitoConfig, tokenType string) (map[string]interface{}, error)
- func GetGroups(request *http.Request, jwks *jwk.Set, appClient string) ([]string, error)
- func GetJWK(info CognitoConfig) (*jwk.Set, error)
- func ValidateTokenFromHeader(request *http.Request, jwks *jwk.Set, info CognitoConfig, tokenType string) error
- type CognitoConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetClaims ¶
func GetClaims(request *http.Request, jwks *jwk.Set, info CognitoConfig, tokenType string) (map[string]interface{}, error)
GetClaims parses a request header and looks for a specific JWT from AWS Cognito. Returns a map with all the claims in it or an error if it is an invalid token.
func GetGroups ¶
GetGroups parses a request header and looks for a specific JWT from AWS Cognito. Returns a slice with all the groups of a user or an error if it is an invalid token.
func GetJWK ¶
func GetJWK(info CognitoConfig) (*jwk.Set, error)
GetJWK is used with in conjunction of the other functions to parse tokens. Fetches and parses the JWK in order to build the RSA key needed to decode a JWT
func ValidateTokenFromHeader ¶ added in v1.3.0
func ValidateTokenFromHeader(request *http.Request, jwks *jwk.Set, info CognitoConfig, tokenType string) error
ValidateTokenFromHeader parses a request header and looks for a specific JWT from AWS Cognito. Returns an error if its not valid or nil if it is.
Types ¶
type CognitoConfig ¶ added in v1.3.0
CognitoConfig is used for passing necessary information to the API of the package. Contains information about your AWS Cognito configuration.