systemdb

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ApiToken

type ApiToken struct {
	ID         string
	UserID     string
	Name       string
	TokenHash  string
	RolesJson  string
	CreatedAt  string
	ExpiresAt  string
	LastUsedAt sql.NullString
}

type ApplyTOTPPendingParams

type ApplyTOTPPendingParams struct {
	TotpConfirmedAt sql.NullString
	TotpLastStep    int64
	UpdatedAt       string
	ID              string
}

type BumpCredentialsEpochParams

type BumpCredentialsEpochParams struct {
	UpdatedAt string
	ID        string
}

type CountOtherActiveTenantAdminsParams

type CountOtherActiveTenantAdminsParams struct {
	TenantID string
	UserID   string
}

type DBTX

type DBTX interface {
	ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
	PrepareContext(context.Context, string) (*sql.Stmt, error)
	QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
	QueryRowContext(context.Context, string, ...interface{}) *sql.Row
}

type DbInfo

type DbInfo struct {
	Key   string
	Value string
}

type DeleteExpiredSessionsParams

type DeleteExpiredSessionsParams struct {
	ExpiresAt  string
	LastSeenAt string
}

type DeleteOtherUserSessionsParams

type DeleteOtherUserSessionsParams struct {
	UserID string
	IDHash string
}

type DeletePasskeyParams

type DeletePasskeyParams struct {
	ID     string
	UserID string
}

type DeleteRoleBindingParams

type DeleteRoleBindingParams struct {
	UserID   string
	TenantID string
	Ca       string
}

type DeleteTokenParams

type DeleteTokenParams struct {
	ID     string
	UserID string
}

type EnsureTenantParams

type EnsureTenantParams struct {
	ID        string
	Name      string
	CreatedAt string
}

type GetInstanceRow

type GetInstanceRow struct {
	Demo          int64
	InitializedAt string
}

type GetTenantRow

type GetTenantRow struct {
	ID                string
	Name              string
	AllowServerKeygen int64
	CreatedAt         string
}

type GetTenantSettingsRow

type GetTenantSettingsRow struct {
	ID                string
	AllowServerKeygen int64
	SubjectO          string
	SubjectOu         string
	SubjectL          string
	SubjectSt         string
	SubjectC          string
	AcmeOrdersPerHour int64
	AcmeFailedPerName int64
	AcmeAccountsPerIp int64
}

type InsertInstanceParams

type InsertInstanceParams struct {
	Demo          int64
	InitializedAt string
}

type InsertPasskeyParams

type InsertPasskeyParams struct {
	ID           string
	UserID       string
	CredentialID []byte
	Credential   string
	Name         string
	SignCount    int64
	CreatedAt    string
}

type InsertRecoveryCodeParams

type InsertRecoveryCodeParams struct {
	UserID    string
	CodeHash  string
	CreatedAt string
}

type InsertSessionParams

type InsertSessionParams struct {
	IDHash     string
	UserID     string
	State      string
	CsrfToken  string
	CreatedAt  string
	LastSeenAt string
	ExpiresAt  string
	StepupAt   sql.NullString
}

type InsertTokenParams

type InsertTokenParams struct {
	ID        string
	UserID    string
	Name      string
	TokenHash string
	RolesJson string
	CreatedAt string
	ExpiresAt string
}

type InsertUnsealSlotParams

type InsertUnsealSlotParams struct {
	Slot           string
	RootKeyVersion int64
	Kdf            string
	KdfParams      string
	Salt           []byte
	WrappedRootKey []byte
	CreatedAt      string
	UpdatedAt      string
}

type InsertUserParams

type InsertUserParams struct {
	ID                string
	Username          string
	PasswordHash      string
	PasswordChangedAt string
	TotpSecret        []byte
	InstanceAdmin     int64
	CreatedAt         string
	UpdatedAt         string
}

type Instance

type Instance struct {
	ID            int64
	Demo          int64
	InitializedAt string
}

type ListTenantsRow

type ListTenantsRow struct {
	ID                string
	Name              string
	AllowServerKeygen int64
	CreatedAt         string
}

type Outbox

type Outbox struct {
	ID          int64
	CreatedAt   string
	Topic       string
	PayloadJson string
	DeliveredAt sql.NullString
}

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) ApplyTOTPPending

