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 AllowNetworkParams

type AllowNetworkParams struct {
	Network   string
	UpdatedAt time.Time
	OrgID     int64
}

type CapOIDCSessionsParams

type CapOIDCSessionsParams struct {
	ExpiresAt time.Time
	OrgID     int64
	UserID    int64
}

type ContinueAsOIDCSessionParams

type ContinueAsOIDCSessionParams struct {
	IdpMfa    bool
	ExpiresAt time.Time
	OrgID     int64
	ID        int64
}

type CreateIdentityUserParams

type CreateIdentityUserParams struct {
	OrgID     int64
	PublicID  string
	Login     string
	Name      string
	Email     pgtype.Text
	Role      string
	Issuer    pgtype.Text
	Subject   pgtype.Text
	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 DeleteCheckParams

type DeleteCheckParams struct {
	OrgID  int64
	UserID int64
}

type DropCheckParams

type DropCheckParams struct {
	OrgID  int64
	UserID int64
	Owner  pgtype.Text
	Now    time.Time
}

type DueChecksParams

type DueChecksParams struct {
	OrgID     int64
	Due       time.Time
	Now       time.Time
	BatchSize int32
}

type EndOtherUserSessionsParams

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

type EndUserSessionsParams

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

type FinishCheckParams

type FinishCheckParams struct {
	Deadline  time.Time
	Outcome   pgtype.Text
	UpdatedAt time.Time
	OrgID     int64
	UserID    int64
	Owner     pgtype.Text
	Now       time.Time
}

type GetCheckUserParams

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

type GetCheckUserRow

type GetCheckUserRow struct {
	ID                         int64
	PublicID                   string
	Name                       string
	Role                       string
	Status                     string
	OidcSubject                pgtype.Text
	OidcOfflineTokenCiphertext []byte
	OidcOfflineTokenKeyID      pgtype.Text
	OidcOfflineTokenUpdatedAt  pgtype.Timestamptz
	LiveSession                bool
	UsableToken                bool
}

type GetIdentityUserParams

type GetIdentityUserParams struct {
	OrgID   int64
	Issuer  pgtype.Text
	Subject pgtype.Text
}

type GetIdentityUserRow

type GetIdentityUserRow struct {
	ID           int64
	PublicID     string
	Login        string
	Name         string
	Role         string
	Status       string
	TotpEnrolled bool
	TotpRequired string
}

type InsertAuthRequestParams

type InsertAuthRequestParams struct {
	StateHash              []byte
	OrgID                  int64
	Purpose                string
	LinkUserID             pgtype.Int8
	LinkSessionID          pgtype.Int8
	Nonce                  string
	CodeVerifierCiphertext []byte
	CodeVerifierKeyID      string
	ReturnTo               pgtype.Text
	CreatedAt              time.Time
	ExpiresAt              time.Time
	MaxPending             int64
}

type InsertDemoSettingsParams

type InsertDemoSettingsParams struct {
	OrgID                  int64
	DisplayName            pgtype.Text
	IssuerUrl              string
	ClientID               string
	ClientSecretCiphertext []byte
	ClientSecretKeyID      pgtype.Text
	UpdatedAt              pgtype.Timestamptz
	Scopes                 []string
	GroupsClaim            string
	GroupMappings          []byte
}

type InsertSettingsParams

type InsertSettingsParams struct {
	OrgID                   int64
	Enabled                 bool
	DisplayName             pgtype.Text
	IssuerUrl               string
	ClientID                string
	ClientSecretCiphertext  []byte
	ClientSecretKeyID       pgtype.Text
	ClientSecretUpdatedAt   pgtype.Timestamptz
	ClientSecretExpiresOn   pgtype.Date
	Scopes                  []string
	GroupsClaim             string
	GroupMappings           []byte
	UnmatchedRole           string
	SyncRole                bool
	SkipTotpWithIdpMfa      bool
	Proxy                   []byte
	ProxyPasswordCiphertext []byte
	ProxyPasswordKeyID      pgtype.Text
	ProxyPasswordUpdatedAt  pgtype.Timestamptz
	UpdatedAt               time.Time
}

type LatestKeptAdminRow

type LatestKeptAdminRow struct {
	At                time.Time
	MappedRole        string
	PublicID          string
	Name              string
	Login             string
	Role              string
	Status            string
	OidcLastContactAt pgtype.Timestamptz
	ActiveAdmins      int64
}

type LeaseChecksParams

type LeaseChecksParams struct {
	Owner      pgtype.Text
	LeaseUntil time.Time
	OrgID      int64
	UserIds    []int64
}

type LinkIdentityParams

type LinkIdentityParams struct {
	Issuer  pgtype.Text
	Subject pgtype.Text
	Now     time.Time
	OrgID   int64
	ID      int64
}

type LockCheckUserParams

type LockCheckUserParams struct {
	OrgID int64
	ID    int64
}

type LockCheckUserRow

type LockCheckUserRow struct {
	Role                      string
	Status                    string
	OidcOfflineTokenUpdatedAt pgtype.Timestamptz
}

type LockLinkUserParams

type LockLinkUserParams struct {
	OrgID int64
	ID    int64
}

type LockLinkUserRow

type LockLinkUserRow struct {
	ID          int64
	PublicID    string
	Name        string
	Status      string
	HasPassword bool
	HasIdentity bool
}

type LockUserParams

type LockUserParams struct {
	OrgID int64
	ID    int64
}

type LockUserRow

type LockUserRow struct {
	Role   string
	Status string
}

type LoginTakenParams

type LoginTakenParams struct {
	OrgID int64
	Login string
}

type OidcSetting

type OidcSetting struct {
	OrgID                   int64
	Enabled                 bool
	DisplayName             pgtype.Text
	IssuerUrl               string
	ClientID                string
	ClientSecretCiphertext  []byte
	ClientSecretKeyID       pgtype.Text
	ClientSecretUpdatedAt   pgtype.Timestamptz
	ClientSecretExpiresOn   pgtype.Date
	Scopes                  []string
	GroupsClaim             string
	GroupMappings           []byte
	UnmatchedRole           string
	SyncRole                bool
	SkipTotpWithIdpMfa      bool
	Proxy                   []byte
	ProxyPasswordCiphertext []byte
	ProxyPasswordKeyID      pgtype.Text
	ProxyPasswordUpdatedAt  pgtype.Timestamptz
	GroupsClaimMissingSince pgtype.Timestamptz
	Version                 int64
	UpdatedAt               time.Time
	GroupsClaimSeenAt       pgtype.Timestamptz
}

type PruneAuthRequestsParams

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

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) AllowNetwork

