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: 6 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 BlockSignInParams

type BlockSignInParams struct {
	BlockedUntil pgtype.Timestamptz
	OrgID        int64
	SubjectKind  string
	Subject      string
}

type CompleteSecondFactorParams

type CompleteSecondFactorParams struct {
	OrgID int64
	ID    int64
}

type CreateSessionParams

type CreateSessionParams struct {
	OrgID         int64
	PublicID      string
	UserID        int64
	TokenHash     []byte
	State         string
	Method        string
	IdpMfa        bool
	Address       *netip.Addr
	UserAgent     pgtype.Text
	CreatedAt     time.Time
	IdleExpiresAt time.Time
	ExpiresAt     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 EndOtherUserSessionsParams

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

type EndSessionParams

type EndSessionParams struct {
	Now       time.Time
	EndReason pgtype.Text
	OrgID     int64
	ID        int64
}

type EndUserSessionsParams

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

type GetSessionByTokenParams

type GetSessionByTokenParams struct {
	OrgID     int64
	TokenHash []byte
}

type GetSessionByTokenRow

type GetSessionByTokenRow struct {
	ID            int64
	PublicID      string
	UserID        int64
	State         string
	Method        string
	Address       *netip.Addr
	UserAgent     pgtype.Text
	CreatedAt     time.Time
	LastUsedAt    time.Time
	IdleExpiresAt time.Time
	ExpiresAt     time.Time
	EndedAt       pgtype.Timestamptz
	EndReason     pgtype.Text
	UserPublicID  string
	UserName      string
	UserRole      string
	UserStatus    string
}

type GetSignInUserParams

type GetSignInUserParams struct {
	OrgID int64
	Login string
}

type GetSignInUserRow

type GetSignInUserRow struct {
	ID           int64
	PublicID     string
	Name         string
	Role         string
	Status       string
	PasswordHash pgtype.Text
	TotpEnrolled bool
	TotpRequired string
}

type GetThrottlesParams

type GetThrottlesParams struct {
	OrgID   int64
	Account string
	Address string
}

type GetThrottlesRow

type GetThrottlesRow struct {
	SubjectKind         string
	ConsecutiveFailures int64
	BlockedUntil        pgtype.Timestamptz
}

type GetUserPasswordParams

type GetUserPasswordParams struct {
	OrgID int64
	ID    int64
}

type GetUserPasswordRow

type GetUserPasswordRow struct {
	Login           string
	PasswordHash    pgtype.Text
	HasOidcIdentity bool
}

type ListUserSessionsParams

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

type ListUserSessionsRow

type ListUserSessionsRow struct {
	ID         int64
	PublicID   string
	Method     string
	Address    *netip.Addr
	UserAgent  pgtype.Text
	CreatedAt  time.Time
	LastUsedAt time.Time
}

type LiveSessionsParams

type LiveSessionsParams struct {
	OrgID int64
	Ids   []int64
	Now   time.Time
}

type MarkSignedInParams

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

type PruneSessionsParams

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

type PruneSignInThrottlesParams

type PruneSignInThrottlesParams 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) BlockSignIn

func (q *Queries) BlockSignIn(ctx context.Context, arg BlockSignInParams) error

func (*Queries) CompleteSecondFactor

func (q *Queries) CompleteSecondFactor(ctx context.Context, arg CompleteSecondFactorParams) (int64, error)

CompleteSecondFactor makes a session that waited for the TOTP code active.

func (*Queries) CreateSession

func (q *Queries) CreateSession(ctx context.Context, arg CreateSessionParams) (int64, error)

func (*Queries) EndOtherUserSessions

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

func (*Queries) EndSession

func (q *Queries) EndSession(ctx context.Context, arg EndSessionParams) (int64, error)

func (*Queries) EndUserSessions

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

func (*Queries) GetSessionByToken

func (q *Queries) GetSessionByToken(ctx context.Context, arg GetSessionByTokenParams) (GetSessionByTokenRow, error)

GetSessionByToken finds a session by the hash of its cookie value, with its user.

func (*Queries) GetSignInUser

