usermanager

package
v0.0.0-...-cf6de95 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2025 License: AGPL-3.0 Imports: 20 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(registry facade.FacadeRegistry)

Register is called to expose a package of facades onto a given registry.

Types

type AccessService

type AccessService interface {
	GetAllUsers(ctx context.Context, includeDisabled bool) ([]coreuser.User, error)
	GetUserByName(ctx context.Context, name coreuser.Name) (coreuser.User, error)
	AddUser(ctx context.Context, arg service.AddUserArg) (coreuser.UUID, []byte, error)
	EnableUserAuthentication(ctx context.Context, name coreuser.Name) error
	DisableUserAuthentication(ctx context.Context, name coreuser.Name) error
	SetPassword(ctx context.Context, name coreuser.Name, password auth.Password) error
	ResetPassword(ctx context.Context, name coreuser.Name) ([]byte, error)
	RemoveUser(ctx context.Context, name coreuser.Name) error

	// ReadUserAccessLevelForTarget returns the access level that the
	// input user has been on the input target entity.
	// If the access level of a user cannot be found then
	// accesserrors.AccessNotFound is returned.
	ReadUserAccessLevelForTarget(ctx context.Context, subject coreuser.Name, target permission.ID) (permission.Access, error)
}

AccessService defines the methods to operate with the database.

type ModelService

type ModelService interface {
	// GetModelUsers will retrieve basic information about users with
	// permissions on the given model UUID.
	// If the model cannot be found it will return
	// [github.com/juju/juju/domain/model/errors.NotFound].
	GetModelUsers(ctx context.Context, modelUUID coremodel.UUID) ([]coremodel.ModelUserInfo, error)

	// GetModelUser will retrieve basic information about the specified model
	// user.
	// If the model cannot be found it will return
	// [github.com/juju/juju/domain/model/errors.NotFound].
	// If the user cannot be found it will return
	// [github.com/juju/juju/domain/model/errors.UserNotFoundOnModel].
	GetModelUser(ctx context.Context, modelUUID coremodel.UUID, name coreuser.Name) (coremodel.ModelUserInfo, error)
}

ModelService defines an interface for interacting with the model service.

type UserManagerAPI

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

UserManagerAPI implements the user manager interface and is the concrete implementation of the api end point.

func NewAPI

func NewAPI(
	state *state.State,
	accessService AccessService,
	modelService ModelService,
	authorizer facade.Authorizer,
	check *common.BlockChecker,
	apiUserTag names.UserTag,
	apiUser coreuser.User,
	isAdmin bool,
	logger corelogger.Logger,
	controllerUUID string,
) (*UserManagerAPI, error)

NewAPI creates a new API endpoint for calling user manager functions.

func (*UserManagerAPI) AddUser

AddUser adds a user with a username, and either a password or a randomly generated secret key which will be returned.

func (*UserManagerAPI) DisableUser

func (api *UserManagerAPI) DisableUser(ctx context.Context, users params.Entities) (params.ErrorResults, error)

DisableUser disables one or more users. If the user is already disabled, the action is considered a success.

func (*UserManagerAPI) EnableUser

func (api *UserManagerAPI) EnableUser(ctx context.Context, users params.Entities) (params.ErrorResults, error)

EnableUser enables one or more users. If the user is already enabled, the action is considered a success.

func (*UserManagerAPI) ModelUserInfo

func (api *UserManagerAPI) ModelUserInfo(ctx context.Context, args params.Entities) (params.ModelUserInfoResults, error)

ModelUserInfo returns information on all users in the model.

func (*UserManagerAPI) RemoveUser

func (api *UserManagerAPI) RemoveUser(ctx context.Context, entities params.Entities) (params.ErrorResults, error)

RemoveUser permanently removes a user from the current controller for each entity provided. While the user is permanently removed we keep it's information around for auditing purposes. TODO(redir): Add information about getting deleted user information when we add that capability.

func (*UserManagerAPI) ResetPassword

func (api *UserManagerAPI) ResetPassword(ctx context.Context, args params.Entities) (params.AddUserResults, error)

ResetPassword resets password for supplied users by invalidating current passwords (if any) and generating new random secret keys which will be returned. Users cannot reset their own password.

func (*UserManagerAPI) SetPassword

SetPassword changes the stored password for the specified users.

func (*UserManagerAPI) UserInfo

UserInfo returns information on a user.

Jump to

Keyboard shortcuts

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