func (q *Queries) ApplyTOTPPending(ctx context.Context, arg ApplyTOTPPendingParams) (int64, error)

func (*Queries) BumpCredentialsEpoch

func (q *Queries) BumpCredentialsEpoch(ctx context.Context, arg BumpCredentialsEpochParams) error

myownpki user unlock: device cookies issued before are void.

func (*Queries) CountOtherActiveInstanceAdmins

func (q *Queries) CountOtherActiveInstanceAdmins(ctx context.Context, id string) (int64, error)

The last active instance admin and the last active tenant-wide admin of a tenant can't be disabled or lose that role: count the others.

func (*Queries) CountOtherActiveTenantAdmins

func (q *Queries) CountOtherActiveTenantAdmins(ctx context.Context, arg CountOtherActiveTenantAdminsParams) (int64, error)

func (*Queries) CountPasskeys

func (q *Queries) CountPasskeys(ctx context.Context, userID string) (int64, error)

func (*Queries) CountTokens

func (q *Queries) CountTokens(ctx context.Context, userID string) (int64, error)

func (*Queries) CountUnsealSlots

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

func (*Queries) CountUnusedRecoveryCodes

func (q *Queries) CountUnusedRecoveryCodes(ctx context.Context, userID string) (int64, error)

func (*Queries) CountUsers

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

func (*Queries) DeleteExpiredSessions

func (q *Queries) DeleteExpiredSessions(ctx context.Context, arg DeleteExpiredSessionsParams) (int64, error)

func (*Queries) DeleteOtherUserSessions

func (q *Queries) DeleteOtherUserSessions(ctx context.Context, arg DeleteOtherUserSessionsParams) (int64, error)

func (*Queries) DeletePasskey

func (q *Queries) DeletePasskey(ctx context.Context, arg DeletePasskeyParams) (int64, error)

func (*Queries) DeleteRecoveryCodes

func (q *Queries) DeleteRecoveryCodes(ctx context.Context, userID string) error

func (*Queries) DeleteRoleBinding

func (q *Queries) DeleteRoleBinding(ctx context.Context, arg DeleteRoleBindingParams) (int64, error)

func (*Queries) DeleteSession

func (q *Queries) DeleteSession(ctx context.Context, idHash string) error

func (*Queries) DeleteToken

func (q *Queries) DeleteToken(ctx context.Context, arg DeleteTokenParams) (int64, error)

func (*Queries) DeleteUserPasskeys

func (q *Queries) DeleteUserPasskeys(ctx context.Context, userID string) (int64, error)

func (*Queries) DeleteUserSessions

func (q *Queries) DeleteUserSessions(ctx context.Context, userID string) (int64, error)

func (*Queries) DeleteUserTokens

func (q *Queries) DeleteUserTokens(ctx context.Context, userID string) (int64, error)

func (*Queries) EnsureTenant

func (q *Queries) EnsureTenant(ctx context.Context, arg EnsureTenantParams) error

Tenants (PHASE1 section 1.2). The id is also the directory name below <data>/tenants/ and is validated by store.Layout before it gets here.

Query files must be ASCII only: sqlc 1.31.1 miscounts positions after a multi-byte character in SQLite query files and cuts statements short.

func (*Queries) GetInstance

func (q *Queries) GetInstance(ctx context.Context) (GetInstanceRow, error)

func (*Queries) GetSession

func (q *Queries) GetSession(ctx context.Context, idHash string) (Session, error)

func (*Queries) GetTenant

func (q *Queries) GetTenant(ctx context.Context, id string) (GetTenantRow, error)

func (*Queries) GetTenantSettings

func (q *Queries) GetTenantSettings(ctx context.Context, id string) (GetTenantSettingsRow, error)

Settings of a tenant (step 18): server key generation and subject defaults.

func (*Queries) GetTokenByHash

func (q *Queries) GetTokenByHash(ctx context.Context, tokenHash string) (ApiToken, error)

func (*Queries) GetUnsealSlot

func (q *Queries) GetUnsealSlot(ctx context.Context, slot string) (Unseal, error)

Unseal slots (ASCII only, see tenants.sql).

func (*Queries) GetUser

func (q *Queries) GetUser(ctx context.Context, id string) (User, error)

func (*Queries) GetUserByName

func (q *Queries) GetUserByName(ctx context.Context, username string) (User, error)

func (*Queries) InsertInstance

