tokens

package
v0.0.0-...-9835270 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2021 License: AGPL-3.0, Apache-2.0, Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// UserPrefix is a common prefix for every user_id caveat
	UserPrefix = "user_id = "
	// TimePrefix is a common prefix for every expiry caveat
	TimePrefix = "time < "
	// Gen is a common caveat for every token
	Gen = "gen = 1"
)

Variables

This section is empty.

Functions

func GenerateLoginToken

func GenerateLoginToken(op TokenOptions) (string, error)

GenerateLoginToken generates a short term login token to be used as token authentication ("m.login.token")

func GetUserFromToken

func GetUserFromToken(token string) (user string, err error)

GetUserFromToken returns the user associated with the token Returns the error if something goes wrong. Warning: Does not validate the token. Use ValidateToken for that.

func ValidateToken

func ValidateToken(op TokenOptions, token string) error

ValidateToken validates that the Token is understood and was signed by this server. Returns nil if token is valid, otherwise returns a error.

Types

type TokenOptions

type TokenOptions struct {
	ServerPrivateKey []byte `yaml:"private_key"`
	ServerName       string `yaml:"server_name"`
	UserID           string `json:"user_id"`
	Duration         int    // optional
}

TokenOptions represent parameters of Token

Jump to

Keyboard shortcuts

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