auth

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HMAC256Algorithm signingAlgorithm = "HS256"
)

The valid JWT hashing function algorithms.

Variables

This section is empty.

Functions

This section is empty.

Types

type JWTSettings

type JWTSettings struct {
	Issuer     string
	Lifespan   int
	SigningKey string
	Algorithm  signingAlgorithm
}

JWTSettings are the available configuration values for generating JWTs.

type Service

type Service struct {
	Repo store.Repository
}

func (Service) IntrospectToken

func (s Service) IntrospectToken(ctx context.Context, token string) (TokenInfo, error)

func (Service) Login

func (s Service) Login(ctx context.Context, username, password string) (Token, error)

func (Service) Logout

func (s Service) Logout(ctx context.Context, token string) error

func (Service) ValidateAPIKey

func (s Service) ValidateAPIKey(ctx context.Context, key string) error

type Token

type Token struct {
	AccessToken string `json:"accessToken"`
	Lifespan    int    `json:"lifespan"`
}

Token holds the information required for transmitting the JWT to the client.

type TokenInfo

type TokenInfo struct {
	Active    bool   `json:"active"`
	UserID    string `json:"sub,omitempty"`
	Username  string `json:"username,omitempty"`
	ExpiresAt int    `json:"exp,omitempty"`
}

Jump to

Keyboard shortcuts

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