func (q *Queries) InsertInstance(ctx context.Context, arg InsertInstanceParams) error

The instance row (PHASE1 step 11). ASCII only, see tenants.sql.

func (*Queries) InsertPasskey

func (q *Queries) InsertPasskey(ctx context.Context, arg InsertPasskeyParams) error

Passkeys (step 17).

func (*Queries) InsertRecoveryCode

func (q *Queries) InsertRecoveryCode(ctx context.Context, arg InsertRecoveryCodeParams) error

func (*Queries) InsertSession

func (q *Queries) InsertSession(ctx context.Context, arg InsertSessionParams) error

func (*Queries) InsertToken

func (q *Queries) InsertToken(ctx context.Context, arg InsertTokenParams) error

API tokens (step 18).

func (*Queries) InsertUnsealSlot

func (q *Queries) InsertUnsealSlot(ctx context.Context, arg InsertUnsealSlotParams) error

func (*Queries) InsertUser

func (q *Queries) InsertUser(ctx context.Context, arg InsertUserParams) error

Users, roles and sessions (PHASE1 step 10). ASCII only, see tenants.sql.

func (*Queries) ListPasskeys

func (q *Queries) ListPasskeys(ctx context.Context, userID string) ([]WebauthnCredential, error)

func (*Queries) ListRoleBindings

func (q *Queries) ListRoleBindings(ctx context.Context, userID string) ([]RoleBinding, error)

func (*Queries) ListTenants

func (q *Queries) ListTenants(ctx context.Context) ([]ListTenantsRow, error)

func (*Queries) ListTokens

func (q *Queries) ListTokens(ctx context.Context, userID string) ([]ApiToken, error)

func (*Queries) ListUsers

func (q *Queries) ListUsers(ctx context.Context) ([]User, error)

func (*Queries) RehashPassword

func (q *Queries) RehashPassword(ctx context.Context, arg RehashPasswordParams) error

The same password with new hash parameters: device cookies stay valid.

func (*Queries) ResetTOTP

func (q *Queries) ResetTOTP(ctx context.Context, arg ResetTOTPParams) error

A new secret set by an admin: confirmed by the first valid code.

func (*Queries) SetDisabled

func (q *Queries) SetDisabled(ctx context.Context, arg SetDisabledParams) error

func (*Queries) SetLoginFailures

func (q *Queries) SetLoginFailures(ctx context.Context, arg SetLoginFailuresParams) error

func (*Queries) SetPassword

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

func (*Queries) SetRoleBinding

func (q *Queries) SetRoleBinding(ctx context.Context, arg SetRoleBindingParams) error

func (*Queries) SetStepUp

func (q *Queries) SetStepUp(ctx context.Context, arg SetStepUpParams) error

func (*Queries) SetTOTPPending

func (q *Queries) SetTOTPPending(ctx context.Context, arg SetTOTPPendingParams) error

func (*Queries) SetTenantSettings

func (q *Queries) SetTenantSettings(ctx context.Context, arg SetTenantSettingsParams) (int64, error)

func (*Queries) TouchSession

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

func (*Queries) TouchToken

func (q *Queries) TouchToken(ctx context.Context, arg TouchTokenParams) error

func (*Queries) UpdateUnsealSlot

func (q *Queries) UpdateUnsealSlot(ctx context.Context, arg UpdateUnsealSlotParams) (int64, error)

func (*Queries) UsePasskey

func (q *Queries) UsePasskey(ctx context.Context, arg UsePasskeyParams) (int64, error)

A sign-in with a passkey: the counter only moves forward, or stays 0 for authenticators that never count (synced passkeys). The WHERE makes a race between two sign-ins safe.

func (*Queries) UseRecoveryCode

func (q *Queries) UseRecoveryCode(ctx context.Context, arg UseRecoveryCodeParams) (int64, error)

0 rows = unknown or used code.

func (*Queries) UseTOTPStep

func (q *Queries) UseTOTPStep(ctx context.Context, arg UseTOTPStepParams) (int64, error)

Takes a time step only if it is newer than the last one: a TOTP code is valid once, also when two requests race. 0 rows = replayed code.

func (*Queries) WithTx

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

type RecoveryCode

type RecoveryCode struct {
	UserID    string
	CodeHash  string
	UsedAt    sql.NullString
	CreatedAt string
}

type RehashPasswordParams

