state

package
v0.0.0-...-56cb166 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2025 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type State

type State struct {
	*domain.StateBase
}

State represents a type for interacting with the underlying state of a user's public key in a model.

func NewState

func NewState(factory database.TxnRunnerFactory) *State

NewState is responsible for constructing a new State that can be used with this domains corresponding service.

func (*State) AddPublicKeysForUser

func (s *State) AddPublicKeysForUser(
	ctx context.Context,
	modelUUID model.UUID,
	userUUID user.UUID,
	publicKeys []keymanager.PublicKey,
) error

AddPublicKeyForUser is responsible for adding one or more ssh public keys for a user to a given model. The following errors can be expected: - keyerrors.PublicKeyAlreadyExists - When one of the public keys being added for a user already exists on the model. - accesserrors.UserNotFound - When the user does not exist. - modelerrors.NotFound - When the model does not exist.

func (*State) DeletePublicKeysForUser

func (s *State) DeletePublicKeysForUser(
	ctx context.Context,
	modelUUID model.UUID,
	userUUID user.UUID,
	keyIds []string,
) error

DeletePublicKeysForUser is responsible for removing the keys from the users list of public keys on the given model. keyIds represent one of the keys fingerprint, public key data or comment. The following errors can be expected: - accesserrors.UserNotFound - When the user does not exist. - modelerrors.NotFound - When the model does not exist.

func (*State) EnsurePublicKeysForUser

func (s *State) EnsurePublicKeysForUser(
	ctx context.Context,
	modelUUID model.UUID,
	userUUID user.UUID,
	publicKeys []keymanager.PublicKey,
) error

EnsurePublicKeysForUser will attempt to add the given set of public keys for the user to the specified model . If the user already has the public key in the model it will be skipped and no keyerrors.PublicKeyAlreadyExists error will be returned. The following errors can be expected: - accesserrors.UserNotFound - When the user does not exist. - modelerrors.NotFound - When the model does not exist.

func (*State) GetAllUsersPublicKeys

func (s *State) GetAllUsersPublicKeys(
	ctx context.Context,
	modelUUID model.UUID,
) (map[user.Name][]string, error)

GetAllUsersPublicKeys returns all of the public keys that are in a model and their respective username. This is useful for building a view during model migration. The following errors can be expected: - modelerrors.NotFound - When no model exists for the uuid.

func (*State) GetPublicKeysDataForUser

func (s *State) GetPublicKeysDataForUser(
	ctx context.Context,
	modelUUID model.UUID,
	userUUID user.UUID,
) ([]string, error)

GetPublicKeysDataForUser is responsible for returning all of the public keys raw data for the user uuid on a given model. The following error can be expected: - accesserrors.UserNotFound if the user does not exist. - modelerrors.NotFound if the model does not exist.

func (*State) GetPublicKeysForUser

func (s *State) GetPublicKeysForUser(
	ctx context.Context,
	modelUUID model.UUID,
	userUUID user.UUID,
) ([]coressh.PublicKey, error)

GetPublicKeysForUser is responsible for returning all of the public keys for the user uuid in this model. If the user does not exist no error is returned.

Jump to

Keyboard shortcuts

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