authpolicy

package
v2.3.0 Latest Latest
Warning

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

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

Documentation

Overview

Package authpolicy resolves effective static and database policy.

Index

Constants

This section is empty.

Variables

View Source
var ErrDenied = errors.New("auth denied")

ErrDenied marks a definitive, well-formed policy denial.

Functions

func IsIndeterminate

func IsIndeterminate(err error) bool

IsIndeterminate reports whether err is a retryable resolver failure.

Types

type CompiledBinding

type CompiledBinding struct {
	ID, Subject, DiagnosticKey string
	Groups                     []string
	Schema                     *jsonschema.Schema
}

CompiledBinding combines current identity output with an immutable effective schema.

type DynamicTrustRow

type DynamicTrustRow struct {
	ClientID, IssuerID, BindingID, Subject      string
	RequiredClaims, PolicyClaims, BindingClaims map[string]json.RawMessage
	Groups                                      []string
}

DynamicTrustRow is one strict trust_bindings query input.

type IndeterminateError

type IndeterminateError struct{ Err error }

IndeterminateError marks a resolver or malformed-result failure that callers may retry.

func (*IndeterminateError) Error

func (e *IndeterminateError) Error() string

Error returns a non-sensitive failure description.

func (*IndeterminateError) Unwrap

func (e *IndeterminateError) Unwrap() error

Unwrap returns the underlying resolver error.

type PostgreSQL

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

PostgreSQL resolves database policy and owns independent bounded caches.

func NewPostgreSQL

func NewPostgreSQL(ctx context.Context, connectionString string, cfg config.PolicyDatabaseConfig, issuers map[string]config.TrustIssuerConfig, logger *slog.Logger) (*PostgreSQL, error)

NewPostgreSQL validates the connection string and creates a dedicated pgx pool.

func (*PostgreSQL) ClientExists

func (r *PostgreSQL) ClientExists(ctx context.Context, clientID string) (bool, error)

ClientExists resolves and caches only definitive positive or negative existence results.

func (*PostgreSQL) Close

func (r *PostgreSQL) Close()

Close closes the dedicated PostgreSQL pool.

func (*PostgreSQL) CompileBindings

func (r *PostgreSQL) CompileBindings(clientID, issuerID string, rows []DynamicTrustRow) ([]CompiledBinding, error)

CompileBindings validates current dynamic rows and compiles or reuses immutable schemas.

func (*PostgreSQL) ResolveTrust

func (r *PostgreSQL) ResolveTrust(ctx context.Context, clientID, issuerID string) (bindings []CompiledBinding, finalErr error)

ResolveTrust queries strict rows and returns compiled current bindings.

func (*PostgreSQL) ResolveUser

func (r *PostgreSQL) ResolveUser(ctx context.Context, clientID, subject string, requireUserGroupsFromPolicy bool) (user ResolvedUser, finalErr error)

ResolveUser resolves a normalized subject and returns definitive groups or denial.

type ResolvedClient

type ResolvedClient struct {
	Config config.ClientConfig
	// contains filtered or unexported fields
}

ResolvedClient contains effective client policy and resolver-owned identity.

type ResolvedUser

type ResolvedUser struct{ Groups []string }

ResolvedUser contains the effective current groups for a user.

type Resolver

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

Resolver gives static clients deterministic precedence over database policy.

func NewResolver

func NewResolver(cfg *config.Config, policyDatabase *PostgreSQL) *Resolver

NewResolver combines static configuration with an optional policy database.

func (*Resolver) ResolveClient

func (r *Resolver) ResolveClient(ctx context.Context, clientID string, fresh bool) (ResolvedClient, error)

ResolveClient resolves effective policy for a client supplied by static or database policy. Fresh bypasses the existence cache for required pre-issuance checks.

func (*Resolver) ResolveTrust

func (r *Resolver) ResolveTrust(ctx context.Context, client ResolvedClient, issuerID string) ([]config.EffectiveTrustBinding, error)

ResolveTrust returns effective trust bindings without exposing their storage.

func (*Resolver) ResolveUser

func (r *Resolver) ResolveUser(ctx context.Context, client ResolvedClient, subject string) (ResolvedUser, error)

ResolveUser returns effective current user policy without exposing its storage.

Jump to

Keyboard shortcuts

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