dbgen

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConvertToLocalParams

type ConvertToLocalParams struct {
	Now   time.Time
	OrgID int64
	ID    int64
}

type CreateUserParams

type CreateUserParams struct {
	OrgID             int64
	PublicID          string
	Login             string
	Name              string
	Email             pgtype.Text
	Role              string
	Source            string
	PasswordHash      pgtype.Text
	PasswordChangedAt pgtype.Timestamptz
	CreatedAt         time.Time
}

type DBTX

type DBTX interface {
	Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
	Query(context.Context, string, ...interface{}) (pgx.Rows, error)
	QueryRow(context.Context, string, ...interface{}) pgx.Row
}

type DeleteOIDCCheckParams

type DeleteOIDCCheckParams struct {
	OrgID  int64
	UserID int64
}

type EndSessionsOfUserParams

type EndSessionsOfUserParams struct {
	Now       time.Time
	EndReason pgtype.Text
	OrgID     int64
	UserID    int64
}

type GetPasswordSetupParams

type GetPasswordSetupParams struct {
	OrgID     int64
	TokenHash []byte
}

type GetPasswordSetupRow

type GetPasswordSetupRow struct {
	ID           int64
	UserID       int64
	ExpiresAt    time.Time
	UsedAt       pgtype.Timestamptz
	SupersededAt pgtype.Timestamptz
	UserPublicID string
	UserName     string
}

type GetUserByLoginParams

type GetUserByLoginParams struct {
	OrgID int64
	Login string
}

type GetUserByLoginRow

type GetUserByLoginRow struct {
	ID              int64
	PublicID        string
	Name            string
	Status          string
	HasOidcIdentity bool
}

type GetUserByPublicIDParams

type GetUserByPublicIDParams struct {
	OrgID    int64
	PublicID string
}

type GetUserByPublicIDRow

type GetUserByPublicIDRow struct {
	ID              int64
	PublicID        string
	Login           string
	Name            string
	Email           pgtype.Text
	Role            string
	Source          string
	Status          string
	HasPassword     bool
	HasOidcIdentity bool
	HasOfflineToken bool
	TimeZone        pgtype.Text
	Language        pgtype.Text
	LastSignInAt    pgtype.Timestamptz
	CreatedAt       time.Time
	Version         int64
	TotpEnabled     bool
	RoleLocked      bool
}

type GetUserParams

type GetUserParams struct {
	OrgID int64
	ID    int64
}

type GetUserRow

type GetUserRow struct {
	ID              int64
	PublicID        string
	Login           string
	Name            string
	Email           pgtype.Text
	Role            string
	Source          string
	Status          string
	HasPassword     bool
	HasOidcIdentity bool
	HasOfflineToken bool
	TimeZone        pgtype.Text
	Language        pgtype.Text
	LastSignInAt    pgtype.Timestamptz
	CreatedAt       time.Time
	Version         int64
	TotpEnabled     bool
	RoleLocked      bool
}

type InsertPasswordSetupParams

type InsertPasswordSetupParams struct {
	OrgID           int64
	UserID          int64
	TokenHash       []byte
	CreatedByUserID pgtype.Int8
	CreatedAt       time.Time
	ExpiresAt       time.Time
}

type ListUserDirectoryParams

type ListUserDirectoryParams struct {
	OrgID     int64
	Q         pgtype.Text
	AfterName pgtype.Text
	AfterID   pgtype.Int8
	PageSize  int32
}

type ListUserDirectoryRow

type ListUserDirectoryRow struct {
	ID       int64
	PublicID string
	Login    string
	Name     string
	Status   string
	SortName string
}

type ListUsersParams

type ListUsersParams struct {
	OrgID     int64
	Q         pgtype.Text
	Role      pgtype.Text
	Status    pgtype.Text
	Source    pgtype.Text
	AfterName pgtype.Text
	AfterID   pgtype.Int8
	PageSize  int32
}

type ListUsersRow

type ListUsersRow struct {
	ID              int64
	PublicID        string
	Login           string
	Name            string
	Email           pgtype.Text
	Role            string
	Source          string
	Status          string
	HasPassword     bool
	HasOidcIdentity bool
	HasOfflineToken bool
	TimeZone        pgtype.Text
	Language        pgtype.Text
	LastSignInAt    pgtype.Timestamptz
	CreatedAt       time.Time
	Version         int64
	TotpEnabled     bool
	RoleLocked      bool
	SortName        string
}

