Documentation
¶
Overview ¶
Package gojwtcognito 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, info CognitoConfig) ([]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. Use this function when you need the Cognito claims of a 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. Use this function when you need the Cognito groups of a user.
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 ¶
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. Use this function when you only need to check if a token is valid or not.
Types ¶
type CognitoConfig ¶
CognitoConfig is used for passing necessary information to the API of the package. Contains information about your AWS Cognito configuration.