jwt

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2022 License: Apache-2.0 Imports: 11 Imported by: 18

Documentation

Index

Constants

View Source
const (
	AuthorizationHeader = "Authorization"
	BearerTokenType     = "Bearer"
	AuthorizationQuery  = "access_token"
)

Variables

Functions

func ExtractHeaderToken

func ExtractHeaderToken(token string) string

func FromJWTContext

func FromJWTContext(ctx context.Context) (jwt string, ok bool)

func NewClaimsContext

func NewClaimsContext(ctx context.Context, claims *Claims) context.Context

func NewJWTContext

func NewJWTContext(ctx context.Context, jwt string) context.Context

func ServerAuth

func ServerAuth(logger log.Logger) middleware.Middleware

func ServerExtract

func ServerExtract(tokenizer Tokenizer, logger log.Logger) middleware.Middleware

func ServerExtractAndAuth

func ServerExtractAndAuth(tokenizer Tokenizer, logger log.Logger) middleware.Middleware

Types

type Claims

type Claims struct {
	Uid      string `json:"id,omitempty"`
	ClientId string `json:"clientId,omitempty"`
	jwt.StandardClaims
}

func ExtractAndValidate

func ExtractAndValidate(tokenizer Tokenizer, t string) (*Claims, error)

func FromClaimsContext

func FromClaimsContext(ctx context.Context) (claims *Claims, ok bool)

func NewClientClaim

func NewClientClaim(clientId string) *Claims

func NewUserClaim

func NewUserClaim(userId string) *Claims

type Tokenizer

type Tokenizer interface {
	Issue(claims *Claims, duration time.Duration) (token string, err error)
	Parse(token string) (claims *Claims, err error)
}

func NewTokenizer

func NewTokenizer(c *TokenizerConfig) Tokenizer

type TokenizerConfig

type TokenizerConfig struct {
	Issuer         string
	ExpireDuration time.Duration
	Secret         string
}

func NewTokenizerConfig

func NewTokenizerConfig(c *conf.Security) *TokenizerConfig

Jump to

Keyboard shortcuts

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