jwtauth

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DoFilter

func DoFilter(handler http.Handler) http.Handler

DoFilter check if the request has the requeired permission

func Generate

func Generate(signingMethod string, claims jwt.Claims, tokenKey []byte) (token string, err error)

Generate with the given key, claims and signing method

func GenerateWithDefault

func GenerateWithDefault(claims jwt.Claims) (token string, err error)

GenerateWithDefault generate with the signing method and key that was set in the os environment variables, refer to init(...) above on what and how the environment variables are set.

func IsValid

func IsValid(token string, tokenKey []byte) bool

IsValid checks if the given token is a valid token

func IsValidDefault

func IsValidDefault(token string) bool

IsValidDefault checks if the given token is a valid token with the key in os env.

func ParseToken

func ParseToken(headerValue string, tokenKey []byte) (claims jwt.Claims, err error)

ParseToken parse the given header value to a claim using the given key

func ParseTokenDefault

func ParseTokenDefault(headerValue string) (claims jwt.Claims, err error)

ParseTokenDefault parse the given header value to a claim using the key in the os env.

func ParseTokenWithClaims

func ParseTokenWithClaims(headerValue string, claims jwt.Claims, tokenKey []byte) (err error)

ParseTokenWithClaims parse the given header value to the given claim using the given key

func ParseTokenWithClaimsDefault

func ParseTokenWithClaimsDefault(headerValue string, claims jwt.Claims) (err error)

ParseTokenWithClaimsDefault parse the given header value to the given claim using the key in the os env.

func RefreshToken

func RefreshToken(token string, tokenKey []byte) (newToken string, err error)

RefreshToken reset the given token expiration time for the given key to future time

func RefreshWithDefault

func RefreshWithDefault(token string) (newToken string, err error)

RefreshWithDefault reset the given token expiration time for the given key to future time

Types

type MiniClaims

type MiniClaims struct {
	Data jwt.MapClaims
	jwt.StandardClaims
}

MiniClaims as claim for jwt

Jump to

Keyboard shortcuts

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