auth

package
v0.2.16 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnexpectedSigningMethod is returned when the signing method is unexpected.
	ErrUnexpectedSigningMethod = fmt.Errorf("unexpected signing method")
)

Functions

This section is empty.

Types

type TokenManager

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

TokenManager manages JWT tokens.

func NewTokenManager

func NewTokenManager(secretKey string, tokenDuration time.Duration) *TokenManager

NewTokenManager creates a new TokenManager.

func (*TokenManager) Generate

func (m *TokenManager) Generate(username string) (string, error)

Generate generates a new token for the user.

func (*TokenManager) Verify

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

Verify verifies the given token.

type UserClaims

type UserClaims struct {
	jwt.StandardClaims

	Username string `json:"username"`
}

UserClaims is a JWT claims struct for a user.

Jump to

Keyboard shortcuts

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