common

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClientJWT

func NewClientJWT(secret string, client authdb.ClientModel) string

NewClientJWT creates a jwt token string for the given client, with the given secret string. Returns empty string on error.

func NewUserJWT

func NewUserJWT(secret string, user authdb.UserModel) string

NewUserJWT creates a jwt token string for the given user, with the given secret string. Returns empty string on error.

func ValidateEmail

func ValidateEmail(email string) bool

ValidateEmail checks whether email is a valid email address.

func ValidatePassword

func ValidatePassword(password string) error

ValidatePassword checks whether password is strong enough.

func ValidateRedirectURI

func ValidateRedirectURI(uri string) bool

ValidateRedirectURI validates a client redirect URI.

func ValidateScope

func ValidateScope(resType string, scope []string) bool

ValidateScope checks whether the scope string is valid for the given response type.

func VerifyPassword

func VerifyPassword(hash, password string) bool

VerifyPassword verifies that a given password matches the hash.

Types

type Claims

type Claims struct {
	Sub  string `json:"sub"`
	Type string `json:"type"`
	PKey string `json:"pkey"`
	Iss  string `json:"iss"`
	Aud  string `json:"aud"`
	Exp  int64  `json:"exp"`
}

Claims are the JWT claims.

func ValidateJWT

func ValidateJWT(literal, secret string) (Claims, bool)

ValidateJWT checks if the JWT string literal is valid. It does not check if the user password has been changed.

Jump to

Keyboard shortcuts

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