aeat.application.auth package¶
Application auth facade for operator configuration and AEAT sessions.
This package owns the application-layer authentication contract used by
operator configuration, live-read preflight, and AEAT session acquisition.
AuthProvider and
AuthProviderKind define the provider protocol
and closed provider catalogue; select_provider()
delegates lazily to concrete outbound providers under
adapters.outbound.aeat.auth so application consumers keep one
stable facade without importing adapter mechanics at module load.
Operator-facing auth configuration stays in this layer.
configure_operator_auth(),
inspect_operator_auth(),
test_operator_auth(),
login_operator_auth(), and
clear_operator_auth() return typed result records
such as AuthStatusResult,
AuthLoginResult, and
LiveAuthPreflightReport. The persisted local
configuration is AuthState, while provider
metadata is reported through
AuthProviderDescription and
AuthProvidersReport. Configuration writes are
gated by application.workflow.ActiveProfileHealth: a missing,
dangling, or unreadable active bucket is refused before workflow state changes.
Successful provider configuration persists the updated
application.workflow.WorkflowState and the typed
AUTH_PROVIDER_CONFIGURED bucket event in one secure-object transaction;
the event payload may include a certificate path but never private keys,
passwords, session tokens, or QR payloads.
The session lifecycle is encrypted and profile-scoped.
ensure_authenticated_aeat_session() and
require_verified_aeat_session() coordinate
PersistedAuthSession reuse,
AuthAcquisitionLockRecord locking, and the provider’s
adapters.outbound.aeat.auth.AeatSession /
adapters.outbound.aeat.auth.AeatLoginAssertion pair. Live-read call
sites combine this facade with core.access_gate.AeatAccessGate;
this package does not expose AEAT-side write verbs. Session object keys are
derived from the active bucket through
storage_state_paths(), and operator verbs open an
active-profile storage span when the process has a selected pointer but no
ambient master-key session. Cl@ve Móvil session acquisition additionally fails
closed with AuthProfileIdentityMismatchError
when the configured identity, active profile tax id, or verified session
identity disagree.
Additional package-level surfaces cover local auth diagnostics and
apoderado configuration. AuthDiagnosticSummary,
AuthDiagnosticDetail, and
record_auth_diagnostic_phone_state() operate on redacted encrypted
diagnostic records. ApoderadoService
persists identity-sensitive represented-party configuration through encrypted
storage and permanently refuses live AEAT-side apoderamiento mutation.
See also
adapters.outbound.aeat.authConcrete certificate and Cl@ve Movil providers selected through this application facade.
core.access_gate.AeatAccessGateMandatory live-read precondition and permanent live-write refusal used before authenticated AEAT access proceeds.
application.state_projectionCanonical operator-state projection consumed by auth status, auth test, and live-auth preflight surfaces.
application.workflowPublic workflow facade that owns
application.workflow.WorkflowStateandapplication.workflow.ActiveProfileHealth.domain.buckets.BucketEventHistoryRepositoryDurable bucket event catalogue that receives auth configuration, session, lock, and clear events without secret payload material.
application.liveRead-only AEAT capture workflows that obtain verified sessions through this package.
domain.auth.apoderamientosDomain-owned scope catalogue consumed by
ApoderadoService.
- class AuthProviderKind(*values)[source]¶
Bases:
StrEnumClosed enumeration of supported AEAT authentication providers.
- Variables:
CERTIFICATE – PKCS#12 client certificate (FNMT-RCM and equivalents).
CLAVE_MOVIL – operator-mediated
Cl@veMóvil flow.CLAVE_PERMANENTE – DNI/NIE + password
Cl@vePermanente flow, used for AEAT read paths without an FNMT certificate or a phone.
- CERTIFICATE¶
- CLAVE_MOVIL¶
- CLAVE_PERMANENTE¶
- class AuthProviderDescription(**data)[source]¶
Bases:
BaseModelOperator-facing description of one configured auth provider.
- Variables:
kind – Identifier of the provider.
label – Human-readable provider name.
configured – Whether the provider’s required settings are present.
available – Whether a session can be established.
identity_nif – NIF resolved by the provider, when known.
subject – Subject DN or equivalent identity string.
expires_on – Expiry date for the underlying credential.
health_severity – Provider-specific health classification.
days_until_expiry – Convenience countdown to
expires_on.health_summary – Short human-readable diagnostic.
- Parameters:
- kind: AuthProviderKind¶
- label: str¶
- configured: bool¶
- available: bool¶
- identity_nif: str | None¶
- subject: str | None¶
- expires_on: date | None¶
- health_severity: str | None¶
- days_until_expiry: int | None¶
- health_summary: str | None¶
- class AuthProvider(*args, **kwargs)[source]¶
Bases:
ProtocolProtocol every concrete AEAT auth provider satisfies.
Implementations live under
adapters.outbound.aeat.authand are dispatched byselect_provider().-
kind:
AuthProviderKind¶
- async authenticate(*, browser_session=None, target_url=None)[source]¶
Establish an authenticated session and return the
AeatSessionrecord.- Return type:
- Parameters:
browser_session (BrowserSessionLike | None)
target_url (str | None)
- async verify(session, *, target_url=None)[source]¶
Re-probe
sessionagainsttarget_urland return theAeatLoginAssertionfor the provider.- Return type:
- Parameters:
session (AeatSession)
target_url (str | None)
- describe()[source]¶
Return a safe, log-friendly
AuthProviderDescriptionof the provider’s configured state.- Return type:
-
kind:
- select_provider(kind, *, settings, browser_session_factory=None)[source]¶
Return the concrete outbound auth provider for
kind.The application package owns the selection contract; the concrete implementations stay in the outbound adapter layer and are imported lazily to avoid an application/adapter import cycle at module load.
Returns an
AuthProviderconfigured for the requested provider kind.- Return type:
- Parameters:
kind (AuthProviderKind)
settings (Settings)
browser_session_factory (BrowserSessionFactory | None)
- describe_provider_operator_impact(description)[source]¶
Return a one-paragraph operator-facing summary of how
descriptionaffects the workflow.Used by
aeat config auth providersto render a human-readable diagnostic. The string focuses on what the operator can and cannot do given the current provider configuration; never contains secrets.- Return type:
- Parameters:
description (AuthProviderDescription)
Submodules¶
- aeat.application.auth._acquisition_lock module
- aeat.application.auth._actions module
- aeat.application.auth._apoderado module
- aeat.application.auth._catalogue module
- aeat.application.auth._certificate_secret_backend module
- aeat.application.auth._certificate_sources module
- aeat.application.auth._certificate_sources_operator module
register_operator_certificate_source()list_operator_certificate_sources()select_operator_certificate_source()remove_operator_certificate_source()check_operator_certificate_sources()resolve_certificate_source_secret()set_operator_certificate_source_secret()remove_operator_certificate_source_secret()
- aeat.application.auth._diagnostics module
AuthDiagnosticSummaryAuthDiagnosticSummary.diagnostic_idAuthDiagnosticSummary.reasonAuthDiagnosticSummary.urlAuthDiagnosticSummary.captured_atAuthDiagnosticSummary.html_capturedAuthDiagnosticSummary.screenshot_capturedAuthDiagnosticSummary.auth_modeAuthDiagnosticSummary.auth_routeAuthDiagnosticSummary.identity_kindAuthDiagnosticSummary.headlessAuthDiagnosticSummary.prefer_non_qrAuthDiagnosticSummary.timeout_msAuthDiagnosticSummary.route_labelAuthDiagnosticSummary.active_profile_idAuthDiagnosticSummary.active_profile_refAuthDiagnosticSummary.active_profile_labelAuthDiagnosticSummary.active_profile_label_presentAuthDiagnosticSummary.active_profile_registeredAuthDiagnosticSummary.profile_record_presentAuthDiagnosticSummary.profile_tax_id_presentAuthDiagnosticSummary.identity_alignmentAuthDiagnosticSummary.clave_identity_configuredAuthDiagnosticSummary.dni_fecha_configuredAuthDiagnosticSummary.nie_soporte_configuredAuthDiagnosticSummary.certificate_path_configuredAuthDiagnosticSummary.certificate_password_configuredAuthDiagnosticSummary.certificate_file_presentAuthDiagnosticSummary.certificate_backendAuthDiagnosticSummary.phone_stateAuthDiagnosticSummary.phone_state_reported_at
AuthDiagnosticListReportAuthDiagnosticDetailAuthDiagnosticDetail.html_excerptAuthDiagnosticDetail.profile_tax_id_fingerprintAuthDiagnosticDetail.clave_identity_fingerprintAuthDiagnosticDetail.dni_fecha_fingerprintAuthDiagnosticDetail.nie_soporte_fingerprintAuthDiagnosticDetail.certificate_path_fingerprintAuthDiagnosticDetail.operator_report_commands
AuthDiagnosticReportResultlist_auth_diagnostics()load_auth_diagnostic()record_auth_diagnostic_phone_state()
- aeat.application.auth._errors module
- aeat.application.auth._models module
- aeat.application.auth._operator module
- aeat.application.auth._operator_probes module
ProviderProbeResultProviderProbeResult.NO_PROVIDERProviderProbeResult.NO_PATH_SETProviderProbeResult.FILE_MISSINGProviderProbeResult.UNREADABLEProviderProbeResult.CORRUPTProviderProbeResult.EXPIREDProviderProbeResult.EXPIRINGProviderProbeResult.OKProviderProbeResult.IDENTITY_UNSETProviderProbeResult.INVALID_IDENTITY
ProviderConfigurationProbeprobe_provider_configuration()
- aeat.application.auth._operator_results module
AuthProviderReservedErrorAuthConfigureNoActiveBucketErrorAuthConfigureDanglingActiveProfileErrorAuthLoginNotEnabledErrorAuthLoginPreconditionErrorAuthProvidersReportAuthConfigureResultAuthConfigureResult.providerAuthConfigureResult.fileAuthConfigureResult.completeAuthConfigureResult.incomplete_reasonAuthConfigureResult.active_profileAuthConfigureResult.profile_tax_id_presentAuthConfigureResult.provider_identity_presentAuthConfigureResult.identity_alignmentAuthConfigureResult.identity_alignment_detailAuthConfigureResult.next_action
AuthStatusResultAuthStatusResult.providerAuthStatusResult.configuredAuthStatusResult.authenticatedAuthStatusResult.availableAuthStatusResult.active_profileAuthStatusResult.active_profile_statusAuthStatusResult.active_profile_registeredAuthStatusResult.active_profile_record_presentAuthStatusResult.active_profile_next_actionAuthStatusResult.backend_configuredAuthStatusResult.backend_availableAuthStatusResult.certificate_pathAuthStatusResult.health_severityAuthStatusResult.health_summary
AuthTestResultLiveAuthPreflightReportLiveAuthPreflightReport.providerLiveAuthPreflightReport.configuredLiveAuthPreflightReport.availableLiveAuthPreflightReport.active_profileLiveAuthPreflightReport.active_profile_statusLiveAuthPreflightReport.active_profile_registeredLiveAuthPreflightReport.active_profile_record_presentLiveAuthPreflightReport.profile_tax_id_presentLiveAuthPreflightReport.provider_identity_presentLiveAuthPreflightReport.identity_alignmentLiveAuthPreflightReport.identity_kindLiveAuthPreflightReport.auth_modeLiveAuthPreflightReport.prefer_non_qrLiveAuthPreflightReport.timeout_msLiveAuthPreflightReport.dni_fecha_configuredLiveAuthPreflightReport.nie_soporte_configuredLiveAuthPreflightReport.certificate_path_configuredLiveAuthPreflightReport.certificate_file_presentLiveAuthPreflightReport.certificate_backendLiveAuthPreflightReport.persisted_session_presentLiveAuthPreflightReport.persisted_session_expiredLiveAuthPreflightReport.persisted_session_stateLiveAuthPreflightReport.probe_result
AuthLoginResultAuthClearResultCertificateSourceNotFoundErrorCertificateSourcePayloadCertificateSourceListResultCertificateSourceMutationResultCertificateSourceCheckEntryCertificateSourceCheckReportCertificateSourceSecretMutationResult
- aeat.application.auth._operator_scope module
- aeat.application.auth._protocols module
- aeat.application.auth._sessions module
configure_session_store()StorageStatePathsCorruptAuthSessionErrorAuthSessionUnavailableErrorSessionDeserializationErrorAuthProfileIdentityMismatchErrorAuthenticatedAeatSessionResultAuthenticatedAeatSessionResult.provider_kindAuthenticatedAeatSessionResult.sessionAuthenticatedAeatSessionResult.assertionAuthenticatedAeatSessionResult.reused_persisted_sessionAuthenticatedAeatSessionResult.acquired_lockAuthenticatedAeatSessionResult.reset_lockAuthenticatedAeatSessionResult.removed_sessionsAuthenticatedAeatSessionResult.fresh
PersistedAuthSessionstorage_state_paths()load_persisted_session()delete_persisted_session()require_verified_aeat_session()ensure_authenticated_aeat_session()