token

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrRevoked token has been revoked
	ErrRevoked = fmt.Errorf("token has been revoked")
)

Functions

This section is empty.

Types

type JWTClaims

type JWTClaims struct {
	jwt.RegisteredClaims

	UID string `json:"uid"`
}

JWTClaims is the claims for the JWT token

func (JWTClaims) Valid

func (j JWTClaims) Valid() error

Valid validates the claims

type TokenService

type TokenService interface {
	// New creates a new token.
	New(id int64, expire time.Duration) (string, error)
	// Validate validates the token.
	Validate(ctx context.Context, token string) (string, int64, error)
	// Revoke revokes the token.
	Revoke(ctx context.Context, id string) error
}

TokenService is the interface for token service.

func NewTokenService

func NewTokenService(privateKeyString string) (TokenService, error)

NewTokenService creates a new token service.

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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