func (q *Queries) GetSignInUser(ctx context.Context, arg GetSignInUserParams) (GetSignInUserRow, error)

GetSignInUser finds the account of a login, compared lowercased, with whether it has TOTP and the Organization's TOTP policy.

func (*Queries) GetThrottles

func (q *Queries) GetThrottles(ctx context.Context, arg GetThrottlesParams) ([]GetThrottlesRow, error)

func (*Queries) GetUserPassword

func (q *Queries) GetUserPassword(ctx context.Context, arg GetUserPasswordParams) (GetUserPasswordRow, error)

func (*Queries) ListRolePermissions

func (q *Queries) ListRolePermissions(ctx context.Context) ([]RolePermission, error)

SPDX-License-Identifier: AGPL-3.0-only Copyright The Muster Authors ListRolePermissions reads the allocation of Permissions to Roles, reference data without org_id.

func (*Queries) ListUserSessions

func (q *Queries) ListUserSessions(ctx context.Context, arg ListUserSessionsParams) ([]ListUserSessionsRow, error)

ListUserSessions lists the sessions of a user that have neither ended nor expired, the latest used first.

func (*Queries) LiveSessions

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

LiveSessions returns which of the sessions are still usable at @now: active, neither ended nor expired, of an active user. Reading them does not count as a use.

func (*Queries) MarkSignedIn

func (q *Queries) MarkSignedIn(ctx context.Context, arg MarkSignedInParams) error

func (*Queries) PruneSessions

func (q *Queries) PruneSessions(ctx context.Context, arg PruneSessionsParams) (int64, error)

PruneSessions deletes up to batch_size sessions that could no longer be used before @before: ended, past their idle timeout or past their lifetime. A session row being used is skipped and taken at the next run.

func (*Queries) PruneSignInThrottles

func (q *Queries) PruneSignInThrottles(ctx context.Context, arg PruneSignInThrottlesParams) (int64, error)

PruneSignInThrottles deletes up to batch_size throttle rows whose last failure, and whose block, are older than @before. A row being counted is skipped and taken at the next run.

func (*Queries) RecordSignInFailure

func (q *Queries) RecordSignInFailure(ctx context.Context, arg RecordSignInFailureParams) (int64, error)

RecordSignInFailure counts one more consecutive failure of a subject and returns the count.

func (*Queries) ResetSignInThrottles

func (q *Queries) ResetSignInThrottles(ctx context.Context, arg ResetSignInThrottlesParams) error

ResetSignInThrottles forgets the failures of an account and of a source address after a successful sign-in.

func (*Queries) SetPassword

func (q *Queries) SetPassword(ctx context.Context, arg SetPasswordParams) (int64, error)

SetPassword replaces the password of a local account.

func (*Queries) TouchSession

func (q *Queries) TouchSession(ctx context.Context, arg TouchSessionParams) error

TouchSession records the use of a session, at most once a minute, and moves its idle expiry.

func (*Queries) TryLockSignInSubject

func (q *Queries) TryLockSignInSubject(ctx context.Context, arg TryLockSignInSubjectParams) (bool, error)

TryLockSignInSubject takes the attempt lock of an account until the transaction ends, without waiting; false means that another attempt of the account is being evaluated. The two-key advisory locks do not overlap the one-key locks of the migrations and the Leader.

func (*Queries) WithTx

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

type RecordSignInFailureParams

type RecordSignInFailureParams struct {
	OrgID       int64
	SubjectKind string
	Subject     string
	Now         time.Time
}

type ResetSignInThrottlesParams

type ResetSignInThrottlesParams struct {
	OrgID   int64
	Account string
	Address string
}

type RolePermission

type RolePermission struct {
	Role       string
	Permission string
}

type SetPasswordParams

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

type TouchSessionParams

type TouchSessionParams struct {
	Now           time.Time
	IdleExpiresAt time.Time
	OrgID         int64
	ID            int64
}

type TryLockSignInSubjectParams

type TryLockSignInSubjectParams struct {
	LockClass int32
	Subject   string
}

Jump to

Keyboard shortcuts

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