auth

package
v0.6.4 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2023 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Claims

type Claims struct {
	UserID      xid.ID `json:"sub"`
	TokenID     xid.ID `json:"jti"`
	UserIsAdmin bool   `json:"adm"`

	// APIToken specifies whether this token was generated for the API or for the website.
	// API tokens cannot perform some destructive actions, such as DELETE /users/@me.
	APIToken bool `json:"atn"`
	// TokenWrite specifies whether this token can be used for write actions.
	// If set to false, this token can only be used for read actions.
	TokenWrite bool `json:"twr"`

	jwt.RegisteredClaims
}

Claims are the claims used in a token.

type Verifier

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

func New

func New() *Verifier

func (*Verifier) Claims

func (v *Verifier) Claims(token string) (c Claims, err error)

Claims parses the given token and returns its Claims. If the token is invalid, returns an error.

func (*Verifier) CreateToken

func (v *Verifier) CreateToken(userID, tokenID xid.ID, isAdmin bool, isAPIToken bool, isWriteToken bool) (token string, err error)

CreateToken creates a token for the given user ID. It expires after three months.

Jump to

Keyboard shortcuts

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