user

package
v0.0.0-...-39bdb22 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2026 License: Apache-2.0 Imports: 24 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AnonymizedUser = apierrors.Forbidden.WithReason("AnonymizedUser")
View Source
var DependencySet = wire.NewSet(
	wire.Struct(new(Store), "*"),
	wire.Bind(new(store), new(*Store)),
	wire.Struct(new(Commands), "*"),
	wire.Struct(new(Queries), "*"),
	wire.Struct(new(RawQueries), "*"),
	wire.Struct(new(RawCommands), "*"),
	wire.Struct(new(Provider), "*"),
)
View Source
var DisabledUser = apierrors.Forbidden.WithReason("DisabledUser")
View Source
var ErrAnonymizedUser = AnonymizedUser.New("user is anonymized")
View Source
var ErrUserNotFound = api.UserNotFound.New("user not found")
View Source
var ErrUserOutsideValidPeriod = UserOutsideValidPeriod.New("user is outside valid period")
View Source
var InvalidAccountStatusTransition = apierrors.Invalid.WithReason("InvalidAccountStatusTransition")
View Source
var ScheduledAnonymizationByAdmin = apierrors.Forbidden.WithReason("ScheduledAnonymizationByAdmin")
View Source
var ScheduledDeletionByAdmin = apierrors.Forbidden.WithReason("ScheduledDeletionByAdmin")
View Source
var ScheduledDeletionByEndUser = apierrors.Forbidden.WithReason("ScheduledDeletionByEndUser")
View Source
var UserOutsideValidPeriod = apierrors.Forbidden.WithReason("UserOutsideValidPeriod")

Functions

func IsAccountStatusError

func IsAccountStatusError(err error) bool

func NewErrDisabledUser

func NewErrDisabledUser(reason *string) error

func NewErrScheduledAnonymizationByAdmin

func NewErrScheduledAnonymizationByAdmin(anonymizeAt time.Time) error

func NewErrScheduledDeletionByAdmin

func NewErrScheduledDeletionByAdmin(deleteAt time.Time) error

func NewErrScheduledDeletionByEndUser

func NewErrScheduledDeletionByEndUser(deleteAt time.Time) error

Types

type AccountStatus

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

func (AccountStatus) WithRefTime

func (s AccountStatus) WithRefTime(refTime time.Time) AccountStatusWithRefTime

type AccountStatusVariantDisabledIndefinitely

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

type AccountStatusVariantDisabledTemporarily

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

type AccountStatusVariantNormal

type AccountStatusVariantNormal struct{}

type AccountStatusVariantScheduledAnonymizationByAdmin

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

type AccountStatusVariantScheduledDeletionByAdmin

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

type AccountStatusVariantScheduledDeletionByEndUser

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

type AccountStatusWithRefTime

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

func (AccountStatusWithRefTime) AccountStatusStaleFrom

func (s AccountStatusWithRefTime) AccountStatusStaleFrom() *time.Time

func (AccountStatusWithRefTime) AccountValidFrom

func (s AccountStatusWithRefTime) AccountValidFrom() *time.Time

func (AccountStatusWithRefTime) AccountValidUntil

func (s AccountStatusWithRefTime) AccountValidUntil() *time.Time

func (AccountStatusWithRefTime) Anonymize

func (AccountStatusWithRefTime) AnonymizeAt

func (s AccountStatusWithRefTime) AnonymizeAt() *time.Time

func (AccountStatusWithRefTime) Check

func (s AccountStatusWithRefTime) Check() error

func (AccountStatusWithRefTime) DeleteAt

func (s AccountStatusWithRefTime) DeleteAt() *time.Time

func (AccountStatusWithRefTime) DeleteReason

func (s AccountStatusWithRefTime) DeleteReason() *string

func (AccountStatusWithRefTime) DisableIndefinitely

func (s AccountStatusWithRefTime) DisableIndefinitely(reason *string) (*AccountStatusWithRefTime, error)

func (AccountStatusWithRefTime) DisableReason

func (s AccountStatusWithRefTime) DisableReason() *string

func (AccountStatusWithRefTime) DisableTemporarily

