access

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package access is the PostgreSQL repository of the access context: members, API tokens and sessions.

Index

Constants

View Source
const AuthSettingsChannel = "auth_settings"

AuthSettingsChannel is the notification channel a change of the auth settings is announced on, so every replica drops what it cached.

View Source
const SMTPSettingsChannel = "smtp_settings"

SMTPSettingsChannel is the notification channel a change of the SMTP settings is announced on, so every replica drops what it cached.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthSettingsCache

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

AuthSettingsCache holds a replica's copy of the auth settings, which every request judging a session reads, trusted only while its listener on AuthSettingsChannel is up.

func NewAuthSettingsCache

func NewAuthSettingsCache(pool *pgxpool.Pool) *AuthSettingsCache

NewAuthSettingsCache returns a cache of the settings on pool, which reads through until its listener reports itself up.

func (*AuthSettingsCache) AuthSettings

func (c *AuthSettingsCache) AuthSettings(ctx context.Context) (access.AuthSettings, error)

AuthSettings returns the auth settings, from the copy while it can be trusted.

func (AuthSettingsCache) Forget

func (c AuthSettingsCache) Forget()

Forget drops the copy, as a change made by this replica does once it is committed, so the replica's next read sees it without waiting for the notification.

func (AuthSettingsCache) Listening

func (c AuthSettingsCache) Listening(up bool)

Listening is told when the listener starts or stops listening.

func (AuthSettingsCache) Received

func (c AuthSettingsCache) Received(string)

Received is told of each change announced.

type SMTPSettingsCache added in v0.3.0

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

SMTPSettingsCache holds a replica's copy of the SMTP settings, trusted only while its listener on SMTPSettingsChannel is up. A replica with no settings holds that too.

func NewSMTPSettingsCache added in v0.3.0

func NewSMTPSettingsCache(pool *pgxpool.Pool) *SMTPSettingsCache

NewSMTPSettingsCache returns a cache of the SMTP settings on pool, which reads through until its listener reports itself up.

func (SMTPSettingsCache) Forget added in v0.3.0

func (c SMTPSettingsCache) Forget()

Forget drops the copy, as a change made by this replica does once it is committed, so the replica's next read sees it without waiting for the notification.

func (SMTPSettingsCache) Listening added in v0.3.0

func (c SMTPSettingsCache) Listening(up bool)

Listening is told when the listener starts or stops listening.

func (SMTPSettingsCache) Received added in v0.3.0

func (c SMTPSettingsCache) Received(string)

Received is told of each change announced.

func (*SMTPSettingsCache) SMTPSettings added in v0.3.0

func (c *SMTPSettingsCache) SMTPSettings(ctx context.Context) (access.SMTPSettings, error)

SMTPSettings returns the SMTP settings, from the copy while it can be trusted, ErrSMTPNotConfigured when there are none.

type Store

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

Store is the repository of members and API tokens.

func NewStore

func NewStore(pool *pgxpool.Pool) *Store

NewStore returns the repository on pool.

func (*Store) ActiveInstanceAdmins added in v0.3.0

func (s *Store) ActiveInstanceAdmins(ctx context.Context) ([]access.Member, error)

ActiveInstanceAdmins returns the active members who are instance admins, ordered by email whatever its case.

func (*Store) AnyInstanceAdmin

func (s *Store) AnyInstanceAdmin(ctx context.Context) (bool, error)

AnyInstanceAdmin reports whether the instance has an instance admin, whatever their status.

func (*Store) AuthSettings

func (s *Store) AuthSettings(ctx context.Context) (access.AuthSettings, error)

AuthSettings returns the instance's auth settings as stored.

func (*Store) ClearAllSignInFailures added in v0.3.0

func (s *Store) ClearAllSignInFailures(ctx context.Context, at time.Time) (int, error)

ClearAllSignInFailures forgets every failed sign-in counted, per email, per email and source, and per source, and returns how many emails were locked out at the moment at, alone or from some source: an email locked both ways counts once, and a lockout already over counts not at all.

func (*Store) ClearAttempt

func (s *Store) ClearAttempt(ctx context.Context, r access.Reservation) error

ClearAttempt takes back the failure r reserved once its password proved right: the source's window, when it is still the one counted in, holds one less, and the consecutive failures r was counted under end. A right password from a known source leaves the email's own failures, which every other source shares, as they are: the member signing in from home does not reset a guesser's count elsewhere.

func (*Store) ClearPasswordHash added in v0.3.0