func (q *Queries) AllowNetwork(ctx context.Context, arg AllowNetworkParams) (int64, error)

AllowNetwork adds a network to the Organization's allowed outbound networks when it is not listed; `muster dev` allows loopback this way so that Muster may call the fake servers.

func (*Queries) CapOIDCSessions

func (q *Queries) CapOIDCSessions(ctx context.Context, arg CapOIDCSessionsParams) (int64, error)

CapOIDCSessions bounds the open OIDC sessions of a user who no longer holds an offline token to @expires_at, since no background re-check can end them any more.

func (*Queries) ContinueAsOIDCSession

func (q *Queries) ContinueAsOIDCSession(ctx context.Context, arg ContinueAsOIDCSessionParams) (int64, error)

ContinueAsOIDCSession turns the web session that linked an identity into an OIDC session; without an offline token it ends at @expires_at at the latest.

func (*Queries) CreateIdentityUser

func (q *Queries) CreateIdentityUser(ctx context.Context, arg CreateIdentityUserParams) (int64, error)

CreateIdentityUser creates the account of an OIDC identity at its first sign-in.

func (*Queries) DeleteCheck

func (q *Queries) DeleteCheck(ctx context.Context, arg DeleteCheckParams) error

DeleteCheck removes the re-check of a user who holds no offline token any more.

func (*Queries) DropCheck