func (s AccountStatusWithRefTime) DisableTemporarily(from *time.Time, until *time.Time, reason *string) (*AccountStatusWithRefTime, error)

func (AccountStatusWithRefTime) IsAnonymized

func (s AccountStatusWithRefTime) IsAnonymized() bool

func (AccountStatusWithRefTime) IsDeactivated

func (s AccountStatusWithRefTime) IsDeactivated() bool

func (AccountStatusWithRefTime) IsDisabled

func (s AccountStatusWithRefTime) IsDisabled() bool

func (AccountStatusWithRefTime) Reenable

func (AccountStatusWithRefTime) ScheduleAnonymizationByAdmin

func (s AccountStatusWithRefTime) ScheduleAnonymizationByAdmin(anonymizeAt time.Time) (*AccountStatusWithRefTime, error)

func (AccountStatusWithRefTime) ScheduleDeletionByAdmin

func (s AccountStatusWithRefTime) ScheduleDeletionByAdmin(deleteAt time.Time, reason string) (*AccountStatusWithRefTime, error)

func (AccountStatusWithRefTime) ScheduleDeletionByEndUser

func (s AccountStatusWithRefTime) ScheduleDeletionByEndUser(deleteAt time.Time, reason string) (*AccountStatusWithRefTime, error)

func (AccountStatusWithRefTime) SetAccountValidFrom

func (s AccountStatusWithRefTime) SetAccountValidFrom(t *time.Time) (*AccountStatusWithRefTime, error)

func (AccountStatusWithRefTime) SetAccountValidPeriod

func (s AccountStatusWithRefTime) SetAccountValidPeriod(from *time.Time, until *time.Time) (*AccountStatusWithRefTime, error)

func (AccountStatusWithRefTime) SetAccountValidUntil

func (s AccountStatusWithRefTime) SetAccountValidUntil(t *time.Time) (*AccountStatusWithRefTime, error)

func (AccountStatusWithRefTime) TemporarilyDisabledFrom

func (s AccountStatusWithRefTime) TemporarilyDisabledFrom() *time.Time

func (AccountStatusWithRefTime) TemporarilyDisabledUntil

func (s AccountStatusWithRefTime) TemporarilyDisabledUntil() *time.Time

func (AccountStatusWithRefTime) UnscheduleAnonymizationByAdmin

func (s AccountStatusWithRefTime) UnscheduleAnonymizationByAdmin() (*AccountStatusWithRefTime, error)

func (AccountStatusWithRefTime) UnscheduleDeletionByAdmin

func (s AccountStatusWithRefTime) UnscheduleDeletionByAdmin() (*AccountStatusWithRefTime, error)

type AuthenticatorService

type AuthenticatorService interface {
	ListByUserIDs(ctx context.Context, userIDs []string, filters ...authenticator.Filter) (map[string][]*authenticator.Info, error)
}

type Commands

type Commands struct {
	*RawCommands
	RawQueries         *RawQueries
	Events             EventService
	Verification       VerificationService
	UserProfileConfig  *config.UserProfileConfig
	StandardAttributes StandardAttributesService
	CustomAttributes   CustomAttributesService
	RolesAndGroups     RolesAndGroupsService
}

func (*Commands) AfterCreate

func (c *Commands) AfterCreate(
	ctx context.Context,
	user *User,
	identities []*identity.Info,
	authenticators []*authenticator.Info,
	isAdminAPI bool,
) error

type CustomAttributesService

type CustomAttributesService interface {
	ReadCustomAttributesInStorageForm(ctx context.Context, role accesscontrol.Role, userID string, storageForm map[string]interface{}) (map[string]interface{}, error)
	ReadCustomAttributesInStorageFormForUsers(
		ctx context.Context,
		role accesscontrol.Role,
		userIDs []string,
		storageForms []map[string]interface{},
	) (map[string]map[string]interface{}, error)
}

type EventService

type EventService interface {
	DispatchEventOnCommit(ctx context.Context, payload event.Payload) error
}

type FilterOptions

type FilterOptions struct {
	GroupKeys []string
	RoleKeys  []string
}

func (FilterOptions) IsFilterEnabled

func (o FilterOptions) IsFilterEnabled() bool

type IdentityService

