Documentation
¶
Index ¶
- Variables
- func Migrate(ctx context.Context, pool *pgxpool.Pool) error
- func Open(ctx context.Context, cfg Config) (*pgxpool.Pool, error)
- func Ping(ctx context.Context, pool *pgxpool.Pool) error
- func RollbackLast(ctx context.Context, pool *pgxpool.Pool) error
- func VerifySchemaReady(ctx context.Context, pool *pgxpool.Pool) error
- func WithTenantTx(ctx context.Context, pool *pgxpool.Pool, tenantID string, ...) error
- type ApplicationOwnershipStore
- type Config
- type ConnectorEnrollmentStore
- func (s *ConnectorEnrollmentStore) AdmitCertificate(ctx context.Context, scope targetenrollment.Scope, serial string, ...) error
- func (s *ConnectorEnrollmentStore) Consume(ctx context.Context, scope targetenrollment.Scope, ...) (targetenrollment.Grant, error)
- func (s *ConnectorEnrollmentStore) Create(ctx context.Context, grant targetenrollment.Grant) error
- func (s *ConnectorEnrollmentStore) CreateRenewal(ctx context.Context, grant targetenrollment.Grant) error
- func (s *ConnectorEnrollmentStore) RecordIssued(ctx context.Context, scope targetenrollment.Scope, tokenDigest, serial string, ...) error
- func (s *ConnectorEnrollmentStore) RevokeCertificate(ctx context.Context, scope targetenrollment.Scope, serial string) error
- func (s *ConnectorEnrollmentStore) RevokeCurrent(ctx context.Context, scope targetenrollment.Scope) (string, error)
- func (s *ConnectorEnrollmentStore) Status(ctx context.Context, scope targetenrollment.Scope) (targetenrollment.NodeStatus, error)
- type IdentityTenantResolver
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidApplicationName = errors.New("invalid application name") ErrApplicationOwnershipConflict = errors.New("application is owned by another tenant") )
var ( ErrSchemaNotReady = errors.New("database schema is not ready") ErrUnexpectedMigration = errors.New("database has unexpected migration") )
var ErrInvalidPrincipal = errors.New("invalid principal")
var ErrInvalidTenantID = errors.New("invalid tenant id")
var ErrMissingDSN = errors.New("database DSN is required")
var ErrNoAppliedMigration = errors.New("no applied migration to roll back")
Functions ¶
func Migrate ¶
Migrate applies all embedded forward migrations exactly once in lexical order. Each migration runs in its own transaction. The migration table is authoritative.
func RollbackLast ¶
RollbackLast reverses exactly the most recently applied BaseHarbor migration. A rollback file is mandatory; rollback never guesses or destroys earlier schema.
func VerifySchemaReady ¶
VerifySchemaReady verifies the authoritative migration state without mutating it. Runtime processes must not apply migrations implicitly during startup.
func WithTenantTx ¶
func WithTenantTx(ctx context.Context, pool *pgxpool.Pool, tenantID string, fn func(pgx.Tx) error) error
WithTenantTx runs fn inside a transaction whose PostgreSQL session context is scoped to exactly one tenant. SET LOCAL semantics ensure the tenant context is automatically discarded when the transaction ends.
Types ¶
type ApplicationOwnershipStore ¶
type ApplicationOwnershipStore struct {
// contains filtered or unexported fields
}
ApplicationOwnershipStore is the authoritative persistence boundary for application-to-tenant ownership.
func NewApplicationOwnershipStore ¶
func NewApplicationOwnershipStore(pool *pgxpool.Pool) *ApplicationOwnershipStore
func (*ApplicationOwnershipStore) Claim ¶
func (s *ApplicationOwnershipStore) Claim(ctx context.Context, tenantID, applicationName string) error
func (*ApplicationOwnershipStore) OwnedByTenant ¶
func (s *ApplicationOwnershipStore) OwnedByTenant(ctx context.Context, tenantID, applicationName string) (bool, error)
OwnedByTenant implements the application-secret API ownership resolver. The lookup is tenant-scoped and therefore subject to PostgreSQL RLS.
type ConnectorEnrollmentStore ¶ added in v0.4.23
type ConnectorEnrollmentStore struct {
// contains filtered or unexported fields
}
func NewConnectorEnrollmentStore ¶ added in v0.4.23
func NewConnectorEnrollmentStore(pool *pgxpool.Pool) *ConnectorEnrollmentStore
func (*ConnectorEnrollmentStore) AdmitCertificate ¶ added in v0.4.23
func (s *ConnectorEnrollmentStore) AdmitCertificate(ctx context.Context, scope targetenrollment.Scope, serial string, expires time.Time) error
AdmitCertificate checks persisted identity and revocation in a tenant-local transaction. Explicit predicates remain mandatory for privileged DB callers.
func (*ConnectorEnrollmentStore) Consume ¶ added in v0.4.23
func (s *ConnectorEnrollmentStore) Consume(ctx context.Context, scope targetenrollment.Scope, tokenDigest, nonceDigest, csrDigest string, now time.Time) (targetenrollment.Grant, error)
func (*ConnectorEnrollmentStore) Create ¶ added in v0.4.23
func (s *ConnectorEnrollmentStore) Create(ctx context.Context, grant targetenrollment.Grant) error
func (*ConnectorEnrollmentStore) CreateRenewal ¶ added in v0.4.23
func (s *ConnectorEnrollmentStore) CreateRenewal(ctx context.Context, grant targetenrollment.Grant) error
CreateRenewal pins a one-use authorization to the currently active serial. A later revocation, scope change or competing replacement invalidates it.
func (*ConnectorEnrollmentStore) RecordIssued ¶ added in v0.4.23
func (s *ConnectorEnrollmentStore) RecordIssued(ctx context.Context, scope targetenrollment.Scope, tokenDigest, serial string, expires time.Time) error
RecordIssued commits the exact authenticated node identity before returning certificate material. Renewal additionally compares its authorized old serial and records one bounded predecessor in the same tenant-local transaction.
func (*ConnectorEnrollmentStore) RevokeCertificate ¶ added in v0.4.23
func (s *ConnectorEnrollmentStore) RevokeCertificate(ctx context.Context, scope targetenrollment.Scope, serial string) error
RevokeCertificate persists the admission denial before provider revocation. A provider outage must never make a retired node identity active again.
func (*ConnectorEnrollmentStore) RevokeCurrent ¶ added in v0.4.24
func (s *ConnectorEnrollmentStore) RevokeCurrent(ctx context.Context, scope targetenrollment.Scope) (string, error)
func (*ConnectorEnrollmentStore) Status ¶ added in v0.4.24
func (s *ConnectorEnrollmentStore) Status(ctx context.Context, scope targetenrollment.Scope) (targetenrollment.NodeStatus, error)
type IdentityTenantResolver ¶
type IdentityTenantResolver struct {
// contains filtered or unexported fields
}
IdentityTenantResolver resolves memberships for one verified external identity before a tenant scope exists. Access remains constrained by the identity-resolution RLS policy; no BYPASSRLS or superuser privilege is used.
func NewIdentityTenantResolver ¶
func NewIdentityTenantResolver(pool *pgxpool.Pool) *IdentityTenantResolver