postgres

package
v1.132.0 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package postgres is the identity_subjects table: the subject each address most recently authenticated as, and whether the person themselves recorded it.

It is the PostgreSQL half of internal/platform/subjects, split out under the module's postgres/ convention (pkg/audit/postgres, pkg/oauth/postgres) once the SQL grew past the point where it read as part of the Book that uses it. It knows nothing about that Book: it stores pairs and answers them.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

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

Store implements subjects.Store over the identity_subjects table.

func New

func New(db *sql.DB) *Store

New builds the store. A nil db yields a store that records nothing and knows nothing, so a caller need not check.

func (*Store) Lookup

func (s *Store) Lookup(ctx context.Context, address string) (string, error)

Lookup reads the subject recorded for address.

func (*Store) LookupPerson

func (s *Store) LookupPerson(ctx context.Context, address string) (string, error)

LookupPerson reads only a pair the person themselves recorded.

func (*Store) Record

func (s *Store) Record(ctx context.Context, address, subject string, fromPerson bool) error

Record upserts the pair, keeping the subject most recently seen.

A key's pair never overwrites a person's. Without that rule a service key configured with somebody's address would replace their subject with its own, and the key issued against their account would then authenticate as the service key instead of as them (#1759). A person's own sign-in always wins, which is also how a row a key wrote earlier is repaired.

Jump to

Keyboard shortcuts

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