usecase

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 ErrKindMismatch = errors.New("secret kind doesn't match")

Functions

This section is empty.

Types

type Auth

type Auth interface {
	Login(ctx context.Context, username string, key entity.Key) (string, error)
}

type AuthUseCase

type AuthUseCase struct {
	// contains filtered or unexported fields
}

AuthUseCase contains business logic related to authentication.

func NewAuthUseCase

func NewAuthUseCase(
	auth repo.Auth,
) *AuthUseCase

NewAuthUseCase create and initializes new AuthUseCase object.

func (*AuthUseCase) Login

func (uc *AuthUseCase) Login(
	ctx context.Context,
	username string,
	key entity.Key,
) (string, error)

Login authenticates a user.

type Secrets

type Secrets interface {
	PushBinary(ctx context.Context, token, name, description string, binary []byte) (uuid.UUID, error)

	PushCard(
		ctx context.Context,
		token, name, description string,
		number, expiration, holder string,
		cvv int32,
	) (uuid.UUID, error)

	PushCreds(ctx context.Context, token, name, description, login, password string) (uuid.UUID, error)
	PushText(ctx context.Context, token, name, description, text string) (uuid.UUID, error)

	List(ctx context.Context, token string) ([]*goph.Secret, error)
	Get(ctx context.Context, token string, id uuid.UUID) (*goph.Secret, proto.Message, error)

	EditBinary(
		ctx context.Context,
		token string,
		id uuid.UUID,
		name, description string,
		noDescription bool,
		binary []byte,
	) error

	EditCard(
		ctx context.Context,
		token string,
		id uuid.UUID,
		name, description string,
		noDescription bool,
		number, expiration, holder string,
		cvv int32,
	) error

	EditCreds(
		ctx context.Context,
		token string,
		id uuid.UUID,
		name, description string,
		noDescription bool,
		login, password string,
	) error

	EditText(
		ctx context.Context,
		token string,
		id uuid.UUID,
		name, description string,
		noDescription bool,
		text string,
	) error

	Delete(ctx context.Context, token string, id uuid.UUID) error
}

type SecretsUseCase

type SecretsUseCase struct {
	// contains filtered or unexported fields
}

SecretsUseCase contains business logic related to secrets management.

func NewSecretsUseCase

func NewSecretsUseCase(key entity.Key, secrets repo.Secrets) *SecretsUseCase

NewSecretsUseCase create and initializes new SecretsUseCase object.

func (*SecretsUseCase) Delete

func (uc *SecretsUseCase) Delete(
	ctx context.Context,
	token string,
	id uuid.UUID,
) error

Delete removes user's secret.

func (*SecretsUseCase) EditBinary

func (uc *SecretsUseCase) EditBinary(
	ctx context.Context,
	token string,
	id uuid.UUID,
	name, description string,
	noDescription bool,
	binary []byte,
) error

EditBinary changes parameters of stored binary secret.

func (*SecretsUseCase) EditCard

func (uc *SecretsUseCase) EditCard(
	ctx context.Context,
	token string,
	id uuid.UUID,
	name, description string,
	noDescription bool,
	number, expiration, holder string,
	cvv int32,
) error

EditCard changes parameters of stored bank card.

func (*SecretsUseCase) EditCreds

func (uc *SecretsUseCase) EditCreds(
	ctx context.Context,
	token string,
	id uuid.UUID,
	name, description string,
	noDescription bool,
	login, password string,
) error

EditCreds changes parameters of stored credentials.

func (*SecretsUseCase) EditText

func (uc *SecretsUseCase) EditText(
	ctx context.Context,
	token string,
	id uuid.UUID,
	name, description string,
	noDescription bool,
	text string,
) error

EditText changes parameters of stored text secret.

func (*SecretsUseCase) Get

func (uc *SecretsUseCase) Get(
	ctx context.Context,
	token string,
	id uuid.UUID,
) (*goph.Secret, proto.Message, error)

Get retrieves full user's secret. All sensitive parts are decrypted.

func (*SecretsUseCase) List

func (uc *SecretsUseCase) List(ctx context.Context, token string) ([]*goph.Secret, error)

List returns list of user's secrets. All sensitive parts are decrypted.

func (*SecretsUseCase) PushBinary

func (uc *SecretsUseCase) PushBinary(
	ctx context.Context,
	token, name, description string,
	binary []byte,
) (uuid.UUID, error)

PushBinary creates new secret with arbitrary binary data.

func (*SecretsUseCase) PushCard

func (uc *SecretsUseCase) PushCard(
	ctx context.Context,
	token, name, description string,
	number, expiration, holder string,
	cvv int32,
) (uuid.UUID, error)

PushCard creates new secret containing bank card data.

func (*SecretsUseCase) PushCreds

func (uc *SecretsUseCase) PushCreds(
	ctx context.Context,
	token, name, description, login, password string,
) (uuid.UUID, error)

PushCreds creates new secret containing credentials.

func (*SecretsUseCase) PushText

func (uc *SecretsUseCase) PushText(
	ctx context.Context,
	token, name, description, text string,
) (uuid.UUID, error)

PushText creates new secret with arbitrary text.

type UseCases

type UseCases struct {
	Auth    Auth
	Secrets Secrets
	Users   Users
}

UseCases is a collection of business logic use cases.

func New

func New(key entity.Key, repos *repo.Repositories) *UseCases

New creates and initializes collection of business logic use cases.

type Users

type Users interface {
	Register(ctx context.Context, username string, key entity.Key) (string, error)
}

type UsersUseCase

type UsersUseCase struct {
	// contains filtered or unexported fields
}

UsersUseCase contains business logic related to users management.

func NewUsersUseCase

func NewUsersUseCase(users repo.Users) *UsersUseCase

NewUsersUseCase create and initializes new UsersUseCase object.

func (*UsersUseCase) Register

func (uc *UsersUseCase) Register(
	ctx context.Context,
	username string,
	key entity.Key,
) (string, error)

Register creates a new user.

Jump to

Keyboard shortcuts

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