jwtauth

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetClaims

func GetClaims(ctx context.Context) (map[string]interface{}, bool)

GetClaims ... JWTAuthのClaimsの値を取得

func GetUserID

func GetUserID(ctx context.Context) string

GetUserID ... JWTAuthのユーザーIDを取得

Types

type Claims

type Claims struct {
	UserID       string                 `json:"user_id"`
	CustomClaims map[string]interface{} `json:"custom_claims"`
	jwt.StandardClaims
}

Claims ... JWTに仕込むclaims定義

type Middleware

type Middleware struct {
	Svc Service
}

Middleware ... JWT認証のミドルウェア

func NewMiddleware

func NewMiddleware(svc Service) *Middleware

NewMiddleware ... Middlewareを作成する

func (*Middleware) Handle

func (m *Middleware) Handle(next http.Handler) http.Handler

Handle ... JWT認証をする

type Service

type Service interface {
	CreateToken(
		ctx context.Context,
		userID string,
		customClaims map[string]interface{}) (string, error)
	Authentication(
		ctx context.Context,
		ah string) (string, map[string]interface{}, error)
}

Service ... JWT認証の機能を提供する

func NewService

func NewService(signKey string, expired time.Duration) Service

NewService ... Serviceを作成する

func NewServiceDebug

func NewServiceDebug(signKey string, expired time.Duration, dummyClaims map[string]interface{}) Service

NewServiceDebug ... Serviceを作成する

Jump to

Keyboard shortcuts

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