magic

package
v0.8.5 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2024 License: LGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MagicSigningPackage signing.SigningPackageInterface

Functions

func ExpireOld

func ExpireOld(db database.DatabaseAccessor, lookupUserID string, manuallyExpireTokenID ...string)

func FilterActive

func FilterActive(activeMagics chan MagicAuthentications, magics MagicAuthentications, manuallyExpireTokenID ...string)

Useful if you've already queried the user and just need a list of active magics back. Used in: the end of Validate() + ValidateSession()

Types

type MagicAuthentication

type MagicAuthentication struct {
	Code               string   // authentication code (hashed)
	AllowedPermissions []string // what the user can DO
	ExpiresAt          int64    // when the token expires
	InheritRole        string   // filled in at validation time
	Username           string   // filled in at validation time
}

func CreateMagicAuthentication

func CreateMagicAuthentication(macVariables MagicAuthenticationVariables) (MagicAuthentication, string, error)

Returns The MagicAuth for saving in the Database The Identifier String (userID:code:signature) Error, if any.

func MagicFromMap

func MagicFromMap(input map[string]interface{}) MagicAuthentication

func Validate

func Validate(db database.DatabaseAccessor, tokenIdentifer string) (MagicAuthentication, map[string]interface{}, error)

func (MagicAuthentication) ToMap

func (m MagicAuthentication) ToMap() map[string]interface{}

type MagicAuthenticationVariables

type MagicAuthenticationVariables struct {
	ForUserID          string
	AllowedPermissions []string      // what the user can DO
	TTL                time.Duration // how long the token should live for
}

type MagicAuthentications

type MagicAuthentications []MagicAuthentication

func MagicsFromMap

func MagicsFromMap(input []interface{}) MagicAuthentications

func (MagicAuthentications) ToMap

func (m MagicAuthentications) ToMap() []interface{}

Jump to

Keyboard shortcuts

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