jwt

package
v0.0.0-...-89b6d9c Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2022 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessDetails

type AccessDetails struct {
	AccessID string
	UserID   string
	Admin    bool
	Mod      bool
}

AccessDetails contains data stored in the jwt token

type Module

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

Module is a module for processing jwt tokens

func New

func New(db db.DB, kv kv.JWT) (*Module, error)

New creates a new JWT module

func (Module) Close

func (m Module) Close() error

Close closes the jwt module

func (*Module) CreateAuth

func (m *Module) CreateAuth(ctx context.Context, userid int64, td *TokenDetails) error

CreateAuth inserts the token data into the KV

func (*Module) CreateToken

func (m *Module) CreateToken(ctx context.Context, user *models.FediAccount) (*TokenDetails, error)

CreateToken creates a token based on a account

func (*Module) DeleteRefreshToken

func (m *Module) DeleteRefreshToken(ctx context.Context, refreshToken string) error

DeleteRefreshToken deletes a refresh token from KV

func (*Module) DeleteTokens

func (m *Module) DeleteTokens(ctx context.Context, authD *AccessDetails) error

DeleteTokens deletes tokens from the KV

func (*Module) ExtractTokenMetadata

func (m *Module) ExtractTokenMetadata(r *http.Request) (*AccessDetails, error)

ExtractTokenMetadata gets the token from the bearer token

func (*Module) RefreshAccessToken

func (m *Module) RefreshAccessToken(ctx context.Context, refreshToken string) (*TokenDetails, error)

RefreshAccessToken generates a new access token for a given refresh token

type TokenDetails

type TokenDetails struct {
	AccessToken  string `json:"access_token"`
	RefreshToken string `json:"refresh_token"`
	AccessID     string
	RefreshID    string
	AtExpires    int64
	RtExpires    int64
}

TokenDetails contains the metadata for a token

Jump to

Keyboard shortcuts

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