func (s *Store) ClearPasswordHash(ctx context.Context, member access.MemberID, at time.Time) error

ClearPasswordHash removes the password of member.

func (*Store) ClearSignInFailures added in v0.3.0

func (s *Store) ClearSignInFailures(ctx context.Context, email string) error

ClearSignInFailures ends the consecutive failed sign-ins counted under email, whatever its case, its own and those from the sources its member signed in from, which lifts any lockout of the email. The failures of an address, which are not the member's, stay.

func (*Store) ConsumeInvitations

func (s *Store) ConsumeInvitations(ctx context.Context, member access.MemberID, at time.Time) (int, error)

ConsumeInvitations ends every open invitation of member at at, and returns how many it ended.

func (*Store) ConsumePasswordResets added in v0.3.0

func (s *Store) ConsumePasswordResets(ctx context.Context, member access.MemberID, at time.Time) (int, error)

ConsumePasswordResets ends every open password reset of member at at, and returns how many it ended.

func (*Store) CreateGrant

func (s *Store) CreateGrant(ctx context.Context, g access.Grant) error

CreateGrant stores g; the same member, role and source in the project twice is refused already_granted.

func (*Store) CreateGrantUnlessHeld added in v0.3.0

func (s *Store) CreateGrantUnlessHeld(ctx context.Context, g access.Grant) (bool, error)

CreateGrantUnlessHeld stores g, unless the member holds the role in the project from the same source already, and reports whether it did.

func (*Store) CreateInvitation

func (s *Store) CreateInvitation(ctx context.Context, inv access.Invitation) error

CreateInvitation stores inv.

func (*Store) CreateMember

func (s *Store) CreateMember(ctx context.Context, m access.Member, passwordHash string) error

CreateMember stores m with its password hash ("" for none).

func (*Store) CreatePasswordReset added in v0.3.0

func (s *Store) CreatePasswordReset(ctx context.Context, reset access.PasswordReset) error

CreatePasswordReset stores reset.

func (*Store) CreateProvisionedMember added in v0.3.0

func (s *Store) CreateProvisionedMember(ctx context.Context, m access.Member, at time.Time) error

CreateProvisionedMember stores m, a member of a provider, without a password.

func (*Store) CreateSession

func (s *Store) CreateSession(ctx context.Context, sess access.Session) error

CreateSession stores sess.

func (*Store) CreateToken

func (s *Store) CreateToken(ctx context.Context, t access.APIToken) error

CreateToken stores t.

func (*Store) DeleteGrant

func (s *Store) DeleteGrant(ctx context.Context, project workspace.ProjectID, grant access.GrantID) (access.Grant, error)

DeleteGrant removes the grant of project with the identifier and returns it; ErrNotFound when the project holds none.

func (*Store) DeleteSMTPSettings added in v0.3.0

func (s *Store) DeleteSMTPSettings(ctx context.Context) error

DeleteSMTPSettings removes the SMTP settings and announces it on SMTPSettingsChannel.

func (*Store) DropInvitationGrant added in v0.3.0

func (s *Store) DropInvitationGrant(ctx context.Context, invitation access.InvitationID) error

DropInvitationGrant clears the project and role of the invitation, which still activates its member.

func (*Store) GrantedProjects

func (s *Store) GrantedProjects(ctx context.Context, member access.MemberID) ([]workspace.ProjectID, error)

GrantedProjects returns the projects member holds a grant in.

func (*Store) GrantingInvitations added in v0.3.0

func (s *Store) GrantingInvitations(ctx context.Context, inviter access.MemberID, project workspace.ProjectID,
) ([]appaccess.GrantingInvitation, error)

GrantingInvitations returns the invitations issued by inviter, not consumed yet, that would grant a role in project, or in any project when project is zero, each with its member, locked until the transaction ends.

func (*Store) InvitationByHash

func (s *Store) InvitationByHash(ctx context.Context, hash access.InvitationHash) (access.Invitation, access.Member, error)

InvitationByHash returns the invitation whose secret hashes to hash, with its member; ErrNotFound when there is none.

func (*Store) InvitationDetails added in v0.3.0

func (s *Store) InvitationDetails(ctx context.Context, invitation access.InvitationID) (appaccess.InvitationDetails, error)

InvitationDetails returns what the page of the invitation shows besides its member: the project it grants a role in, if it still does, and who issued it.

func (*Store) LatestSelfServicePasswordReset added in v0.3.0