func (q *Queries) DropCheck(ctx context.Context, arg DropCheckParams) (int64, error)

DropCheck removes a re-check that still holds its lease, when the identity provider refused the user; no row means the lease was lost.

func (*Queries) DueChecks

func (q *Queries) DueChecks(ctx context.Context, arg DueChecksParams) ([]int64, error)

DueChecks locks up to batch_size re-checks that are due on the business clock and not leased on the real clock, skipping those another replica holds.

func (*Queries) EndOtherUserSessions

func (q *Queries) EndOtherUserSessions(ctx context.Context, arg EndOtherUserSessionsParams) (int64, error)

EndOtherUserSessions ends every session of a user but the one that made the change, with the reason.

func (*Queries) EndUserSessions

func (q *Queries) EndUserSessions(ctx context.Context, arg EndUserSessionsParams) (int64, error)

EndUserSessions ends every session of a user that has not ended, with the reason.

func (*Queries) FinishCheck

func (q *Queries) FinishCheck(ctx context.Context, arg FinishCheckParams) (int64, error)

FinishCheck records the outcome of a re-check that still holds its lease, makes it due again at @deadline and releases the lease; no row means the lease was lost and the outcome must not be recorded.

func (*Queries) GetCheckUser

func (q *Queries) GetCheckUser(ctx context.Context, arg GetCheckUserParams) (GetCheckUserRow, error)

GetCheckUser reads the user of a claimed re-check: the offline token and when it was stored, and whether the user has a live session or a Personal access token that has not expired, at @now on the business clock.

func (*Queries) GetIdentityUser

func (q *Queries) GetIdentityUser(ctx context.Context, arg GetIdentityUserParams) (GetIdentityUserRow, error)

GetIdentityUser finds the account that holds an OIDC identity, with whether it has TOTP and the Organization's TOTP policy.

func (*Queries) GetSettings

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

SPDX-License-Identifier: AGPL-3.0-only Copyright The Muster Authors GetSettings reads the OIDC settings of the Organization, with the state of their Secrets.

func (*Queries) InsertAuthRequest

func (q *Queries) InsertAuthRequest(ctx context.Context, arg InsertAuthRequestParams) (int64, error)

InsertAuthRequest stores an OIDC redirect in flight, keyed by the hash of its state, unless the Organization already has max_pending requests that have not expired: starts need no credentials, so their rows are bounded.

func (*Queries) InsertDemoSettings

func (q *Queries) InsertDemoSettings(ctx context.Context, arg InsertDemoSettingsParams) (int64, error)

InsertDemoSettings stores the demo OIDC configuration of `muster dev` when the Organization has none.

func (*Queries) InsertSettings

func (q *Queries) InsertSettings(ctx context.Context, arg InsertSettingsParams) (int64, error)

InsertSettings stores the first OIDC settings of the Organization; it changes nothing when they exist, so that two first saves at once leave one row and the second answers a version mismatch.

func (*Queries) LatestKeptAdmin

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

LatestKeptAdmin reads the latest entry in which Role sync kept the last active Admin, with the user it names, that user's last OIDC contact and how many active Admins there are now.

func (*Queries) LeaseChecks

func (q *Queries) LeaseChecks(ctx context.Context, arg LeaseChecksParams) error

LeaseChecks leases the re-checks DueChecks locked to this replica until @lease_until on the real clock.

func (*Queries) LinkIdentity

func (q *Queries) LinkIdentity(ctx context.Context, arg LinkIdentityParams) (int64, error)

LinkIdentity adds the OIDC identity to an active account with a password and wipes the password in the same update, so that the account never holds both (users_one_credential_check).

func (*Queries) LockActiveAdmins

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

LockActiveAdmins locks the rows of the active Admins, as the last_admin check of user administration does, before the row of the user whose Role sync may lower an Admin.

func (*Queries) LockCheckUser

func (q *Queries) LockCheckUser(ctx context.Context, arg LockCheckUserParams) (LockCheckUserRow, error)

LockCheckUser locks the user whose re-check ends and reads the offline token it holds now.

