jwtauth

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2022 License: MIT Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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