jwt

package
v0.0.0-...-9c90d3e Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(cfg *config.Config, logger lumber.Logger) (core.Session, error)

New returns a new session authorizer

Types

type JWTAuthorizer

type JWTAuthorizer struct {
	// contains filtered or unexported fields
}

JWTAuthorizer provides a Json-Web-Token authentication implementation. On failure, a 401 HTTP response is returned.

func (*JWTAuthorizer) Authorize

func (jw *JWTAuthorizer) Authorize(c *gin.Context) (*core.UserData, error)

Authorize vaildates and extracts the data from JWT Token claims from request header

func (*JWTAuthorizer) AuthorizeInternal

func (jw *JWTAuthorizer) AuthorizeInternal(c *gin.Context) (*core.BuildData, error)

AuthorizeInternal parses and validates the internal JWT Token

func (*JWTAuthorizer) CreateToken

func (jw *JWTAuthorizer) CreateToken(data *core.UserData) (*http.Cookie, error)

CreateToken method that clients can use to create a jwt token and returns the http cookie.

func (*JWTAuthorizer) CreateTokenInternal

func (jw *JWTAuthorizer) CreateTokenInternal(data *core.BuildData) (string, error)

CreateInternalToken creates internal JWT token

func (*JWTAuthorizer) DeleteCookie

func (jw *JWTAuthorizer) DeleteCookie() *http.Cookie

DeleteCookie deletes the cookie.

type JwtClaims

type JwtClaims struct {
	jwt.MapClaims
}

JwtClaims - represents the jwt claims

func NewJWTClaims

func NewJWTClaims() *JwtClaims

NewJWTClaims - Initializes a new jwt claims

func (*JwtClaims) MarshalJSON

func (c *JwtClaims) MarshalJSON() ([]byte, error)

MarshalJSON marshals the MapClaims struct

func (*JwtClaims) SetCustomClaim

func (c *JwtClaims) SetCustomClaim(data *core.UserData) error

SetCustomClaim sets the custom claim in payload

func (*JwtClaims) SetExpiry

func (c *JwtClaims) SetExpiry(timeUnix int64)

SetExpiry sets expiry in unix epoch secs

func (*JwtClaims) SetIssuedAt

func (c *JwtClaims) SetIssuedAt(timeUnix int64)

SetIssuedAt sets expiry in unix epoch secs

func (*JwtClaims) SetIssuer

func (c *JwtClaims) SetIssuer(issuer string)

SetIssuer sets the issuer for these claims

func (*JwtClaims) SetJTI

func (c *JwtClaims) SetJTI(jti string)

SetJTI sets sets the unique JWT ID

func (*JwtClaims) Valid

func (c *JwtClaims) Valid() error

Valid Checks if the JWT Token is valid

Jump to

Keyboard shortcuts

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