type LockUserParams

type LockUserParams struct {
	OrgID    int64
	PublicID string
}

type MarkPasswordSetupUsedParams

type MarkPasswordSetupUsedParams struct {
	Now   time.Time
	OrgID int64
	ID    int64
}

type PrunePasswordSetupsParams

type PrunePasswordSetupsParams struct {
	OrgID     int64
	Before    time.Time
	BatchSize int32
}

type PseudonymizeUserParams

type PseudonymizeUserParams struct {
	Pseudonym string
	Now       time.Time
	OrgID     int64
	ID        int64
}

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) ConvertToLocal

func (q *Queries) ConvertToLocal(ctx context.Context, arg ConvertToLocalParams) (int64, error)

ConvertToLocal removes the OIDC identity of an account that is not deleted, with its offline token, so that the account signs in with a password once one is set.

func (*Queries) CountAdmins

func (q *Queries) CountAdmins(ctx context.Context, orgID int64) (int64, error)

CountAdmins counts the Admins that are not deleted; a disabled Admin still counts.

func (*Queries) CreateUser

func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) (int64, error)

func (*Queries) DeleteOIDCCheck

func (q *Queries) DeleteOIDCCheck(ctx context.Context, arg DeleteOIDCCheckParams) error

DeleteOIDCCheck removes the background re-check of a user whose offline token was wiped: disabled, deleted or converted to local.

func (*Queries) EndSessionsOfUser

func (q *Queries) EndSessionsOfUser(ctx context.Context, arg EndSessionsOfUserParams) (int64, error)

EndSessionsOfUser ends every session of a user that has not ended, with the reason of the administrative action.

func (*Queries) GetPasswordSetup

func (q *Queries) GetPasswordSetup(ctx context.Context, arg GetPasswordSetupParams) (GetPasswordSetupRow, error)

GetPasswordSetup finds a link by the hash of its token and, inside a transaction, locks it, so that it is used once. The transaction locks the user first (LockUser), as every change of a user and its links does.

func (*Queries) GetUser

func (q *Queries) GetUser(ctx context.Context, arg GetUserParams) (GetUserRow, error)

SPDX-License-Identifier: AGPL-3.0-only Copyright The Muster Authors

func (*Queries) GetUserByLogin

func (q *Queries) GetUserByLogin(ctx context.Context, arg GetUserByLoginParams) (GetUserByLoginRow, error)

GetUserByLogin finds an account by its login, compared lowercased.

func (*Queries) GetUserByPublicID

func (q *Queries) GetUserByPublicID(ctx context.Context, arg GetUserByPublicIDParams) (GetUserByPublicIDRow, error)

GetUserByPublicID reads a user by the public_id of the API, deleted users included.

func (*Queries) InsertPasswordSetup

func (q *Queries) InsertPasswordSetup(ctx context.Context, arg InsertPasswordSetupParams) error

func (*Queries) ListUserDirectory

func (q *Queries) ListUserDirectory(ctx context.Context, arg ListUserDirectoryParams) ([]ListUserDirectoryRow, error)

ListUserDirectory is a page of the user directory (C-10.FR-13): every user, deleted ones included, with only what pickers and filters show, in the order of the lowercased name, then id, after the cursor (after_name, after_id) when one is given; q matches the name and the login case-insensitively, never the email.

func (*Queries) ListUsers

func (q *Queries) ListUsers(ctx context.Context, arg ListUsersParams) ([]ListUsersRow, error)

ListUsers is a page of users in the order of their lowercased name, then id, after the cursor (after_name, after_id) when one is given; q matches the name, the login and the email case-insensitively.

func (*Queries) LockActiveAdmins

func (q *Queries) LockActiveAdmins(ctx context.Context, orgID int64) ([]int64, error)

LockActiveAdmins locks the rows of the active Admins, so that a change that could remove the last of them is decided by one transaction at a time; a row that stopped matching while waiting is left out. Every change that locks them does so before it locks its own user, so that two changes never wait for each other.

func (*Queries) LockUser

func (q *Queries) LockUser(ctx context.Context, arg LockUserParams) (int64, error)

