auth

package
v0.0.0-...-81f6757 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthInterceptor

type AuthInterceptor struct {
	JwtManager JwtManager
	// contains filtered or unexported fields
}

func NewAuthInterceptor

func NewAuthInterceptor(jwtManager JwtManager, methodsRoles map[string][]string) *AuthInterceptor

func (*AuthInterceptor) Unary

type JwtManager

type JwtManager struct {
	SecretKey string
	Duration  time.Duration
}

func NewJWTManager

func NewJWTManager(secretKey string, tokenDuration time.Duration) *JwtManager

func (*JwtManager) GenerateKey

func (m *JwtManager) GenerateKey(user *User) (string, error)

func (*JwtManager) Verify

func (m *JwtManager) Verify(token string) (*UserClaims, error)

type User

type User struct {
	Username       string
	HashedPassword string
	Role           string
}

func (*User) CheckPassword

func (u *User) CheckPassword(password string) error

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