type RehashPasswordParams struct {
	PasswordHash string
	UpdatedAt    string
	ID           string
}

type ResetTOTPParams

type ResetTOTPParams struct {
	TotpSecret []byte
	UpdatedAt  string
	ID         string
}

type RoleBinding

type RoleBinding struct {
	UserID    string
	TenantID  string
	Ca        string
	Role      string
	CreatedAt string
	CreatedBy string
}

type Session

type Session struct {
	IDHash     string
	UserID     string
	State      string
	CsrfToken  string
	CreatedAt  string
	LastSeenAt string
	ExpiresAt  string
	StepupAt   sql.NullString
}

type SetDisabledParams

type SetDisabledParams struct {
	DisabledAt sql.NullString
	UpdatedAt  string
	ID         string
}

type SetLoginFailuresParams

type SetLoginFailuresParams struct {
	FailedLogins int64
	LockedUntil  sql.NullString
	UpdatedAt    string
	ID           string
}

type SetPasswordParams

type SetPasswordParams struct {
	PasswordHash      string
	PasswordChangedAt string
	UpdatedAt         string
	ID                string
}

type SetRoleBindingParams

type SetRoleBindingParams struct {
	UserID    string
	TenantID  string
	Ca        string
	Role      string
	CreatedAt string
	CreatedBy string
}

type SetStepUpParams

type SetStepUpParams struct {
	StepupAt sql.NullString
	IDHash   string
}

type SetTOTPPendingParams

type SetTOTPPendingParams struct {
	TotpPending []byte
	UpdatedAt   string
	ID          string
}

type SetTenantSettingsParams

type SetTenantSettingsParams struct {
	AllowServerKeygen int64
	SubjectO          string
	SubjectOu         string
	SubjectL          string
	SubjectSt         string
	SubjectC          string
	AcmeOrdersPerHour int64
	AcmeFailedPerName int64
	AcmeAccountsPerIp int64
	ID                string
}

type Tenant

type Tenant struct {
	ID                string
	Name              string
	AllowServerKeygen int64
	CreatedAt         string
	SubjectO          string
	SubjectOu         string
	SubjectL          string
	SubjectSt         string
	SubjectC          string
	AcmeOrdersPerHour int64
	AcmeFailedPerName int64
	AcmeAccountsPerIp int64
}

type TouchSessionParams

type TouchSessionParams struct {
	LastSeenAt string
	IDHash     string
}

type TouchTokenParams

type TouchTokenParams struct {
	LastUsedAt sql.NullString
	ID         string
}

type Unseal

type Unseal struct {
	Slot           string
	RootKeyVersion int64
	Kdf            string
	KdfParams      string
	Salt           []byte
	WrappedRootKey []byte
	CreatedAt      string
	UpdatedAt      string
}

type UpdateUnsealSlotParams

type UpdateUnsealSlotParams struct {
	Kdf            string
	KdfParams      string
	Salt           []byte
	WrappedRootKey []byte
	UpdatedAt      string
	Slot           string
	RootKeyVersion int64
}

type UsePasskeyParams

type UsePasskeyParams struct {
	Credential string
	SignCount  int64
	LastUsedAt sql.NullString
	ID         string
}

type UseRecoveryCodeParams

type UseRecoveryCodeParams struct {
	UsedAt   sql.NullString
	UserID   string
	CodeHash string
}

type UseTOTPStepParams

type UseTOTPStepParams struct {
	TotpLastStep    int64
	TotpConfirmedAt sql.NullString
	UpdatedAt       string
	ID              string
	TotpLastStep_2  int64
}

type User

type User struct {
	ID                string
	Username          string
	PasswordHash      string
	PasswordChangedAt string
	TotpSecret        []byte
	TotpConfirmedAt   sql.NullString
	TotpLastStep      int64
	TotpPending       []byte
	InstanceAdmin     int64
	DisabledAt        sql.NullString
	FailedLogins      int64
	LockedUntil       sql.NullString
	CreatedAt         string
	UpdatedAt         string
	CredentialsEpoch  int64
}

type WebauthnCredential

type WebauthnCredential struct {
	ID           string
	UserID       string
	CredentialID []byte
	Credential   string
	Name         string
	SignCount    int64
	CreatedAt    string
	LastUsedAt   sql.NullString
}

Jump to

Keyboard shortcuts

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