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 ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CognitoChecker ¶ added in v1.1.0
type CognitoChecker struct {
// contains filtered or unexported fields
}
CognitoChecker is the main object of the API of the package. Contains information about your AWS Cognito configuration.
func NewCognitoChecker ¶ added in v1.1.0
func NewCognitoChecker(region, userPool, appClient string) (*CognitoChecker, error)
NewCognitoChecker is used for generating a CognitoChecker object and been able to use the library Needs the region, user pool id and app client id of your Cognito user pool to work properly
func (CognitoChecker) GetClaims ¶ added in v1.1.0
func (c CognitoChecker) GetClaims(request *http.Request, 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 (CognitoChecker) GetGroups ¶ added in v1.1.0
func (c CognitoChecker) GetGroups(request *http.Request) ([]string, error)
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 (CognitoChecker) ValidateTokenFromHeader ¶ added in v1.1.0
func (c CognitoChecker) ValidateTokenFromHeader(request *http.Request, 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.