entity

package
v0.0.0-...-6aec01b Latest Latest
Warning

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

Go to latest
Published: May 17, 2023 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSecretNotFound     = errors.New("secret not found")
	ErrSecretExists       = errors.New("secret already exists")
	ErrSecretNameConflict = errors.New("secret with such name already exists")
)
View Source
var (
	ErrInvalidCredentials = errors.New("invalid username or security key")
	ErrUserExists         = errors.New("user already exists")
)

Functions

This section is empty.

Types

type AccessToken

type AccessToken string

AccessToken is JWT token used for authentication.

func NewAccessToken

func NewAccessToken(user User, secret creds.Password) (AccessToken, error)

NewAccessToken issues new access token valid for limited period of time.

func TokenFromString

func TokenFromString(src string) AccessToken

TokenFromString create new AccessToken from provided string. Supports strings in form of "Bearer xxx" or raw tokens.

func (AccessToken) Decode

func (t AccessToken) Decode(secret creds.Password) (*Claims, error)

Decode decodes token, verifies it's signature and return claims if the token is valid.

func (AccessToken) String

func (t AccessToken) String() string

String converts AccessToken to string.

type Claims

type Claims struct {
	jwt.RegisteredClaims
	Username string
}

Claims contain token's payload with various info about token itself and authentciated user.

type Secret

type Secret struct {
	ID       uuid.UUID `db:"secret_id"`
	Name     string
	Kind     goph.DataKind
	Metadata []byte
	Data     []byte
}

Secret represents full secret info stored in the service.

type User

type User struct {
	ID       uuid.UUID `db:"user_id"`
	Username string
}

User represents basic user of the system.

func UserFromContext

func UserFromContext(ctx context.Context) *User

UserFromContext extracts User object from context. Returns nil, if there is no info regarding user in the context.

func (User) WithContext

func (u User) WithContext(ctx context.Context) context.Context

WithContext injects user info into context.

Jump to

Keyboard shortcuts

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