func (s *Store) LatestSelfServicePasswordReset(ctx context.Context, member access.MemberID) (time.Time, bool, error)

LatestSelfServicePasswordReset returns when the latest password reset member asked for was issued, whether or not it is still open; false when they never asked. One an instance admin issued does not count.

func (*Store) LockAuthSettings

func (s *Store) LockAuthSettings(ctx context.Context) (access.AuthSettings, error)

LockAuthSettings returns the auth settings and locks them until the transaction ends, so two changes made at once each see the other's outcome. The enforced domains are locked with the row: every change to them takes this lock first.

func (*Store) LockBootstrap

func (s *Store) LockBootstrap(ctx context.Context) error

LockBootstrap serializes bootstraps until the transaction ends.

func (*Store) LockGrant

func (s *Store) LockGrant(ctx context.Context, project workspace.ProjectID, grant access.GrantID) (access.Grant, error)

LockGrant returns the grant of project with the identifier, locked until the transaction ends; ErrNotFound when the project holds none.

func (*Store) LockInstanceAdmins

func (s *Store) LockInstanceAdmins(ctx context.Context) error

LockInstanceAdmins takes, until the transaction ends, the lock every change that could leave the instance without an active instance admin holds. The key names the schema too, so instances sharing a database in separate schemas do not wait on each other.

func (*Store) LockInvitationByHash

func (s *Store) LockInvitationByHash(ctx context.Context, hash access.InvitationHash) (access.Invitation, access.Member, error)

LockInvitationByHash returns the invitation whose secret hashes to hash, locked until the transaction ends, with its member; ErrNotFound when there is none. Its member is to be locked first, as every change to a member's invitations locks them.

func (*Store) LockMember

func (s *Store) LockMember(ctx context.Context, member access.MemberID) (access.Member, bool, error)

LockMember returns the member, locked until the transaction ends, and whether they hold a password; ErrNotFound when none has the identifier. The lock excludes every other LockMember of the member but not a row merely referring to them: a change to a member never removes them, and a unit of work holding a member while it waits on rows another holds (an inviter deactivated waits on the invitations they issued) would otherwise deadlock with that other inserting a row naming the member (accepting one of those invitations makes a grant created by the inviter).

func (*Store) LockMemberByEmail

func (s *Store) LockMemberByEmail(ctx context.Context, email string) (access.Member, error)

LockMemberByEmail returns the member whose email is email whatever its case, locked until the transaction ends; ErrNotFound when there is none.

func (*Store) LockMemberPassword added in v0.2.0

func (s *Store) LockMemberPassword(ctx context.Context, member access.MemberID) (access.Member, string, error)

LockMemberPassword returns the member with the identifier and their password hash ("" for none), locked until the transaction ends; ErrNotFound when there is none.

func (*Store) LockPasswordResetByHash added in v0.3.0

func (s *Store) LockPasswordResetByHash(ctx context.Context, hash access.PasswordResetHash,
) (access.PasswordReset, access.Member, error)

LockPasswordResetByHash returns the password reset whose secret hashes to hash, locked until the transaction ends, with its member; ErrNotFound when there is none. Its member is to be locked first, as every change to a member's password resets locks them.

func (*Store) LockSMTPSettings added in v0.3.0

func (s *Store) LockSMTPSettings(ctx context.Context) (access.SMTPSettings, error)

LockSMTPSettings returns the SMTP settings and locks them until the transaction ends, so two changes made at once each see the other's outcome; ErrSMTPNotConfigured when there are none. Two first configurations at once are ordered by the row's primary key.

func (*Store) MemberByEmail

func (s *Store) MemberByEmail(ctx context.Context, email string) (access.Member, string, error)

MemberByEmail returns the member whose email is email whatever its case, with their password hash ("" for none); ErrNotFound when there is none.

func (*Store) MemberByExternalID added in v0.3.0

func (s *Store) MemberByExternalID(ctx context.Context, provider, externalID string) (access.Member, error)

MemberByExternalID returns the member the provider with this slug provisioned with externalID as their external ID; ErrNotFound when there is none.

func (*Store) MemberByID

func (s *Store) MemberByID(ctx context.Context, member access.MemberID) (access.Member, error)

MemberByID returns the member with the identifier; ErrNotFound when there is none.

func (*Store) MemberEmails added in v0.3.0

func (s *Store) MemberEmails(ctx context.Context, members []access.MemberID) (map[access.MemberID]string, error)

MemberEmails returns the email address of each of members that exists, as the member signs in with it.

