Help us shape the future of Go! Take the 2026 Go Developer Survey

auth

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UserID = "user_id"
	Email  = "email"
)

Variables

This section is empty.

Functions

func SetEmail

func SetEmail(ctx *gin.Context, tok jwt.Token)

メールをコンテキストに代入

@paramss ctx コンテキスト tok トークン

Types

type JWTer

type JWTer struct {
	PrivateKey, PublicKey jwk.Key
	Store                 Store
	Clocker               clock.Clocker
}

func NewJWTer

func NewJWTer(s Store, c clock.Clocker) (*JWTer, error)

jWTのインスタンス

func (*JWTer) FillContext

func (j *JWTer) FillContext(ctx *gin.Context) error

トークンを解析し、contextにuserIDとEmailをセットする @params ctx コンテキスト

func (*JWTer) GenerateToken

func (j *JWTer) GenerateToken(ctx context.Context, u entities.User) ([]byte, error)

アクセストークンの作成 @params ctx コンテキスト u ユーザエンティティ

@returns token アクセストークン

func (*JWTer) GetToken

func (j *JWTer) GetToken(ctx context.Context, r *http.Request) (jwt.Token, error)

トークンを取得し解析 @params ctx コンテキスト r リクエスト情報

@returns トークン

type Store

type Store interface {
	Save(ctx context.Context, key, value string, minute time.Duration) error
	Load(ctx context.Context, key string) (string, error)
	Expire(ctx context.Context, key string, expiration time.Duration) error
}

Jump to

Keyboard shortcuts

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