type IdentityService interface {
	ListByUserIDs(ctx context.Context, userIDs []string) (map[string][]*identity.Info, error)
}

type ListOptions

type ListOptions struct {
	SortOption SortOption
}

type Provider

type Provider struct {
	*Commands
	*Queries
}

type Queries

type Queries struct {
	*RawQueries
	Store              store
	Identities         IdentityService
	Authenticators     AuthenticatorService
	Verification       VerificationService
	StandardAttributes StandardAttributesService
	CustomAttributes   CustomAttributesService
	RolesAndGroups     RolesAndGroupsService
	Clock              clock.Clock
}

func (*Queries) CountAll

func (p *Queries) CountAll(ctx context.Context) (count uint64, err error)

func (*Queries) Get

func (p *Queries) Get(ctx context.Context, id string, role accesscontrol.Role) (*model.User, error)

func (*Queries) GetMany

func (p *Queries) GetMany(ctx context.Context, ids []string, role accesscontrol.Role) (users []*model.User, err error)

func (*Queries) GetPageForExport

func (p *Queries) GetPageForExport(ctx context.Context, offset uint64, limit uint64) (users []*UserForExport, err error)

type RawCommands

type RawCommands struct {
	Store store
	Clock clock.Clock
}

func (*RawCommands) AfterCreate

func (c *RawCommands) AfterCreate(userModel *model.User, identities []*identity.Info) error

func (*RawCommands) Anonymize

func (c *RawCommands) Anonymize(ctx context.Context, userID string) error

func (*RawCommands) Create

func (c *RawCommands) Create(ctx context.Context, userID string) (*User, error)

func (*RawCommands) Delete

func (c *RawCommands) Delete(ctx context.Context, userID string) error

func (*RawCommands) New

func (c *RawCommands) New(userID string) *User

func (*RawCommands) UpdateAccountStatus

func (c *RawCommands) UpdateAccountStatus(ctx context.Context, userID string, accountStatus AccountStatusWithRefTime) error

func (*RawCommands) UpdateLoginTime

func (c *RawCommands) UpdateLoginTime(ctx context.Context, userID string, loginAt time.Time) error

func (*RawCommands) UpdateMFAEnrollment

func (c *RawCommands) UpdateMFAEnrollment(ctx context.Context, userID string, endAt *time.Time) error

func (*RawCommands) UpdateOptOutPasskeyUpselling

func (c *RawCommands) UpdateOptOutPasskeyUpselling(ctx context.Context, userID string, optout bool) error

type RawQueries

type RawQueries struct {
	Store store
}

func (*RawQueries) Count

func (p *RawQueries) Count(ctx context.Context) (uint64, error)

func (*RawQueries) GetManyRaw

func (p *RawQueries) GetManyRaw(ctx context.Context, ids []string) ([]*User, error)

func (*RawQueries) GetRaw

func (p *RawQueries) GetRaw(ctx context.Context, id string) (*User, error)

func (*RawQueries) QueryPage

func (p *RawQueries) QueryPage(ctx context.Context, listOption ListOptions, pageArgs graphqlutil.PageArgs) ([]model.PageItemRef, error)

type RolesAndGroupsService

type RolesAndGroupsService interface {
	ListRolesByUserID(ctx context.Context, userID string) ([]*model.Role, error)
	ListGroupsByUserID(ctx context.Context, userID string) ([]*model.Group, error)
	ListRolesByUserIDs(ctx context.Context, userIDs []string) (map[string][]*model.Role, error)
	ListGroupsByUserIDs(ctx context.Context, userIDs []string) (map[string][]*model.Group, error)
}

type SortBy

type SortBy string
const (
	SortByDefault     SortBy = ""
	SortByCreatedAt   SortBy = "created_at"
	SortByLastLoginAt SortBy = "last_login_at"
)

type SortOption

type SortOption struct {
	SortBy        SortBy
	SortDirection model.SortDirection
}

func (SortOption) Apply

func (o SortOption) Apply(builder db.SelectBuilder, after string) db.SelectBuilder

func (SortOption) GetSortBy

func (o SortOption) GetSortBy() SortBy

func (SortOption) GetSortDirection

