systemdb

package
v0.3.8 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 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 Alert added in v0.3.3

type Alert struct {
	ID               string
	Tenant           string
	AlertKey         string
	Kind             string
	Subject          string
	Severity         string
	Detail           string
	Href             string
	FirstSeenAt      string
	LastSeenAt       string
	ResolvedAt       sql.NullString
	NotifiedSeverity sql.NullString
	NotifiedAt       sql.NullString
	ResolveNotified  int64
}

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 DeleteFinishedNotificationsBeforeParams added in v0.3.3

type DeleteFinishedNotificationsBeforeParams struct {
	SentAt    sql.NullString
	DroppedAt sql.NullString
}

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
	TrustPage              int64
	AgentEnrollment        string
	StepUpMinutes          int64
	AgentPredecessorChoice string
	AgentPredecessorDays   int64
	OtherPredecessorChoice string
	OtherPredecessorDays   int64
}

type InsertAlertParams added in v0.3.3

type InsertAlertParams struct {
	ID          string
	Tenant      string
	AlertKey    string
	Kind        string
	Subject     string
	Severity    string
	Detail      string
	Href        string
	FirstSeenAt string
	LastSeenAt  string
}

type InsertInstanceParams

type InsertInstanceParams struct {
	Demo          int64
	InitializedAt string
}

type InsertNotificationParams added in v0.3.3

type InsertNotificationParams struct {
	Channel       string
	CreatedAt     string
	PayloadJson   string
	NextAttemptAt 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
	StepupMinutes int64
}

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 ListAlertsSinceParams added in v0.3.3

type ListAlertsSinceParams struct {
	Tenant     string
	ResolvedAt sql.NullString
}

type ListTenantsRow

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

type MarkAlertNotifiedParams added in v0.3.3

type MarkAlertNotifiedParams struct {
	NotifiedSeverity sql.NullString
	NotifiedAt       sql.NullString
	ID               string
}

type MarkNotificationDroppedParams added in v0.3.3

type MarkNotificationDroppedParams struct {
	DroppedAt sql.NullString
	LastError sql.NullString
	ID        int64
}

type MarkNotificationRetryParams added in v0.3.3

type MarkNotificationRetryParams struct {
	NextAttemptAt string
	LastError     sql.NullString
	ID            int64
}

type MarkNotificationSentParams added in v0.3.3

type MarkNotificationSentParams struct {
	SentAt sql.NullString
	ID     int64
}

type Notification added in v0.3.3

type Notification struct {
	ID            int64
	Channel       string
	CreatedAt     string
	PayloadJson   string
	Attempts      int64
	NextAttemptAt string
	SentAt        sql.NullString
	DroppedAt     sql.NullString
	LastError     sql.NullString
}

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) DeleteFinishedNotificationsBefore added in v0.3.3

func (q *Queries) DeleteFinishedNotificationsBefore(ctx context.Context, arg DeleteFinishedNotificationsBeforeParams) (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) DeleteResolvedAlertsBefore added in v0.3.3

func (q *Queries) DeleteResolvedAlertsBefore(ctx context.Context, resolvedAt sql.NullString) (int64, 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) GetAgentEnrollment added in v0.3.0

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

The agent listener asks this for every enrollment (v0.3.0).

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) GetStepUpMinutes added in v0.3.1

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

Authentication snapshots this whenever it records a new second-factor proof.

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) GetTrustPage added in v0.2.2

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

The public listener asks this for every request to / (v0.2.2).

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) InsertAlert added in v0.3.3

func (q *Queries) InsertAlert(ctx context.Context, arg InsertAlertParams) 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) InsertNotification added in v0.3.3

func (q *Queries) InsertNotification(ctx context.Context, arg InsertNotificationParams) (int64, error)

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) ListAlertsSince added in v0.3.3

func (q *Queries) ListAlertsSince(ctx context.Context, arg ListAlertsSinceParams) ([]Alert, error)

Open alerts and those resolved at or after the given time, newest first.

func (*Queries) ListDueNotifications added in v0.3.3

func (q *Queries) ListDueNotifications(ctx context.Context, nextAttemptAt string) ([]Notification, error)

func (*Queries) ListOpenAlerts added in v0.3.3

func (q *Queries) ListOpenAlerts(ctx context.Context, tenant string) ([]Alert, error)

Monitoring: alerts and notification digests (ASCII only, see tenants.sql).

func (*Queries) ListPasskeys

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

func (*Queries) ListResolvedUnnotified added in v0.3.3

func (q *Queries) ListResolvedUnnotified(ctx context.Context, tenant string) ([]Alert, error)

Resolved alerts whose opening was reported but whose end was not yet.

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) MarkAlertNotified added in v0.3.3

func (q *Queries) MarkAlertNotified(ctx context.Context, arg MarkAlertNotifiedParams) error

func (*Queries) MarkAlertResolveNotified added in v0.3.3

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

func (*Queries) MarkNotificationDropped added in v0.3.3

func (q *Queries) MarkNotificationDropped(ctx context.Context, arg MarkNotificationDroppedParams) error

func (*Queries) MarkNotificationRetry added in v0.3.3

func (q *Queries) MarkNotificationRetry(ctx context.Context, arg MarkNotificationRetryParams) error

func (*Queries) MarkNotificationSent added in v0.3.3

func (q *Queries) MarkNotificationSent(ctx context.Context, arg MarkNotificationSentParams) 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) ResolveAlert added in v0.3.3

func (q *Queries) ResolveAlert(ctx context.Context, arg ResolveAlertParams) error

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) UpdateOpenAlert added in v0.3.3

func (q *Queries) UpdateOpenAlert(ctx context.Context, arg UpdateOpenAlertParams) 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 ResolveAlertParams added in v0.3.3

type ResolveAlertParams struct {
	ResolvedAt sql.NullString
	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
	StepupMinutes int64
}

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
	StepupMinutes int64
	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
	TrustPage              int64
	AgentEnrollment        string
	StepUpMinutes          int64
	AgentPredecessorChoice string
	AgentPredecessorDays   int64
	OtherPredecessorChoice string
	OtherPredecessorDays   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
	TrustPage              int64
	AgentEnrollment        string
	StepUpMinutes          int64
	AgentPredecessorChoice string
	AgentPredecessorDays   int64
	OtherPredecessorChoice string
	OtherPredecessorDays   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 UpdateOpenAlertParams added in v0.3.3

type UpdateOpenAlertParams struct {
	Subject    string
	Severity   string
	Detail     string
	Href       string
	LastSeenAt string
	ID         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