func (*Queries) LockLinkUser

func (q *Queries) LockLinkUser(ctx context.Context, arg LockLinkUserParams) (LockLinkUserRow, error)

LockLinkUser locks the account a link adds the identity to and reads whether it can take one: active, with a password and without an identity.

func (*Queries) LockSettings

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

LockSettings locks the settings row until the transaction ends and returns its version.

func (*Queries) LockUser

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

LockUser locks the user whose Role sync runs and reads the Role and status it has now.

func (*Queries) LoginTaken

func (q *Queries) LoginTaken(ctx context.Context, arg LoginTakenParams) (bool, error)

LoginTaken reports whether an account has the login, compared lowercased.

func (*Queries) PruneAuthRequests

func (q *Queries) PruneAuthRequests(ctx context.Context, arg PruneAuthRequestsParams) (int64, error)

PruneAuthRequests deletes up to batch_size requests that expired before @before. A request being taken is skipped and goes at the next run.

func (*Queries) RecordContact

func (q *Queries) RecordContact(ctx context.Context, arg RecordContactParams) error

RecordContact records a successful contact with the identity provider and lifts an earlier refusal.

func (*Queries) RecordGroupsClaimAdvertised added in v0.1.1

func (q *Queries) RecordGroupsClaimAdvertised(ctx context.Context, arg RecordGroupsClaimAdvertisedParams) (int64, error)

RecordGroupsClaimAdvertised records what a check found in discovery while no sign-in has seen the groups claim: an unlisted claim raises the warning, a listed one clears it. Once a sign-in has seen the claim the warning stays clear, since discovery's list of claims is optional and identity providers leave the claims of their mappers out of it; a warning that an older replica raised next to a claim seen is cleared. It changes nothing when an Admin saved another groups claim, issuer, client ID or scopes since the check read them, and writes no row when the warning already is what the check found.

func (*Queries) RecordGroupsClaimSeen added in v0.1.1

func (q *Queries) RecordGroupsClaimSeen(ctx context.Context, arg RecordGroupsClaimSeenParams) (int64, error)

RecordGroupsClaimSeen records that a sign-in or a link found the groups claim in an ID token or in userinfo: the first time is kept, and the warning is cleared for good, until an Admin saves another groups claim, issuer, client ID or scopes. A sign-in without the claim records nothing: identity providers leave it out for a user in no group. It changes nothing when an Admin saved other values of those four since the sign-in read them, and writes no row when the claim is already seen and the warning clear. The warning is not a configured value, so the version stays.

func (*Queries) RefuseUser

func (q *Queries) RefuseUser(ctx context.Context, arg RefuseUserParams) error

RefuseUser records that the identity provider refused the user at a re-check and wipes the offline token.

func (*Queries) RenameDemoSettings

func (q *Queries) RenameDemoSettings(ctx context.Context, arg RenameDemoSettingsParams) (int64, error)

RenameDemoSettings gives the settings that still carry the demo configuration's earlier display name its current one; `muster dev` runs it at start, and any other settings stay as they are.

func (*Queries) ScheduleCheck

func (q *Queries) ScheduleCheck(ctx context.Context, arg ScheduleCheckParams) error

ScheduleCheck makes the re-check of a user who holds an offline token due at @deadline; a re-check in flight for the token it replaced loses its lease, so that its outcome is not recorded.

func (*Queries) SetRole

func (q *Queries) SetRole(ctx context.Context, arg SetRoleParams) (int64, error)

SetRole gives a user the Role the identity provider maps them to.

func (*Queries) StoreOfflineToken

func (q *Queries) StoreOfflineToken(ctx context.Context, arg StoreOfflineTokenParams) error

StoreOfflineToken keeps the offline token the identity provider granted, encrypted, in place of the previous one.

func (*Queries) TakeAuthRequest

func (q *Queries) TakeAuthRequest(ctx context.Context, arg TakeAuthRequestParams) (TakeAuthRequestRow, error)

TakeAuthRequest removes and returns the request of a state, so that a callback uses it once.