func (*Store) MemberGrants

func (s *Store) MemberGrants(ctx context.Context, member access.MemberID, project workspace.ProjectID) ([]access.Grant, error)

MemberGrants returns the grants member holds in project, oldest first.

func (*Store) MemberSessions

func (s *Store) MemberSessions(ctx context.Context, member access.MemberID) ([]access.Session, error)

MemberSessions returns the sessions of member not yet revoked, the newest first.

func (*Store) MemberView

func (s *Store) MemberView(ctx context.Context, member access.MemberID) (appaccess.MemberView, error)

MemberView returns one member as an instance admin sees them; ErrNotFound when none has the identifier.

func (*Store) Members

Members returns the members f selects, ordered by email whatever its case.

func (*Store) OtherActiveInstanceAdmins

func (s *Store) OtherActiveInstanceAdmins(ctx context.Context, member access.MemberID) (int, error)

OtherActiveInstanceAdmins counts the active instance admins other than member.

func (*Store) PasswordResetByHash added in v0.3.0

func (s *Store) PasswordResetByHash(ctx context.Context, hash access.PasswordResetHash) (access.PasswordReset, access.Member, error)

PasswordResetByHash returns the password reset whose secret hashes to hash, with its member; ErrNotFound when there is none.

func (*Store) PasswordSetAt added in v0.3.0

func (s *Store) PasswordSetAt(ctx context.Context, member access.MemberID) (*time.Time, error)

PasswordSetAt returns when member set the password they hold; nil when they hold none. ErrNotFound when no member has the identifier.

func (*Store) PendingInvitation added in v0.3.0

func (s *Store) PendingInvitation(ctx context.Context, member access.MemberID) (access.Invitation, error)

PendingInvitation returns the latest invitation of member not consumed yet, expired or not, locked until the transaction ends; ErrNotFound when the member has none. Its member is to be locked first.

func (*Store) PersonalTokens

func (s *Store) PersonalTokens(ctx context.Context, member access.MemberID) ([]access.APIToken, error)

PersonalTokens returns every personal access token of member, the newest first.

func (*Store) ProjectGrants

func (s *Store) ProjectGrants(ctx context.Context, project workspace.ProjectID) ([]access.Grant, error)

ProjectGrants returns every grant of project, oldest first.

func (*Store) ProjectInvitations added in v0.3.0

func (s *Store) ProjectInvitations(ctx context.Context, project workspace.ProjectID) ([]appaccess.ProjectInvitation, error)

ProjectInvitations returns the invited members whose pending invitation, expired or not, grants a role in project, ordered by email, each with that invitation. A member's pending invitation is their latest not consumed yet, so an earlier one is passed over even when it grants a role here.

func (*Store) ProjectKeyAndName added in v0.3.0

func (s *Store) ProjectKeyAndName(ctx context.Context, project workspace.ProjectID) (key, name string, err error)

ProjectKeyAndName returns the key and the name of project; ErrNotFound when it no longer exists.

func (*Store) ProjectMemberCounts

func (s *Store) ProjectMemberCounts(ctx context.Context, projects []workspace.ProjectID) (map[workspace.ProjectID]int, error)

ProjectMemberCounts returns how many active members hold a grant in each of projects, in one query.

func (*Store) ProjectMembers

func (s *Store) ProjectMembers(ctx context.Context, project workspace.ProjectID) ([]appaccess.ProjectMember, error)

ProjectMembers returns the members holding grants in project, ordered by email, each with their grants oldest first, in one query.

func (*Store) ProjectTokens

func (s *Store) ProjectTokens(ctx context.Context, project workspace.ProjectID) ([]access.APIToken, error)

ProjectTokens returns every project token of project, the newest first.

func (*Store) ProviderGrants added in v0.3.0

func (s *Store) ProviderGrants(ctx context.Context, member access.MemberID, provider string) ([]access.Grant, error)

ProviderGrants returns the grants the group mappings of the auth provider with slug made to member, in every project, oldest first.

func (*Store) ProviderMadeAccess added in v0.3.0

func (s *Store) ProviderMadeAccess(ctx context.Context, provider string) (bool, error)

ProviderMadeAccess reports whether the group mappings of the auth provider with slug made any grant or any instance admin.

func (*Store) ProviderProvisionedMembers added in v0.3.0

func (s *Store) ProviderProvisionedMembers(ctx context.Context, provider string) (bool, error)

ProviderProvisionedMembers reports whether the provider holds a member.

func (*Store) ProvisionedMembers added in v0.3.0

