user

package
v0.0.0-...-94d0466 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2025 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

WireSet provides a wire set for this package.

Functions

func GenerateSessionTokenIdentifier

func GenerateSessionTokenIdentifier() (string, error)

Types

type Controller

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

func NewController

func NewController(
	tx dbtx.Transactor,
	principalUIDCheck check.PrincipalUID,
	authorizer authz.Authorizer,
	principalStore store.PrincipalStore,
	tokenStore store.TokenStore,
	membershipStore store.MembershipStore,
	publicKeyStore store.PublicKeyStore,
) *Controller

func ProvideController

func ProvideController(
	tx dbtx.Transactor,
	principalUIDCheck check.PrincipalUID,
	authorizer authz.Authorizer,
	principalStore store.PrincipalStore,
	tokenStore store.TokenStore,
	membershipStore store.MembershipStore,
	publicKeyStore store.PublicKeyStore,
) *Controller

func (*Controller) Create

func (c *Controller) Create(ctx context.Context, session *auth.Session, in *CreateInput) (*types.User, error)

Create creates a new user.

func (*Controller) CreateAccessToken

func (c *Controller) CreateAccessToken(
	ctx context.Context,
	session *auth.Session,
	userUID string,
	in *CreateTokenInput,
) (*types.TokenResponse, error)

* CreateToken creates a new user access token.

func (*Controller) CreateNoAuth

func (c *Controller) CreateNoAuth(ctx context.Context, in *CreateInput, admin bool) (*types.User, error)

* CreateNoAuth creates a new user without auth checks. * WARNING: Never call as part of user flow. * * Note: take admin separately to avoid potential vulnerabilities for user calls.

func (*Controller) CreatePublicKey

func (c *Controller) CreatePublicKey(
	ctx context.Context,
	session *auth.Session,
	userUID string,
	in *CreatePublicKeyInput,
) (*types.PublicKey, error)

func (*Controller) Delete

func (c *Controller) Delete(ctx context.Context, session *auth.Session,
	userUID string) error

Delete deletes a user.

func (*Controller) DeletePublicKey

func (c *Controller) DeletePublicKey(
	ctx context.Context,
	session *auth.Session,
	userUID string,
	identifier string,
) error

func (*Controller) DeleteToken

func (c *Controller) DeleteToken(
	ctx context.Context,
	session *auth.Session,
	userUID string,
	tokenType enum.TokenType,
	tokenIdentifier string) error

* DeleteToken deletes a token of a user.

func (*Controller) Find

func (c *Controller) Find(ctx context.Context, session *auth.Session,
	userUID string) (*types.User, error)

* Find tries to find the provided user.

func (*Controller) FindEmail

func (c *Controller) FindEmail(ctx context.Context, session *auth.Session,
	email string) (*types.User, error)

* FindEmail tries to find the provided user using email.

func (*Controller) FindNoAuth

func (c *Controller) FindNoAuth(ctx context.Context, userUID string) (*types.User, error)

* FindNoAuth finds a user without auth checks. * WARNING: Never call as part of user flow.

func (*Controller) List

func (c *Controller) List(ctx context.Context, session *auth.Session,
	filter *types.UserFilter) ([]*types.User, int64, error)

* List lists all users of the system.

func (*Controller) ListPublicKeys

func (c *Controller) ListPublicKeys(
	ctx context.Context,
	session *auth.Session,
	userUID string,
	filter *types.PublicKeyFilter,
) ([]types.PublicKey, int, error)

func (*Controller) ListTokens

func (c *Controller) ListTokens(ctx context.Context, session *auth.Session,
	userUID string, tokenType enum.TokenType) ([]*types.Token, error)

* ListTokens lists all tokens of a user.

func (*Controller) Login

func (c *Controller) Login(
	ctx context.Context,
	in *LoginInput,
) (*types.TokenResponse, error)

* Login attempts to login as a specific user - returns the session token if successful.

func (*Controller) Logout

func (c *Controller) Logout(ctx context.Context, session *auth.Session) error

Logout searches for the user's token present in the request and proceeds to delete it. If no user was present, a usererror.ErrUnauthorized is returned.

func (*Controller) MembershipSpaces

func (c *Controller) MembershipSpaces(ctx context.Context,
	session *auth.Session,
	userUID string,
	filter types.MembershipSpaceFilter,
) ([]types.MembershipSpace, int64, error)

MembershipSpaces lists all spaces in which the user is a member.

func (*Controller) Register

func (c *Controller) Register(ctx context.Context, sysCtrl *system.Controller,
	in *RegisterInput) (*types.TokenResponse, error)

Register creates a new user and returns a new session token on success. This doesn't require auth, but has limited functionalities (unable to create admin user for example).

func (*Controller) Search

func (c *Controller) Search(ctx context.Context, session *auth.Session,
	userUID string) (*types.User, error)

func (*Controller) SearchSpace

func (c *Controller) SearchSpace(ctx context.Context, session *auth.Session,
	userUID string) (*types.User, error)

func (*Controller) Update

func (c *Controller) Update(ctx context.Context, session *auth.Session,
	userUID string, in *UpdateInput) (*types.User, error)

Update updates the provided user.

func (*Controller) UpdateAdmin

func (c *Controller) UpdateAdmin(ctx context.Context, session *auth.Session,
	userUID string, request *UpdateAdminInput) (*types.User, error)

UpdateAdmin updates the admin state of a user.

func (*Controller) UpdateBlocked

func (c *Controller) UpdateBlocked(ctx context.Context, session *auth.Session,
	userUID string, request *UpdateBlockedInput) (*types.User, error)

UpdateBlocked updates the blocked state of a user.

type CreateInput

type CreateInput struct {
	UID          string `json:"uid"`
	Email        string `json:"email"`
	DisplayName  string `json:"display_name"`
	Password     string `json:"password,omitempty"`
	PasswordHash string `json:"password_hash,omitempty"`
	Source       string `json:"source,omitempty"`
}

CreateInput is the input used for create operations. On purpose don't expose admin, has to be enabled explicitly.

type CreatePublicKeyInput

type CreatePublicKeyInput struct {
	Identifier string              `json:"identifier"`
	Usage      enum.PublicKeyUsage `json:"usage"`
	Content    string              `json:"content"`
}

type CreateTokenInput

type CreateTokenInput struct {
	// TODO [CODE-1363]: remove after identifier migration.
	UID        string         `json:"uid" deprecated:"true"`
	Identifier string         `json:"identifier"`
	Lifetime   *time.Duration `json:"lifetime"`
}

type LoginInput

type LoginInput struct {
	LoginIdentifier string `json:"login_identifier"`
	Password        string `json:"password"`
}

type RegisterInput

type RegisterInput struct {
	Email       string `json:"email"`
	DisplayName string `json:"display_name"`
	UID         string `json:"uid"`
	Password    string `json:"password"`
}

type UpdateAdminInput

type UpdateAdminInput struct {
	Admin bool `json:"admin"`
}

type UpdateBlockedInput

type UpdateBlockedInput struct {
	Blocked bool `json:"blocked"`
}

type UpdateInput

type UpdateInput struct {
	Email        *string `json:"email"`
	Password     *string `json:"password"`
	DisplayName  *string `json:"display_name"`
	Source       *string `json:"source,omitempty"`
	PasswordHash *string `json:"password_hash,omitempty"`
}

UpdateInput store infos to update an existing user.

Jump to

Keyboard shortcuts

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