cadrumo.application.auth.apoderado_service module¶
Apoderado application service.
Operator verbs:
statusRead-only summary of the active apoderado configuration.
configureSet
--represented-nif NIF --scope SCOPE(repeated).clearRetire the apoderado configuration for the active bucket.
checkLive verification of the stored apoderamiento against the AEAT sede. The live-read path is not wired, so this verb refuses with
ApoderadoLiveCheckUnavailableError; usestatusfor the offline configuration read.
Configuration is persisted per-bucket through the application-owned configuration repository capability. The repository implementation is responsible for encryption and storage; the service never writes plaintext to disk. Live mutation of AEAT-side apoderamiento state (registrar, ampliar, revocar, confirmar, renunciar, presentar-en-representacion) is permanently refused at this boundary; the service has no verb that would write to AEAT.
- exception ApoderadoConfigurationNotSetError(message=None, *, context=None, translated_message=None)[source]¶
Bases:
CadrumoErrorRaised when status or check runs without a configured apoderado.
- Parameters:
- Return type:
None
- code¶
- exception ApoderadoRepresentedNifInvalidError(message=None, *, context=None, translated_message=None)[source]¶
Bases:
CadrumoErrorRaised when
configurereceives an invalid represented-party tax id.Both the flag-driven and the paged-flow transports commit through
ApoderadoService.configure(), which validates the represented party’s identifier through the canonicalcadrumo.domain.calculations.registry.tax_id_runtime.validate_runtime_identity()authority. The raised error carries NO raw identifier in its context – the value is identity-sensitive and must never leak into a diagnostic.- Parameters:
- Return type:
None
- code¶
Bases:
CadrumoErrorRaised when the live-read path is not yet wired or AEAT contact fails.
- Parameters:
- Return type:
None
- exception ApoderadoConfigurationIdentityError(message=None, *, context=None, translated_message=None)[source]¶
Bases:
CadrumoErrorRaised when a stored configuration does not belong to the key it sits under.
The persisted record key IS the bucket binding for this record: nothing else in the row asserts ownership. A configuration for bucket B placed under bucket A’s key would otherwise be returned by
status(bucket_id=A)and projected with B’s represented tax identifier – an identity-bearing cross-bucket leak that the key-only boundary cannot otherwise detect.The error carries no represented identifier: that value is identity-sensitive and must never reach a diagnostic.
- Parameters:
- Return type:
None
- code¶
- class ApoderadoConfiguration(**data)[source]¶
Bases:
BaseModelPersisted apoderado configuration for one bucket.
- Parameters:
data (Any)
- bucket_id: BucketId¶
- represented_nif: RepresentedNif¶
- granted_scopes: tuple[str, ...]¶
- catalogue_version: str¶
- configured_at: datetime¶
- notes: ApoderadoNotes¶
- class ApoderadoStatus(**data)[source]¶
Bases:
BaseModelRead-only status surface returned by
apoderado status.- Parameters:
data (Any)
- bucket_id: BucketId¶
- configured: bool¶
- represented_nif: str | None¶
- granted_scopes: tuple[str, ...]¶
- catalogue_version: str | None¶
- configured_at: datetime | None¶
- class ApoderadoService(*, repository_factory, operation, settings=None, catalogue=None)[source]¶
Bases:
objectLocal apoderado configuration management.
Live AEAT mutation is permanently refused at this boundary.
checkperforms read-only verification only; the actual remote contact is a sealed extension point.- Parameters:
repository_factory (ApoderadoConfigurationRepositoryFactory)
operation (PinnedAuthorityOperation)
settings (Settings | None)
catalogue (ApoderamientosCatalogue | None)
- property catalogue: ApoderamientosCatalogue¶
Return the AEAT apoderamiento scope
ApoderamientosCataloguein use by this service.
- status(*, bucket_id)[source]¶
Return the current
ApoderadoStatusforbucket_id.Reads the persisted
ApoderadoConfiguration(if any) and projects it into a read-only status record. Does not contact AEAT.- Parameters:
bucket_id (
str) – The profile bucket’s UUIDv4 identifier.- Return type:
- configure(*, bucket_id, represented_nif, scope_tokens, notes='')[source]¶
Persist apoderado config and return the resulting
ApoderadoConfiguration.Validates the represented party’s tax identifier through the authority-aware
cadrumo.domain.calculations.registry.tax_id_runtime.validate_runtime_identity()(the single validation law both the flag path and the paged flow commit through), then validates and dedups scopes against the catalogue.- Raises:
ApoderadoRepresentedNifInvalidError – When
represented_nifis not a valid NIF, NIE, or CIF.- Return type:
- Parameters:
- check(*, bucket_id)[source]¶
Read-only live verification (sealed pending live-read wiring).
checkis the live-verification verb: it would contact the AEAT sede to confirm the stored apoderamiento is still granted. That live-read path is not wired (live AEAT reads are refused at this boundary per the safety gate), socheckraisesApoderadoLiveCheckUnavailableErrorunconditionally rather than silently re-reading stored configuration and presenting it as a live result. Usestatusfor the offline configuration read.Returns the live
ApoderadoStatusonce the live-read path is wired; until then it raises.- Raises:
ApoderadoLiveCheckUnavailableError – always, until the live-read path is wired.
- Return type:
- Parameters:
bucket_id (str)