models

package
v0.0.0-...-5ff450b Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KeyStateActive      = "ACTIVE"
	KeyStateNext        = "NEXT"
	KeyStateDeactivated = "DEACTIVATED"
)

Key states

View Source
const (
	MinimumPasswordLength = 8
)
View Source
const (
	UserRole = "USER"
)

User roles

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthenticationRequest

type AuthenticationRequest struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

AuthenticationRequest request to signup or login.

func (AuthenticationRequest) String

func (r AuthenticationRequest) String() string

func (AuthenticationRequest) Valid

func (r AuthenticationRequest) Valid(checkPassword bool) error

Valid validates if an authenication request is valid.

type AuthenticationResponse

type AuthenticationResponse struct {
	Token string `json:"token"`
	User  User   `json:"user"`
}

AuthenticationResponse response to successfull signup or login.

func (AuthenticationResponse) String

func (r AuthenticationResponse) String() string

type Credentials

type Credentials struct {
	Password          string
	Salt              string
	DataEncryptionKey DataEncryptionKey
}

Credentials authenication information

func (Credentials) Decode

func (c Credentials) Decode() ([]byte, []byte, error)

type DataEncryptionKey

type DataEncryptionKey struct {
	Body               string // Body is a hex encoded string of an encrypted byte array.
	KeyEncryptionKeyID int
}

DataEncryptionKey (DEK) key to encrypt and decrypt a objects. A DEK is encrypted with a KeyEncryptionKey.

func (DataEncryptionKey) String

func (d DataEncryptionKey) String() string

type KeyEncryptionKey

type KeyEncryptionKey struct {
	ID int
	// contains filtered or unexported fields
}

KeyEncryptionKey (KEK) key to encrypt and decrypt a data encryption key.

func ParseKeyEncryptionKey

func ParseKeyEncryptionKey(s string) (KeyEncryptionKey, error)

ParseKeyEncryptionKey parses a hex encode key encryption key and id.

func (KeyEncryptionKey) Decrypt

func (k KeyEncryptionKey) Decrypt(dek DataEncryptionKey) ([]byte, error)

Decrypt decodes the hex encoded ciphertext and decrypts the encoded data encryption key with with the key encryption key body.

func (KeyEncryptionKey) Encrypt

func (k KeyEncryptionKey) Encrypt(plaintext []byte) (DataEncryptionKey, error)

Encrypt encrypts the provided data encryption key with with the key encryption key body. Encodes the result as a hex string.

func (KeyEncryptionKey) String

func (k KeyEncryptionKey) String() string

func (KeyEncryptionKey) Valid

func (k KeyEncryptionKey) Valid() error

Valid checks that a key is valid by asserting its size.

type User

type User struct {
	ID          string      `json:"id"`
	Username    string      `json:"username"`
	Role        string      `json:"role"`
	Credentials Credentials `json:"-"`
	CreatedAt   time.Time   `json:"createdAt"`
	UpdatedAt   time.Time   `json:"updatedAt"`
}

User account describing a user of the object storage service.

func NewUser

func NewUser(username, role string, credentials Credentials) User

func (User) JWTUser

func (u User) JWTUser() jwt.User

func (User) String

func (u User) String() string

Jump to

Keyboard shortcuts

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