func (s *Store) ProvisionedMembers(ctx context.Context, provider string, conds []appaccess.ProvisionedCondition,
	startIndex, count int,
) ([]access.Member, int, error)

ProvisionedMembers returns the page of provider's members that satisfy every condition, and how many do in all.

func (*Store) PurgeEmailFailures

func (s *Store) PurgeEmailFailures(ctx context.Context, cut access.FailureCutoffs, limit int) (int, error)

PurgeEmailFailures deletes at most limit emails' failures that no lock holds and whose last failure is at or before the cutoff.

func (*Store) PurgeInvitations

func (s *Store) PurgeInvitations(ctx context.Context, cut access.InvitationCutoffs, limit int) (int, error)

PurgeInvitations deletes at most limit invitations consumed or expired at or before the cutoff, except each member's latest, which stays as the record of their last link.

func (*Store) PurgeKnownSourceFailures added in v0.2.0

func (s *Store) PurgeKnownSourceFailures(ctx context.Context, cut access.FailureCutoffs, limit int) (int, error)

PurgeKnownSourceFailures deletes at most limit failures of emails from known sources that no lock holds and whose last failure is at or before the cutoff, as PurgeEmailFailures does an email's own.

func (*Store) PurgeKnownSources added in v0.2.0

func (s *Store) PurgeKnownSources(ctx context.Context, cut access.FailureCutoffs, limit int) (int, error)

PurgeKnownSources deletes at most limit sources their members last signed in from at or before the cutoff: they are no longer known.

func (*Store) PurgePasswordResets added in v0.3.0

func (s *Store) PurgePasswordResets(ctx context.Context, cut access.PasswordResetCutoffs, limit int) (int, error)

PurgePasswordResets deletes at most limit password resets consumed or expired at or before the cutoff.

func (*Store) PurgeSessions

func (s *Store) PurgeSessions(ctx context.Context, cut access.SessionCutoffs, limit int) (int, error)

PurgeSessions deletes at most limit sessions the cutoffs end.

func (*Store) PurgeSourceFailures

func (s *Store) PurgeSourceFailures(ctx context.Context, cut access.FailureCutoffs, limit int) (int, error)

PurgeSourceFailures deletes at most limit sources' failures whose window opened at or before the cutoff.

func (*Store) RecordKnownSource added in v0.2.0

func (s *Store) RecordKnownSource(ctx context.Context, member access.MemberID, source netip.Prefix, at time.Time) error

RecordKnownSource records that member signed in from source at, which keeps the source known to them for the age the domain gives it.

func (*Store) RecordSignIn

func (s *Store) RecordSignIn(ctx context.Context, member access.MemberID, at time.Time) error

RecordSignIn records that member signed in at.

func (*Store) RecordTokenUse

func (s *Store) RecordTokenUse(ctx context.Context, token access.APITokenID, at time.Time, ip netip.Addr) error

RecordTokenUse records the use of token at at from ip unless a use less than the domain's interval before at is recorded already, so replicas recording the same token's use coalesce on one write per interval.

func (*Store) ReleaseAttempt

func (s *Store) ReleaseAttempt(ctx context.Context, r access.Reservation) error

ReleaseAttempt takes back the failure r reserved when its attempt guessed nothing: its password could not be verified, or proved right but the sign-in failed after, or it was refused before any was checked. It runs in the unit of work ctx carries, so the source and the failures r was counted under are taken back together. When no failure was counted on them since r, they are as they were before r: a lock r started is lifted, and a lock before it had ended, since r was counted. Failures fewer than r counted were cleared since, and r's failure went with them, so nothing is taken back twice.

func (*Store) ReserveAttempt

func (s *Store) ReserveAttempt(ctx context.Context, a access.Attempt) (access.Reservation, error)

ReserveAttempt counts a as a failure before its password is verified, and returns what it found: failures locked by earlier ones are not counted again, and report when they unlock. It runs in the unit of work ctx carries.

A statement sees only the rows committed before it began, so failures first counted by a statement it waited on, on the source's row, say, are invisible to its prior: the count finds them locked and skips them, but the statement cannot say until when. The skipped row is locked all the same until the unit of work ends, so a second statement, which sees it, reads the lock it was judged against.

func (*Store) ReserveSourceAttempt

func (s *Store) ReserveSourceAttempt(ctx context.Context, a access.Attempt) (access.Reservation, error)

