cadrumo.application.auth.operator module¶
Operator-facing auth application services for the config CLI.
Auth configuration and login actions mutate
application.workflow.state_models.WorkflowState, validate the active bucket
through application.workflow.profile_health.assess_active_profile_health(), and
emit durable domain.buckets.event.BucketEvent records through
adapters.persistence.profile.buckets.BucketEventHistoryRepository.
Status, test, and preflight surfaces consume the canonical
application.state_projection.build_operator_state_projection()
producer, then narrow its
application.state_projection_auth.ProjectionAuthReadiness and
application.state_projection.ProjectionActiveProfile fields into
operator-facing result records.
See also
application.auth.models.AuthStateWorkflow-owned persisted authentication readiness.
application.auth.operator_results.AuthStatusResultCLI readiness result emitted by
auth status.application.auth.operator_results.AuthTestResultCLI readiness result emitted by
auth testwith local provider probes.application.auth.operator_results.LiveAuthPreflightReportRedacted readiness report used before a live read can request login.
- list_operator_auth_providers()[source]¶
Return the report enumerating executable authentication providers.
- Return type:
- configure_operator_auth(provider, *, certificate_path=None, operator_scope_ports, operation)[source]¶
Configure the active auth provider in workflow state.
The active profile is resolved through
application.workflow.profile_health.assess_active_profile_health()before theapplication.workflow.state_models.WorkflowStatemutation is written, so a dangling or unreadable active bucket cannot receive an auth selection. Persists the workflow-state update and a typedAUTH_PROVIDER_CONFIGUREDevent into the bucket-event-history catalogue in a single SQL transaction (viaadapters.persistence.storage.sql._secure_object_writes.SecureObjectWriteOperations.save_many()), so a crash between the two writes cannot leave the state mutated without the catalogue event landing. The certificate path is recorded as a payload value when supplied because it is a filesystem reference, not credential material; certificate passwords, private keys, and session tokens never enter the payload.- Parameters:
provider (
str) – The auth provider identifier to configure (e.g."certificate").certificate_path (
Path|None) – Optional filesystem path to the operator’s certificate file. Recorded in the event payload when supplied.operator_scope_ports (
OperatorScopePorts) – Caller-composed profile and auth storage scope.operation (
PinnedAuthorityOperation) – Caller-owned authority pin used for profile health.
- Return type:
- Returns:
An
AuthConfigureResultcarrying the updated workflow state.- Raises:
AuthConfigureNoActiveBucketError – When no active profile bucket exists yet. The operator must run
aeat config profile create NAMEfirst.AuthConfigureDanglingActiveProfileError – When the active-profile pointer does not resolve to a registered bucket.
See also
adapters.persistence.profile.buckets.BucketEventHistoryRepositoryDurable per-bucket event history that receives the typed auth event.
application.workflow.profile_health.ActiveProfileHealthRedacted health verdict used to accept or refuse the active bucket.
- inspect_operator_auth(provider=None, *, certificate_secret_backend_factory, operator_probe_ports, operator_scope_ports, read_ports, operation)[source]¶
Return current local auth state as
AuthStatusResult, optionally scoped to a known provider slot.Consumes the canonical
application.state_projection.build_operator_state_projection(). Theconfiguredfield is theapplication.state_projection_auth.ProjectionAuthReadinesssingle canonical operational-readiness definition;auth statusandauth testread the same datum and cannot disagree. The live backend is probed (via the projection) for theavailable/health_*fields, while the active-profile fields mirrorapplication.state_projection.ProjectionActiveProfile.- Return type:
- Parameters:
provider (str | None)
certificate_secret_backend_factory (CertificateSecretBackendFactory)
operator_probe_ports (OperatorProbePorts)
operator_scope_ports (OperatorScopePorts)
read_ports (StateProjectionReadPorts)
operation (PinnedAuthorityOperation)
- test_operator_auth(provider=None, *, certificate_secret_backend_factory, operator_probe_ports, operator_scope_ports, read_ports, operation, settings=None)[source]¶
Return auth readiness as
AuthTestResult, plus a deeper local session-token probe.auth testandauth status(inspect_operator_auth()) both consumebuild_operator_state_projection(), so they report the SAMEconfigured— the cross-surface disagreement is closed structurally. The live backend probe is kept (it is what the projection’sprobe_live_backendperforms) and feeds only the separateavailable/health_*fields; it never recomputesconfigured.On top of the shared readiness,
auth testperforms a local readiness probe thatauth statusdoes not: it inspects the encrypted AEAT session token persisted on disk for the probed provider and reports whether one is present and whether it is still within its idle deadline. This givesauth testan observable behaviour beyondauth status.When the operator passes
--providerthe requested provider is actively probed. When no provider is requested,auth testscopes the readiness to whatever provider is configured in workflow state; if none is configured it does NOT invent a default and probe it — that would letauth testreport a provideravailablewhileauth statusreports no provider at all. Both surfaces report the same “no provider configured” state on the same state.- Return type:
- Parameters:
provider (str | None)
certificate_secret_backend_factory (CertificateSecretBackendFactory)
operator_probe_ports (OperatorProbePorts)
operator_scope_ports (OperatorScopePorts)
read_ports (StateProjectionReadPorts)
operation (PinnedAuthorityOperation)
settings (Settings | None)
- build_live_auth_preflight_report(provider=None, *, certificate_secret_backend_factory, operator_probe_ports, operator_scope_ports, read_ports, operation, settings=None)[source]¶
Return a redacted preflight report before a live read may trigger auth.
Returns a
LiveAuthPreflightReportwith provider status, identity alignment, persisted-session indicators, and active-profile health fields inherited fromAuthTestResult.A locked store answers “not ready” rather than refusing to answer. The two ways this report can fail to reach a profile are not the same question. When a custody session is open for some OTHER profile, answering about the named one would be a claim about a profile that was never inspected, so the refusal stands. When NO session is open at all, the operator is asking whether auth is ready before unlocking anything – the locked workstation – and a readiness probe that declines to answer precisely then has no remaining purpose. Every field of
LiveAuthPreflightReportdefaults to empty or false because the type exists to carry that degraded answer.See also
core.access_gate.gate.AeatAccessGateLive-read gate evaluated before an authenticated AEAT operation can proceed.
test_operator_auth()Shared provider-readiness probe that supplies the preflight base.
- Return type:
- Parameters:
provider (str | None)
certificate_secret_backend_factory (CertificateSecretBackendFactory)
operator_probe_ports (OperatorProbePorts)
operator_scope_ports (OperatorScopePorts)
read_ports (StateProjectionReadPorts)
operation (PinnedAuthorityOperation)
settings (Settings | None)
- async login_operator_auth(provider=None, *, certificate_secret_backend_factory, browser_session_factory, operator_probe_ports, operator_scope_ports, fresh=False, reset_lock=False, settings=None, guarded_read_context=None)[source]¶
Acquire or verify a live AEAT session as
AuthLoginResult, and persist backend auth state.Refuses with a localised, user-prose message — never a raw env-var or class name — when a pytest live-read attempt is missing its live-test opt-in, or when the configured provider is locally incomplete (certificate path unset / file missing / unreadable). Round-5 B2.
See also
core.access_gate.gate.AeatAccessGateEnforces the live-read opt-in before provider authentication.
application.auth.sessions.ensure_authenticated_aeat_session()Provider-session lifecycle helper that returns the verified session result consumed here.
- Return type:
- Parameters:
provider (str | None)
certificate_secret_backend_factory (CertificateSecretBackendFactory)
browser_session_factory (BrowserSessionFactoryPort)
operator_probe_ports (OperatorProbePorts)
operator_scope_ports (OperatorScopePorts)
fresh (bool)
reset_lock (bool)
settings (Settings | None)
guarded_read_context (str | None)
- logout_operator_auth(*, certificate_secret_backend_factory, provider=None, all_providers=False, target_bucket_id=None, settings=None, operator_scope_ports)[source]¶
Terminate persisted sessions while preserving provider configuration.
- Return type:
- Parameters:
certificate_secret_backend_factory (CertificateSecretBackendFactory)
provider (str | None)
all_providers (bool)
target_bucket_id (str | None)
settings (Settings | None)
operator_scope_ports (OperatorScopePorts)
- reset_operator_auth(*, certificate_secret_backend_factory, provider=None, all_providers=False, target_bucket_id=None, settings=None, operator_scope_ports)[source]¶
Remove auth custody through one durable, resumable reset operation.
- Return type:
- Parameters:
certificate_secret_backend_factory (CertificateSecretBackendFactory)
provider (str | None)
all_providers (bool)
target_bucket_id (str | None)
settings (Settings | None)
operator_scope_ports (OperatorScopePorts)