jwt

package
v1.6.3 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2024 License: MIT Imports: 10 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create

func Create(claims Claims, privatekey string) (string, error)

Create creates server signed JWT

Types

type Claims

type Claims struct {
	Issuer         string `json:"iss,omitempty"` // 発行者
	Subject        string `json:"sub,omitempty"` // 用途
	Audience       string `json:"aud,omitempty"` // 想定利用者
	ExpirationTime string `json:"exp,omitempty"` // 失効時刻
	IssuedAt       string `json:"iat,omitempty"` // 発行時刻
	JWTID          string `json:"jti,omitempty"` // JWT ID
}

Claims is jwt payload type

func Validate

func Validate(jwt string) (Claims, error)

Validate checks is jwt signature valid and not expired

type Header struct {
	Algorithm string `json:"alg"`
	Type      string `json:"typ"`
}

Header is jwt header type

type Repository

type Repository interface {
	CheckJTI(ctx context.Context, jti string) (bool, error)
	InvalidateJTI(ctx context.Context, jti string, exp time.Time) error
}

func NewRepository

func NewRepository(rdb *redis.Client) Repository

type Service

type Service interface {
	CheckJTI(ctx context.Context, jti string) (bool, error)
	InvalidateJTI(ctx context.Context, jti string, exp time.Time) error
}

Service is the interface for auth service

func NewService

func NewService(repository Repository) Service

NewService creates a new auth service

Jump to

Keyboard shortcuts

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