tokens

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AccessPurpose  = "access"
	RefreshPurpose = "refresh"
)
View Source
const BearerSchema = "Bearer "

Variables

This section is empty.

Functions

func AuthorizeJWT

func AuthorizeJWT(validationKey *rsa.PublicKey, issuer, audience string) gin.HandlerFunc

AuthorizeJWT creates a middleware that checks the presence and validity of the authorization header. If this middleware is installed on an endpoint, the authorization header is required. When the header is present and the access token (JWT) inside is valid, user, role and instance are set to context. The middleware creation is parameterized by service specifics.

func CheckAccessToken

func CheckAccessToken(tokenStr string, claims *AccessTokenClaims, validationKey *rsa.PublicKey, issuer, audience string) error

func CheckRefreshToken

func CheckRefreshToken(tokenStr string, claims *RefreshTokenClaims, validationKey *rsa.PublicKey, issuer, audience string) error

Types

type AccessTokenClaims

type AccessTokenClaims struct {
	Purpose  string `json:"purp"`
	Role     string `json:"role"`
	Instance string `json:"inst"`
	jwt.StandardClaims
}

AccessTokenClaims contain temporary authorization information.

type RefreshTokenClaims

type RefreshTokenClaims struct {
	Purpose  string `json:"purp"`
	Instance string `json:"inst"`
	jwt.StandardClaims
}

RefreshTokenClaims contain everything necessary to recreate an accesstoken, i.e. identify the right profile to load role and user meta information from.

Jump to

Keyboard shortcuts

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