LockUser locks the user an administrative change is about, so that it reads the row it changes.

func (*Queries) MarkPasswordSetupUsed

func (q *Queries) MarkPasswordSetupUsed(ctx context.Context, arg MarkPasswordSetupUsedParams) (int64, error)

func (*Queries) PrunePasswordSetups

func (q *Queries) PrunePasswordSetups(ctx context.Context, arg PrunePasswordSetupsParams) (int64, error)

PrunePasswordSetups deletes up to batch_size links that expired before @before, used and superseded ones included. A link being used is skipped and taken at the next run.

func (*Queries) PseudonymizeUser

func (q *Queries) PseudonymizeUser(ctx context.Context, arg PseudonymizeUserParams) (int64, error)

PseudonymizeUser deletes a user: the row stays with the status deleted, name and login become the pseudonym, and the email, the password and the offline token are erased.

func (*Queries) ResetUserPassword

func (q *Queries) ResetUserPassword(ctx context.Context, arg ResetUserPasswordParams) (int64, error)

ResetUserPassword is the emergency reset of the CLI: it sets the password of any account that is not deleted and removes an OIDC identity and its offline token in the same update, so that the account never holds both.

func (*Queries) RevokeTokensOfUser

func (q *Queries) RevokeTokensOfUser(ctx context.Context, arg RevokeTokensOfUserParams) (int64, error)

RevokeTokensOfUser revokes the Personal access tokens of a deleted user with the reason owner_deleted (C-04.FR-1).

func (*Queries) RoleSyncOn

func (q *Queries) RoleSyncOn(ctx context.Context, orgID int64) (bool, error)

RoleSyncOn reports whether the identity provider decides the Role of OIDC accounts: OIDC and oidc.sync_role are both on.

func (*Queries) SetUserPassword

func (q *Queries) SetUserPassword(ctx context.Context, arg SetUserPasswordParams) (int64, error)

SetUserPassword sets the password of a local account that is not deleted.

func (*Queries) SetUserStatus

func (q *Queries) SetUserStatus(ctx context.Context, arg SetUserStatusParams) (int64, error)

SetUserStatus disables or enables a user that is not deleted; disabling wipes the offline token of an OIDC account.

func (*Queries) SupersedePasswordSetups

func (q *Queries) SupersedePasswordSetups(ctx context.Context, arg SupersedePasswordSetupsParams) (int64, error)

SupersedePasswordSetups marks the open links of a user as replaced, before a newer one is issued or the user is deleted.

func (*Queries) UpdateProfile

func (q *Queries) UpdateProfile(ctx context.Context, arg UpdateProfileParams) (int64, error)

UpdateProfile changes what the user edits in the profile: the display name, the time zone and the language.

func (*Queries) UpdateUser

func (q *Queries) UpdateUser(ctx context.Context, arg UpdateUserParams) (int64, error)

UpdateUser changes what an Admin edits: the name, the email and the Role, at the version that was read.

func (*Queries) WithTx

func (q *Queries) WithTx(tx pgx.Tx) *Queries

type ResetUserPasswordParams

type ResetUserPasswordParams struct {
	PasswordHash pgtype.Text
	Now          time.Time
	OrgID        int64
	ID           int64
}

type RevokeTokensOfUserParams

type RevokeTokensOfUserParams struct {
	Now    time.Time
	OrgID  int64
	UserID pgtype.Int8
}

type SetUserPasswordParams

type SetUserPasswordParams struct {
	PasswordHash pgtype.Text
	Now          time.Time
	OrgID        int64
	ID           int64
}

type SetUserStatusParams

type SetUserStatusParams struct {
	Status string
	Now    time.Time
	OrgID  int64
	ID     int64
}

type SupersedePasswordSetupsParams

type SupersedePasswordSetupsParams struct {
	Now    time.Time
	OrgID  int64
	UserID int64
}

type UpdateProfileParams

type UpdateProfileParams struct {
	Name      string
	TimeZone  pgtype.Text
	Language  pgtype.Text
	UpdatedAt time.Time
	OrgID     int64
	ID        int64
}

type UpdateUserParams

type UpdateUserParams struct {
	Name    string
	Email   pgtype.Text
	Role    string
	Now     time.Time
	OrgID   int64
	ID      int64
	Version int64
}

Jump to

Keyboard shortcuts

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