ReserveSourceAttempt counts a as a failure of its source alone, before what it presents is checked: an attempt naming no email, such as accepting an invitation, is throttled with the source's other attempts but locks no email. The window is counted as reserveAttempt counts it.

func (*Store) RevokeMemberSessions

func (s *Store) RevokeMemberSessions(ctx context.Context, member access.MemberID, at time.Time) (int, error)

RevokeMemberSessions ends every session of member not ended yet at at, and returns how many it ended.

func (*Store) RevokePersonalToken

func (s *Store) RevokePersonalToken(ctx context.Context, member access.MemberID, token access.APITokenID, at time.Time,
) (access.APIToken, error)

RevokePersonalToken revokes member's unrevoked personal access token at at and returns it.

func (*Store) RevokePersonalTokens

func (s *Store) RevokePersonalTokens(ctx context.Context, member access.MemberID, at time.Time) (int, error)

RevokePersonalTokens revokes every personal access token of member not revoked yet at at, and returns how many it revoked.

func (*Store) RevokeProjectToken

func (s *Store) RevokeProjectToken(ctx context.Context, project workspace.ProjectID, token access.APITokenID, at time.Time,
) (access.APIToken, error)

RevokeProjectToken revokes project's unrevoked project token at at and returns it.

func (*Store) RevokeSession

func (s *Store) RevokeSession(ctx context.Context, session access.SessionID, at time.Time) error

RevokeSession ends session at, unless it has ended already.

func (*Store) RevokeSessions

func (s *Store) RevokeSessions(ctx context.Context, sessions []access.SessionID, at time.Time) ([]access.SessionID, error)

RevokeSessions ends each of sessions not ended yet at at, and returns those it ended.

func (*Store) SMTPSettings added in v0.3.0

func (s *Store) SMTPSettings(ctx context.Context) (access.SMTPSettings, error)

SMTPSettings returns the SMTP settings as stored, ErrSMTPNotConfigured when there are none.

func (*Store) SaveAuthSettings

func (s *Store) SaveAuthSettings(ctx context.Context, settings access.AuthSettings) error

SaveAuthSettings stores settings, the enforced domains replacing those stored, and announces the change on AuthSettingsChannel, which PostgreSQL delivers once the transaction commits and never if it rolls back. It runs in the transaction ctx carries, which holds the settings locked.

func (*Store) SaveMember

func (s *Store) SaveMember(ctx context.Context, m access.Member, at time.Time) error

SaveMember stores m's email, display name, status, instance admin switch with the provider that made it, and locale, NULL when the member follows the browser.

func (*Store) SaveProvisionedMember added in v0.3.0

func (s *Store) SaveProvisionedMember(ctx context.Context, m access.Member, at time.Time) error

SaveProvisionedMember stores m's email, display name, status, provider and external ID.

func (*Store) SaveSMTPSettings added in v0.3.0

func (s *Store) SaveSMTPSettings(ctx context.Context, settings access.SMTPSettings) error

SaveSMTPSettings stores settings, replacing any, and announces the change on SMTPSettingsChannel, which PostgreSQL delivers once the transaction commits and never if it rolls back.

func (*Store) SessionByHash

func (s *Store) SessionByHash(ctx context.Context, hash access.SessionHash) (access.Session, access.Member, error)

SessionByHash returns the session stored under hash with its member; ErrNotFound when there is none.

func (*Store) SetInstanceAdmin

func (s *Store) SetInstanceAdmin(ctx context.Context, member access.MemberID, instanceAdmin bool, at time.Time) error

SetInstanceAdmin makes member an instance admin or not.

func (*Store) SetPasswordHash

func (s *Store) SetPasswordHash(ctx context.Context, member access.MemberID, hash string, at time.Time) error

SetPasswordHash replaces the password hash of member.

func (*Store) TokenByHash

func (s *Store) TokenByHash(ctx context.Context, hash access.TokenHash) (access.APIToken, *access.Member, error)

TokenByHash returns the token whose value hashes to hash and, for a personal access token, its member.

func (*Store) TouchSession

func (s *Store) TouchSession(ctx context.Context, session access.SessionID, at time.Time) error

TouchSession records a request of session at, unless a later one is recorded already.

func (*Store) TryLockAuthRetention

func (s *Store) TryLockAuthRetention(ctx context.Context) (bool, error)

TryLockAuthRetention takes the purge lock until the transaction ends, without waiting; false when another replica holds it. The key names the schema too, so instances sharing a database in separate schemas purge independently.

Jump to

Keyboard shortcuts

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