auth

package
v0.0.0-...-f952efe Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RBAC

func RBAC(r *RBACRequest) error

RBAC (role base access control)

Types

type JWTManager

type JWTManager struct {
	// contains filtered or unexported fields
}

JWTManager is a JSON web token manager

func NewJWTManager

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

NewJWTManager returns a new JWT manager

func (*JWTManager) Generate

func (manager *JWTManager) Generate(user *model.User) (string, error)

Generate generates and signs a new token for a user

func (*JWTManager) Verify

func (manager *JWTManager) Verify(accessToken string) (*UserClaims, error)

Verify verifies the access token string and return a user claim if the token is valid

type RBACRequest

type RBACRequest struct {
	// contains filtered or unexported fields
}

type UserClaims

type UserClaims struct {
	jwt.StandardClaims
	ID uint64 `json:"id"`
}

UserClaims is a custom JWT claims that contains some user's information

Jump to

Keyboard shortcuts

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