aeat.application.auth._operator module¶
Operator-facing auth application services for the config CLI.
Auth configuration and login actions mutate
application.workflow.WorkflowState, validate the active bucket
through application.workflow.assess_active_profile_health(), and
emit durable domain.buckets.BucketEvent records through
domain.buckets.BucketEventHistoryRepository.
Status, test, and preflight surfaces consume the canonical
application.state_projection.build_operator_state_projection()
producer, then narrow its
application.state_projection.ProjectionAuthReadiness and
application.state_projection.ProjectionActiveProfile fields into
operator-facing result records.
See also
application.auth.AuthStatePersisted local auth selection embedded in workflow state.
application.auth.AuthStatusResultCLI readiness result emitted by
auth status.application.auth.AuthTestResultCLI readiness result emitted by
auth testwith local provider probes.application.auth.LiveAuthPreflightReportRedacted readiness report used before a live read can request login.
- list_operator_auth_providers()[source]¶
Return the
AuthProvidersReportenumerating implemented and reserved auth provider slots.- Return type:
- configure_operator_auth(provider, *, certificate_path=None)[source]¶
Configure the active auth provider in workflow state.
The active profile is resolved through
application.workflow.assess_active_profile_health()before theapplication.workflow.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.SecureObjectRepository.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:
- 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
domain.buckets.BucketEventHistoryRepositoryDurable per-bucket event history that receives the typed auth event.
application.workflow.ActiveProfileHealthRedacted health verdict used to accept or refuse the active bucket.
- inspect_operator_auth(provider=None)[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.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)
- test_operator_auth(provider=None, *, 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(persona-fleet finding G5).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:
- build_live_auth_preflight_report(provider=None, *, 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.See also
core.access_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:
- async login_operator_auth(provider=None, *, fresh=False, reset_lock=False, target_url=None, settings=None, pytest_current_test=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.AeatAccessGateEnforces the live-read opt-in before provider authentication.
application.auth.ensure_authenticated_aeat_session()Provider-session lifecycle helper that returns the verified session result consumed here.
- clear_operator_auth(*, provider=None, all_providers=False, sessions=False, locks=False, settings=None)[source]¶
Clear workflow auth state, persisted sessions, and acquisition locks.
Returns an
AuthClearResultafter resettingapplication.auth.AuthStateinapplication.workflow.WorkflowStatewhen the requested target matches the currently configured provider. Session and lock removals append bucket events through the same workflow-state event trail.