func (*Queries) TakeLinkRequest

func (q *Queries) TakeLinkRequest(ctx context.Context, arg TakeLinkRequestParams) (TakeLinkRequestRow, error)

TakeLinkRequest removes and returns the link request of a state only for the web session that started it, so that a callback in another session neither uses nor spends it.

func (*Queries) UpdateSettings

func (q *Queries) UpdateSettings(ctx context.Context, arg UpdateSettingsParams) (int64, error)

UpdateSettings replaces the settings at the version that was read.

func (*Queries) WipeOfflineToken

func (q *Queries) WipeOfflineToken(ctx context.Context, arg WipeOfflineTokenParams) error

WipeOfflineToken removes the offline token of a user whose sign-in granted none.

func (*Queries) WithTx

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

type RecordContactParams

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

type RecordGroupsClaimAdvertisedParams added in v0.1.1

type RecordGroupsClaimAdvertisedParams struct {
	Advertised  bool
	At          time.Time
	OrgID       int64
	GroupsClaim string
	IssuerUrl   string
	ClientID    string
	Scopes      []string
}

type RecordGroupsClaimSeenParams added in v0.1.1

type RecordGroupsClaimSeenParams struct {
	At          time.Time
	OrgID       int64
	GroupsClaim string
	IssuerUrl   string
	ClientID    string
	Scopes      []string
}

type RefuseUserParams

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

type RenameDemoSettingsParams

type RenameDemoSettingsParams struct {
	DisplayName pgtype.Text
	UpdatedAt   time.Time
	OrgID       int64
	Was         pgtype.Text
}

type ScheduleCheckParams

type ScheduleCheckParams struct {
	UserID   int64
	OrgID    int64
	Deadline time.Time
	Now      time.Time
}

type SetRoleParams

type SetRoleParams struct {
	Role  string
	Now   time.Time
	OrgID int64
	ID    int64
}

type StoreOfflineTokenParams

type StoreOfflineTokenParams struct {
	Ciphertext []byte
	KeyID      pgtype.Text
	Now        time.Time
	OrgID      int64
	ID         int64
}

type TakeAuthRequestParams

type TakeAuthRequestParams struct {
	OrgID     int64
	StateHash []byte
}

type TakeAuthRequestRow

type TakeAuthRequestRow struct {
	Purpose                string
	LinkUserID             pgtype.Int8
	LinkSessionID          pgtype.Int8
	Nonce                  string
	CodeVerifierCiphertext []byte
	CodeVerifierKeyID      string
	ReturnTo               pgtype.Text
	ExpiresAt              time.Time
}

type TakeLinkRequestParams

type TakeLinkRequestParams struct {
	OrgID     int64
	StateHash []byte
	SessionID pgtype.Int8
	UserID    pgtype.Int8
}

type TakeLinkRequestRow

type TakeLinkRequestRow struct {
	Nonce                  string
	CodeVerifierCiphertext []byte
	CodeVerifierKeyID      string
	ExpiresAt              time.Time
}

type UpdateSettingsParams

type UpdateSettingsParams struct {
	Enabled                 bool
	DisplayName             pgtype.Text
	IssuerUrl               string
	ClientID                string
	ClientSecretCiphertext  []byte
	ClientSecretKeyID       pgtype.Text
	ClientSecretUpdatedAt   pgtype.Timestamptz
	ClientSecretExpiresOn   pgtype.Date
	Scopes                  []string
	GroupsClaim             string
	GroupMappings           []byte
	UnmatchedRole           string
	SyncRole                bool
	SkipTotpWithIdpMfa      bool
	Proxy                   []byte
	ProxyPasswordCiphertext []byte
	ProxyPasswordKeyID      pgtype.Text
	ProxyPasswordUpdatedAt  pgtype.Timestamptz
	UpdatedAt               time.Time
	OrgID                   int64
	Version                 int64
}

type WipeOfflineTokenParams

type WipeOfflineTokenParams struct {
	OrgID int64
	ID    int64
}

Jump to

Keyboard shortcuts

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