Skip to content

API Reference parrot_formdesigner.services.sink_aliases

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot_formdesigner.services.sink_aliases

View source

Tenant-scoped connection-alias allowlist for submission sinks.

A form's persistence: block names a connection alias, never a raw DSN, path, or credential. This module is the operator-controlled allowlist that maps an alias -> a credential source, resolved through :func:parrot_formdesigner.core.auth._get_env (navconfig first, then os.environ). It is wired explicitly at app construction (an aiohttp app key — see TASK-2429) and is intentionally NOT runtime-mutable or DB-backed: it is a security control.

Class SinkAliasRegistry

Tenant-scoped allowlist mapping alias -> credential source.

Wired as an aiohttp app key in api/routes.py (spec section 8, resolved). Resolution delegates to :func:parrot_formdesigner.core.auth._get_env (navconfig, then os.environ); this registry never reads os.environ directly and never logs a resolved credential value.

Method SinkAliasRegistry.register

Register an alias for a tenant.

register(alias: str, *, tenant: str, dsn_env: str | None = None, base_dir: str | None = None, credentials_env: str | None = None) -> None

Parameter Type Default Description
alias str The connection alias name a FormSchema may reference.
tenant str Tenant this alias is scoped to.
dsn_env str | None None Name of the env var holding a DSN.
base_dir str | None None Base directory for a filesystem-backed alias.
credentials_env str | None None Name of the env var holding opaque credentials.

Method SinkAliasRegistry.is_allowed

Return whether alias is registered and scoped to tenant.

is_allowed(alias: str, *, tenant: str) -> bool

Parameter Type Default Description
alias str The connection alias to check.
tenant str The tenant requesting to use the alias.

Returns: bool — True if alias is registered under tenant, else False.

Method SinkAliasRegistry.resolve_dsn

Resolve the DSN for a registered database alias.

resolve_dsn(alias: str, *, tenant: str) -> str

Parameter Type Default Description
alias str The connection alias to resolve.
tenant str The tenant requesting to use the alias.

Returns: str — The resolved DSN string.

Raises:

  • ValueError — If the alias is unknown, cross-tenant, has no dsn_env configured, or the env var is unset.

Method SinkAliasRegistry.resolve_base_dir

Resolve the base directory for a registered filesystem alias.

resolve_base_dir(alias: str, *, tenant: str) -> Path

Parameter Type Default Description
alias str The connection alias to resolve.
tenant str The tenant requesting to use the alias.

Returns: Path — The alias's configured base directory as a Path.

Raises:

  • ValueError — If the alias is unknown, cross-tenant, or has no base_dir configured.

Method SinkAliasRegistry.resolve_credentials

Resolve opaque credentials for a registered alias.

resolve_credentials(alias: str, *, tenant: str) -> str

Parameter Type Default Description
alias str The connection alias to resolve.
tenant str The tenant requesting to use the alias.

Returns: str — The resolved credentials string (e.g. a path or JSON blob name).

Raises:

  • ValueError — If the alias is unknown, cross-tenant, has no credentials_env configured, or the env var is unset.

Method SinkAliasRegistry.contain

Resolve relative_path against the alias's base dir, safely.

Joins relative_path onto the alias's base directory and rejects any result whose resolved real path escapes that base directory (including via a symlink).

contain(alias: str, *, tenant: str, relative_path: str) -> Path

Parameter Type Default Description
alias str The filesystem-backed connection alias.
tenant str The tenant requesting to use the alias.
relative_path str Path relative to the alias's base directory.

Returns: Path — The resolved, contained absolute path.

Raises:

  • ValueError — If the alias is unknown/cross-tenant, or the resolved path escapes the base directory.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally