auth

package
v0.0.0-...-3235916 Latest Latest
Warning

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

Go to latest
Published: May 5, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const Header = "authorization"

Variables

This section is empty.

Functions

This section is empty.

Types

type Interceptor

type Interceptor interface {
	Unary() grpc.UnaryServerInterceptor
	Stream() grpc.StreamServerInterceptor
}

func NewInterceptor

func NewInterceptor(manager TokenManager, accessibleRoles map[string][]string, log *zap.Logger) Interceptor

type Manager

type Manager interface {
	TokenManager
	Interceptor
}

func NewManager

func NewManager(tm TokenManager, accessibleRoles map[string][]string, log *zap.Logger) Manager

type TokenManager

type TokenManager interface {
	Generate(user, role string) (string, error)
	Verify(accessToken string) (*UserClaims, error)
	GetUserClaimsFromContext(ctx context.Context) (*UserClaims, bool)
	PutUserClaimsToContext(ctx context.Context, claims *UserClaims) context.Context
}

func NewJWTManager

func NewJWTManager(secretKey string, tokenDuration time.Duration) TokenManager

type UserClaims

type UserClaims struct {
	jwt.StandardClaims
	Username string `json:"username"`
	Role     string `json:"role"`
}

Jump to

Keyboard shortcuts

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