func (o SortOption) GetSortDirection() model.SortDirection

type StandardAttributesService

type StandardAttributesService interface {
	DeriveStandardAttributes(ctx context.Context, role accesscontrol.Role, userID string, updatedAt time.Time, attrs map[string]interface{}) (map[string]interface{}, error)
	DeriveStandardAttributesForUsers(
		ctx context.Context,
		role accesscontrol.Role,
		userIDs []string,
		updatedAts []time.Time,
		attrsList []map[string]interface{},
	) (map[string]map[string]interface{}, error)
}

type Store

type Store struct {
	SQLBuilder  *appdb.SQLBuilderApp
	SQLExecutor *appdb.SQLExecutor
	Clock       clock.Clock
	AppID       config.AppID
}

func (*Store) Count

func (s *Store) Count(ctx context.Context) (uint64, error)

func (*Store) Create

func (s *Store) Create(ctx context.Context, u *User) (err error)

func (*Store) Delete

func (s *Store) Delete(ctx context.Context, userID string) error

func (*Store) Get

func (s *Store) Get(ctx context.Context, userID string) (*User, error)

func (*Store) GetByIDs

func (s *Store) GetByIDs(ctx context.Context, userIDs []string) ([]*User, error)

func (*Store) MarkAsReindexRequired

func (s *Store) MarkAsReindexRequired(ctx context.Context, userIDs []string) error

func (*Store) QueryForExport

func (s *Store) QueryForExport(ctx context.Context, offset uint64, limit uint64) ([]*User, error)

func (*Store) QueryPage

func (s *Store) QueryPage(ctx context.Context, listOption ListOptions, pageArgs graphqlutil.PageArgs) ([]*User, uint64, error)

func (*Store) SetAllAttributesToNull

func (s *Store) SetAllAttributesToNull(ctx context.Context, userID string) error

func (*Store) UpdateAccountStatus

func (s *Store) UpdateAccountStatus(ctx context.Context, userID string, accountStatus AccountStatusWithRefTime) error

func (*Store) UpdateCustomAttributes

func (s *Store) UpdateCustomAttributes(ctx context.Context, userID string, customAttrs map[string]interface{}) error

func (*Store) UpdateLastIndexedAt

func (s *Store) UpdateLastIndexedAt(ctx context.Context, userIDs []string, at time.Time) error

func (*Store) UpdateLoginTime

func (s *Store) UpdateLoginTime(ctx context.Context, userID string, loginAt time.Time) error

func (*Store) UpdateMFAEnrollment

func (s *Store) UpdateMFAEnrollment(ctx context.Context, userID string, endAt *time.Time) error

func (*Store) UpdateOptOutPasskeyUpselling

func (s *Store) UpdateOptOutPasskeyUpselling(ctx context.Context, userID string, optout bool) error

func (*Store) UpdateStandardAttributes

func (s *Store) UpdateStandardAttributes(ctx context.Context, userID string, stdAttrs map[string]interface{}) error

type User

type User struct {
	ID                   string
	CreatedAt            time.Time
	UpdatedAt            time.Time
	MostRecentLoginAt    *time.Time
	LessRecentLoginAt    *time.Time
	StandardAttributes   map[string]interface{}
	CustomAttributes     map[string]interface{}
	LastIndexedAt        *time.Time
	RequireReindexAfter  *time.Time
	MFAGracePeriodtEndAt *time.Time
	OptOutPasskeyUpsell  bool
	// contains filtered or unexported fields
}

func (*User) AccountStatus

func (u *User) AccountStatus(refTime time.Time) AccountStatusWithRefTime

func (*User) GetMeta

func (u *User) GetMeta() model.Meta

func (*User) ToRef

func (u *User) ToRef() *model.UserRef

type UserForExport

type UserForExport struct {
	model.User

	Identities     []*identity.Info
	Authenticators []*authenticator.Info
}

type VerificationService

type VerificationService interface {
	IsUserVerified(ctx context.Context, identities []*identity.Info) (bool, error)
	AreUsersVerified(ctx context.Context, identitiesByUserIDs map[string][]*identity.Info) (map[string]bool, error)
}

Jump to

Keyboard shortcuts

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