user

package
v0.0.0-...-2bc625b Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: Apache-2.0 Imports: 22 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AnonymizedUser = apierrors.Forbidden.WithReason("AnonymizedUser")
View Source
var DeactivatedUser = apierrors.Forbidden.WithReason("DeactivatedUser")
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 ErrDeactivatedUser = DeactivatedUser.New("user is deactivated")
View Source
var ErrUserNotFound = errors.New("user not found")
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")

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 {
	IsDisabled    bool
	IsDeactivated bool
	DisableReason *string
	DeleteAt      *time.Time
	IsAnonymized  bool
	AnonymizeAt   *time.Time
}

AccountStatus represents disabled, deactivated, or scheduled deletion state. The zero value means normal.

func (AccountStatus) Anonymize

func (s AccountStatus) Anonymize() (*AccountStatus, error)

func (AccountStatus) Check

func (s AccountStatus) Check() error

func (AccountStatus) Disable

func (s AccountStatus) Disable(reason *string) (*AccountStatus, error)

func (AccountStatus) Reenable

func (s AccountStatus) Reenable() (*AccountStatus, error)

func (AccountStatus) ScheduleAnonymizationByAdmin

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

func (AccountStatus) ScheduleDeletionByAdmin

func (s AccountStatus) ScheduleDeletionByAdmin(deleteAt time.Time) (*AccountStatus, error)

func (AccountStatus) ScheduleDeletionByEndUser

func (s AccountStatus) ScheduleDeletionByEndUser(deleteAt time.Time) (*AccountStatus, error)

func (AccountStatus) Type

func (AccountStatus) UnscheduleAnonymizationByAdmin

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

func (AccountStatus) UnscheduleDeletionByAdmin

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

type AccountStatusType

type AccountStatusType string
const (
	AccountStatusTypeNormal                         AccountStatusType = "normal"
	AccountStatusTypeDisabled                       AccountStatusType = "disabled"
	AccountStatusTypeDeactivated                    AccountStatusType = "deactivated"
	AccountStatusTypeScheduledDeletionDisabled      AccountStatusType = "scheduled_deletion_disabled"
	AccountStatusTypeScheduledDeletionDeactivated   AccountStatusType = "scheduled_deletion_deactivated"
	AccountStatusTypeAnonymized                     AccountStatusType = "anonymized"
	AccountStatusTypeScheduledAnonymizationDisabled AccountStatusType = "scheduled_anonymization_disabled"
)

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
}

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 AccountStatus) 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

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) Anonymize

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

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) UpdateAccountStatus

func (s *Store) UpdateAccountStatus(ctx context.Context, userID string, accountStatus AccountStatus) 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) 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
	IsDisabled           bool
	DisableReason        *string
	IsDeactivated        bool
	DeleteAt             *time.Time
	IsAnonymized         bool
	AnonymizeAt          *time.Time
	StandardAttributes   map[string]interface{}
	CustomAttributes     map[string]interface{}
	LastIndexedAt        *time.Time
	RequireReindexAfter  *time.Time
	MFAGracePeriodtEndAt *time.Time
}

func (*User) AccountStatus

func (u *User) AccountStatus() AccountStatus

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