auth

package
v0.0.0-...-8faf8f0 Latest Latest
Warning

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

Go to latest
Published: May 23, 2023 License: AGPL-3.0 Imports: 11 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetToken

func GetToken(claims jwt.Claims, alg string) (string, error)

GetToken accepts a claims object and signs it with the algorithm provided via the alg field.

func GetTokenHS256

func GetTokenHS256(claims jwt.Claims) (string, error)

GetTokenHS256 returns a JWT token created from the provided claims object

func GetTokenRS256

func GetTokenRS256(claims jwt.Claims) (string, error)

GetTokenRS256 returns a JWT token created from the provided claims object

func ValidateToken

func ValidateToken(tokenString string) (*jwt.Token, error)

ValidateToken parses a JWT token, checks it for validity and returns a `*jwt.Token` object

func VerifyEmail

func VerifyEmail(token *jwt.Token) error

VerifyEmail checks if token contains an "email" field and also an "email_verified" field (which is either `true` or `"true"`). I wrote this to checking that I am getting a token from a verified logged-in user from Auth0 but left it here anyway.

func VerifyJWKS

func VerifyJWKS(tokenString string, jwksURL string) (*jwt.Token, error)

VerifyJWKS to verify token via JWKS

func VerifyManualHS256

func VerifyManualHS256(tokenString string) error

VerifyManualHS256 manually verifies that a JWT token is valid and returns the body in a DummyJSONClaims object This assumes that the token is a HS256 token

Types

type SimpleClaims

type SimpleClaims map[string]interface{}

SimpleClaims lets us parse random JSON strings as a `map[string]interface{}` and have the resultant JSON satisfy the `jwt.Claims` interface

func ParseClaims

func ParseClaims(tokenString string) (claims SimpleClaims, err error)

ParseClaims parses the claims portion of a JWT token

func (*SimpleClaims) FromBytes

func (c *SimpleClaims) FromBytes(b []byte) error

FromBytes loads a SimpleClaims object from `[]byte`

func (*SimpleClaims) FromReader

func (c *SimpleClaims) FromReader(r io.Reader) error

FromReader loads a SimpleClaims object from an `io.Reader`

func (SimpleClaims) Valid

func (c SimpleClaims) Valid() error

Valid lets SimpleClaims implement `jwt.Claims`

type TokenGetter

type TokenGetter func(jwt.Claims) (string, error)

TokenGetter is a function that accepts a jwt.Claims object and returns a signed token as a string and an error if any

Jump to

Keyboard shortcuts

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