tba-storage-core 0.4.0.dev2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- tba_storage_core/__init__.py +25 -0
- tba_storage_core/components.py +35 -0
- tba_storage_core/framework.py +3 -0
- tba_storage_core/migrations/__init__.py +15 -0
- tba_storage_core/migrations/contract.py +74 -0
- tba_storage_core/migrations/env.py +7 -0
- tba_storage_core/migrations/helpers.py +219 -0
- tba_storage_core/migrations/versions/0001_initial_identity_tables.py +17 -0
- tba_storage_core/migrations/versions/0002_client_and_service_tables.py +23 -0
- tba_storage_core/migrations/versions/0003_authorization_runtime_tables.py +17 -0
- tba_storage_core/migrations/versions/0004_device_par_revocation_tables.py +17 -0
- tba_storage_core/migrations/versions/0005_session_logout_tables.py +17 -0
- tba_storage_core/migrations/versions/0006_key_rotation_and_audit_tables.py +17 -0
- tba_storage_core/migrations/versions/0007_browser_session_cookie_and_auth_code_linkage.py +50 -0
- tba_storage_core/migrations/versions/0008_refresh_token_family_state.py +44 -0
- tba_storage_core/migrations/versions/0009_admin_identity_bootstrap_and_password_recovery.py +48 -0
- tba_storage_core/migrations/versions/0010_realm_namespace_tables.py +33 -0
- tba_storage_core/migrations/versions/0011_delegation_grant_lifecycle_tables.py +39 -0
- tba_storage_core/migrations/versions/0012_key_version_and_token_provenance_tables.py +36 -0
- tba_storage_core/migrations/versions/0013_contract_durable_state_tables.py +59 -0
- tba_storage_core/migrations/versions/0014_optional_contract_state_tables.py +57 -0
- tba_storage_core/migrations/versions/0015_principal_identity_credential_tables.py +85 -0
- tba_storage_core/migrations/versions/0016_crypto_key_storage_tables.py +84 -0
- tba_storage_core/migrations/versions/0017_authorization_server_table.py +21 -0
- tba_storage_core/migrations/versions/0018_policy_tables.py +27 -0
- tba_storage_core/migrations/versions/0019_federation_and_invariant_tables.py +35 -0
- tba_storage_core/migrations/versions/0020_backchannel_logout_replay_table.py +21 -0
- tba_storage_core/migrations/versions/0021_authentication_challenge_table.py +21 -0
- tba_storage_core/migrations/versions/0022_authority_and_trust_graph_tables.py +35 -0
- tba_storage_core/migrations/versions/0023_artifact_and_token_profile_discriminators.py +65 -0
- tba_storage_core/migrations/versions/0024_credential_issuer_wallet_and_configuration.py +32 -0
- tba_storage_core/migrations/versions/0025_credential_issuance_and_status.py +34 -0
- tba_storage_core/migrations/versions/0026_presentation_transaction_and_replay.py +28 -0
- tba_storage_core/migrations/versions/0027_attestation_and_reference_material.py +32 -0
- tba_storage_core/migrations/versions/0028_spiffe_svid_and_trust_bundles.py +22 -0
- tba_storage_core/migrations/versions/0029_security_event_delivery.py +28 -0
- tba_storage_core/migrations/versions/0030_optional_did_and_gnap_state.py +37 -0
- tba_storage_core/migrations/versions/0031_certificate_trust_and_status.py +22 -0
- tba_storage_core/migrations/versions/0032_claim_definition_and_provenance.py +30 -0
- tba_storage_core/migrations/versions/0033_replay_reservations.py +18 -0
- tba_storage_core/migrations/versions/0034_dpop_replay_nonce_tables.py +21 -0
- tba_storage_core/migrations/versions/0035_webauthn_rp_ceremony_and_credentials.py +76 -0
- tba_storage_core/migrations/versions/0036_workload_credentials_artifacts_and_proof_replay.py +27 -0
- tba_storage_core/migrations/versions/0037_operator_tables.py +30 -0
- tba_storage_core/migrations/versions/0038_adopt_component_ownership.py +66 -0
- tba_storage_core/migrations/versions/0039_normalized_platform_iam.py +17 -0
- tba_storage_core/py.typed +0 -0
- tba_storage_core/storage.lock.toml +211 -0
- tba_storage_core/storage.toml +34 -0
- tba_storage_core/tables/__init__.py +179 -0
- tba_storage_core/tables/_graph_base.py +53 -0
- tba_storage_core/tables/_registry.py +200 -0
- tba_storage_core/tables/access_review_campaign/__init__.py +9 -0
- tba_storage_core/tables/access_review_campaign/_table.py +25 -0
- tba_storage_core/tables/access_review_decision/__init__.py +9 -0
- tba_storage_core/tables/access_review_decision/_table.py +27 -0
- tba_storage_core/tables/access_review_item/__init__.py +9 -0
- tba_storage_core/tables/access_review_item/_table.py +26 -0
- tba_storage_core/tables/attestation_appraisal_policy/__init__.py +3 -0
- tba_storage_core/tables/attestation_endorsement/__init__.py +3 -0
- tba_storage_core/tables/attestation_evidence/__init__.py +3 -0
- tba_storage_core/tables/attestation_reference_manifest/__init__.py +3 -0
- tba_storage_core/tables/attestation_reference_value/__init__.py +3 -0
- tba_storage_core/tables/attestation_result/__init__.py +3 -0
- tba_storage_core/tables/attestation_state.py +124 -0
- tba_storage_core/tables/attribute_policy/__init__.py +9 -0
- tba_storage_core/tables/attribute_policy/_table.py +40 -0
- tba_storage_core/tables/audit_event/__init__.py +10 -0
- tba_storage_core/tables/audit_event/_table.py +47 -0
- tba_storage_core/tables/auth_code/__init__.py +13 -0
- tba_storage_core/tables/auth_code/_table.py +41 -0
- tba_storage_core/tables/auth_session/__init__.py +13 -0
- tba_storage_core/tables/auth_session/_table.py +45 -0
- tba_storage_core/tables/authentication_challenge/__init__.py +7 -0
- tba_storage_core/tables/authentication_challenge/_table.py +38 -0
- tba_storage_core/tables/authority_derivation_graph/__init__.py +15 -0
- tba_storage_core/tables/authority_derivation_graph/_table.py +94 -0
- tba_storage_core/tables/authorization_invariant/__init__.py +5 -0
- tba_storage_core/tables/authorization_invariant/_table.py +34 -0
- tba_storage_core/tables/authorization_server/__init__.py +6 -0
- tba_storage_core/tables/authorization_server/_table.py +61 -0
- tba_storage_core/tables/authz_verification_report/__init__.py +9 -0
- tba_storage_core/tables/authz_verification_report/_table.py +29 -0
- tba_storage_core/tables/backchannel_logout_replay/__init__.py +5 -0
- tba_storage_core/tables/backchannel_logout_replay/_table.py +37 -0
- tba_storage_core/tables/certificate_record/__init__.py +3 -0
- tba_storage_core/tables/certificate_state.py +82 -0
- tba_storage_core/tables/certificate_status_snapshot/__init__.py +3 -0
- tba_storage_core/tables/claim_state.py +98 -0
- tba_storage_core/tables/client/__init__.py +9 -0
- tba_storage_core/tables/client/_table.py +41 -0
- tba_storage_core/tables/client_registration/__init__.py +10 -0
- tba_storage_core/tables/client_registration/_table.py +47 -0
- tba_storage_core/tables/consent/__init__.py +13 -0
- tba_storage_core/tables/consent/_table.py +57 -0
- tba_storage_core/tables/control_correctness_report/__init__.py +9 -0
- tba_storage_core/tables/control_correctness_report/_table.py +20 -0
- tba_storage_core/tables/credential/__init__.py +9 -0
- tba_storage_core/tables/credential/_table.py +74 -0
- tba_storage_core/tables/credential_api_key/__init__.py +9 -0
- tba_storage_core/tables/credential_api_key/_table.py +50 -0
- tba_storage_core/tables/credential_audit_event/__init__.py +9 -0
- tba_storage_core/tables/credential_audit_event/_table.py +25 -0
- tba_storage_core/tables/credential_client_secret/__init__.py +9 -0
- tba_storage_core/tables/credential_client_secret/_table.py +24 -0
- tba_storage_core/tables/credential_configuration/__init__.py +3 -0
- tba_storage_core/tables/credential_deferred_transaction/__init__.py +3 -0
- tba_storage_core/tables/credential_dpop_key/__init__.py +9 -0
- tba_storage_core/tables/credential_dpop_key/_table.py +22 -0
- tba_storage_core/tables/credential_ecosystem_registry.py +119 -0
- tba_storage_core/tables/credential_issuance_state.py +154 -0
- tba_storage_core/tables/credential_issuance_transaction/__init__.py +3 -0
- tba_storage_core/tables/credential_issuer/__init__.py +3 -0
- tba_storage_core/tables/credential_mfa_factor/__init__.py +9 -0
- tba_storage_core/tables/credential_mfa_factor/_table.py +24 -0
- tba_storage_core/tables/credential_mtls_certificate/__init__.py +9 -0
- tba_storage_core/tables/credential_mtls_certificate/_table.py +26 -0
- tba_storage_core/tables/credential_notification/__init__.py +3 -0
- tba_storage_core/tables/credential_offer/__init__.py +3 -0
- tba_storage_core/tables/credential_password/__init__.py +9 -0
- tba_storage_core/tables/credential_password/_table.py +24 -0
- tba_storage_core/tables/credential_recovery_code/__init__.py +9 -0
- tba_storage_core/tables/credential_recovery_code/_table.py +23 -0
- tba_storage_core/tables/credential_service_key/__init__.py +9 -0
- tba_storage_core/tables/credential_service_key/_table.py +49 -0
- tba_storage_core/tables/credential_status_entry/__init__.py +3 -0
- tba_storage_core/tables/credential_status_list/__init__.py +3 -0
- tba_storage_core/tables/credential_status_publication/__init__.py +3 -0
- tba_storage_core/tables/credential_webauthn_passkey/__init__.py +9 -0
- tba_storage_core/tables/credential_webauthn_passkey/_table.py +42 -0
- tba_storage_core/tables/crypto_key/__init__.py +13 -0
- tba_storage_core/tables/crypto_key/_table.py +52 -0
- tba_storage_core/tables/crypto_key_version/__init__.py +13 -0
- tba_storage_core/tables/crypto_key_version/_table.py +53 -0
- tba_storage_core/tables/delegated_admin_scope/__init__.py +9 -0
- tba_storage_core/tables/delegated_admin_scope/_table.py +34 -0
- tba_storage_core/tables/delegation_grant/__init__.py +13 -0
- tba_storage_core/tables/delegation_grant/_table.py +134 -0
- tba_storage_core/tables/device_code/__init__.py +13 -0
- tba_storage_core/tables/device_code/_table.py +54 -0
- tba_storage_core/tables/did_document/__init__.py +3 -0
- tba_storage_core/tables/did_document_version/__init__.py +3 -0
- tba_storage_core/tables/did_gnap_state.py +169 -0
- tba_storage_core/tables/did_resolution_cache/__init__.py +3 -0
- tba_storage_core/tables/did_service/__init__.py +3 -0
- tba_storage_core/tables/did_verification_method/__init__.py +3 -0
- tba_storage_core/tables/dpop_nonce/__init__.py +5 -0
- tba_storage_core/tables/dpop_nonce/_table.py +77 -0
- tba_storage_core/tables/dpop_replay/__init__.py +5 -0
- tba_storage_core/tables/dpop_replay/_table.py +97 -0
- tba_storage_core/tables/entitlement/__init__.py +9 -0
- tba_storage_core/tables/entitlement/_table.py +22 -0
- tba_storage_core/tables/entitlement_assignment/__init__.py +9 -0
- tba_storage_core/tables/entitlement_assignment/_table.py +26 -0
- tba_storage_core/tables/federated_session/__init__.py +5 -0
- tba_storage_core/tables/federated_session/_table.py +32 -0
- tba_storage_core/tables/federation/__init__.py +5 -0
- tba_storage_core/tables/federation/_table.py +37 -0
- tba_storage_core/tables/gnap_client_instance/__init__.py +3 -0
- tba_storage_core/tables/gnap_continuation/__init__.py +3 -0
- tba_storage_core/tables/gnap_grant/__init__.py +3 -0
- tba_storage_core/tables/gnap_interaction/__init__.py +3 -0
- tba_storage_core/tables/identity_provider/__init__.py +5 -0
- tba_storage_core/tables/identity_provider/_table.py +37 -0
- tba_storage_core/tables/invariant_evaluation/__init__.py +5 -0
- tba_storage_core/tables/invariant_evaluation/_table.py +29 -0
- tba_storage_core/tables/invariant_violation/__init__.py +5 -0
- tba_storage_core/tables/invariant_violation/_table.py +27 -0
- tba_storage_core/tables/key_attestation_evidence/__init__.py +13 -0
- tba_storage_core/tables/key_attestation_evidence/_table.py +99 -0
- tba_storage_core/tables/key_envelope/__init__.py +13 -0
- tba_storage_core/tables/key_envelope/_table.py +54 -0
- tba_storage_core/tables/key_rotation_event/__init__.py +9 -0
- tba_storage_core/tables/key_rotation_event/_table.py +44 -0
- tba_storage_core/tables/key_rotation_policy/__init__.py +9 -0
- tba_storage_core/tables/key_rotation_policy/_table.py +38 -0
- tba_storage_core/tables/logout_state/__init__.py +10 -0
- tba_storage_core/tables/logout_state/_table.py +67 -0
- tba_storage_core/tables/machine_identity/__init__.py +9 -0
- tba_storage_core/tables/machine_identity/_table.py +49 -0
- tba_storage_core/tables/operator_activity/__init__.py +9 -0
- tba_storage_core/tables/operator_activity/_table.py +29 -0
- tba_storage_core/tables/operator_audit_event/__init__.py +9 -0
- tba_storage_core/tables/operator_audit_event/_table.py +29 -0
- tba_storage_core/tables/operator_metadata/__init__.py +9 -0
- tba_storage_core/tables/operator_metadata/_table.py +19 -0
- tba_storage_core/tables/operator_record/__init__.py +9 -0
- tba_storage_core/tables/operator_record/_table.py +44 -0
- tba_storage_core/tables/operator_transaction/__init__.py +9 -0
- tba_storage_core/tables/operator_transaction/_table.py +33 -0
- tba_storage_core/tables/plugin_descriptor/__init__.py +9 -0
- tba_storage_core/tables/plugin_descriptor/_table.py +23 -0
- tba_storage_core/tables/plugin_lifecycle_event/__init__.py +9 -0
- tba_storage_core/tables/plugin_lifecycle_event/_table.py +22 -0
- tba_storage_core/tables/policy/__init__.py +5 -0
- tba_storage_core/tables/policy/_table.py +30 -0
- tba_storage_core/tables/policy_condition/__init__.py +9 -0
- tba_storage_core/tables/policy_condition/_table.py +21 -0
- tba_storage_core/tables/policy_set/__init__.py +5 -0
- tba_storage_core/tables/policy_set/_table.py +33 -0
- tba_storage_core/tables/policy_set_member/__init__.py +5 -0
- tba_storage_core/tables/policy_set_member/_table.py +32 -0
- tba_storage_core/tables/policy_target/__init__.py +5 -0
- tba_storage_core/tables/policy_target/_table.py +36 -0
- tba_storage_core/tables/policy_version/__init__.py +5 -0
- tba_storage_core/tables/policy_version/_table.py +35 -0
- tba_storage_core/tables/presentation_consent/__init__.py +3 -0
- tba_storage_core/tables/presentation_replay/__init__.py +3 -0
- tba_storage_core/tables/presentation_state.py +98 -0
- tba_storage_core/tables/presentation_transaction/__init__.py +3 -0
- tba_storage_core/tables/principal/__init__.py +9 -0
- tba_storage_core/tables/principal/_table.py +49 -0
- tba_storage_core/tables/principal_key_binding/__init__.py +13 -0
- tba_storage_core/tables/principal_key_binding/_table.py +48 -0
- tba_storage_core/tables/provider_artifact/__init__.py +9 -0
- tba_storage_core/tables/provider_artifact/_table.py +22 -0
- tba_storage_core/tables/pushed_authorization_request/__init__.py +13 -0
- tba_storage_core/tables/pushed_authorization_request/_table.py +59 -0
- tba_storage_core/tables/realm/__init__.py +13 -0
- tba_storage_core/tables/realm/_table.py +87 -0
- tba_storage_core/tables/release_attestation_event/__init__.py +9 -0
- tba_storage_core/tables/release_attestation_event/_table.py +21 -0
- tba_storage_core/tables/release_authorization_state/__init__.py +9 -0
- tba_storage_core/tables/release_authorization_state/_table.py +21 -0
- tba_storage_core/tables/release_capability_record/__init__.py +9 -0
- tba_storage_core/tables/release_capability_record/_table.py +21 -0
- tba_storage_core/tables/release_posture/__init__.py +9 -0
- tba_storage_core/tables/release_posture/_table.py +21 -0
- tba_storage_core/tables/release_security_posture/__init__.py +9 -0
- tba_storage_core/tables/release_security_posture/_table.py +22 -0
- tba_storage_core/tables/replay_reservation.py +34 -0
- tba_storage_core/tables/residency_zone/__init__.py +9 -0
- tba_storage_core/tables/residency_zone/_table.py +20 -0
- tba_storage_core/tables/resource_server_contract/__init__.py +9 -0
- tba_storage_core/tables/resource_server_contract/_table.py +21 -0
- tba_storage_core/tables/revoked_token/__init__.py +13 -0
- tba_storage_core/tables/revoked_token/_table.py +39 -0
- tba_storage_core/tables/role/__init__.py +9 -0
- tba_storage_core/tables/role/_table.py +22 -0
- tba_storage_core/tables/runtime_qualification/__init__.py +9 -0
- tba_storage_core/tables/runtime_qualification/_table.py +21 -0
- tba_storage_core/tables/scim_group/__init__.py +9 -0
- tba_storage_core/tables/scim_group/_table.py +21 -0
- tba_storage_core/tables/scim_patch_event/__init__.py +9 -0
- tba_storage_core/tables/scim_patch_event/_table.py +22 -0
- tba_storage_core/tables/scim_schema/__init__.py +9 -0
- tba_storage_core/tables/scim_schema/_table.py +21 -0
- tba_storage_core/tables/scim_user/__init__.py +9 -0
- tba_storage_core/tables/scim_user/_table.py +21 -0
- tba_storage_core/tables/sdk_package/__init__.py +9 -0
- tba_storage_core/tables/sdk_package/_table.py +23 -0
- tba_storage_core/tables/security_event/__init__.py +3 -0
- tba_storage_core/tables/security_event_delivery/__init__.py +3 -0
- tba_storage_core/tables/security_event_replay/__init__.py +3 -0
- tba_storage_core/tables/security_event_state.py +100 -0
- tba_storage_core/tables/security_event_subscription/__init__.py +3 -0
- tba_storage_core/tables/service_identity/__init__.py +9 -0
- tba_storage_core/tables/service_identity/_table.py +47 -0
- tba_storage_core/tables/spiffe_state.py +83 -0
- tba_storage_core/tables/spiffe_trust_bundle/__init__.py +3 -0
- tba_storage_core/tables/subject_alias/__init__.py +9 -0
- tba_storage_core/tables/subject_alias/_table.py +21 -0
- tba_storage_core/tables/svid_record/__init__.py +3 -0
- tba_storage_core/tables/tenant/__init__.py +13 -0
- tba_storage_core/tables/tenant/_table.py +83 -0
- tba_storage_core/tables/tenant_membership/__init__.py +9 -0
- tba_storage_core/tables/tenant_membership/_table.py +28 -0
- tba_storage_core/tables/tenant_residency/__init__.py +9 -0
- tba_storage_core/tables/tenant_residency/_table.py +23 -0
- tba_storage_core/tables/token_record/__init__.py +10 -0
- tba_storage_core/tables/token_record/_table.py +123 -0
- tba_storage_core/tables/trust_anchor/__init__.py +3 -0
- tba_storage_core/tables/trust_domain_federation/__init__.py +3 -0
- tba_storage_core/tables/trust_federation_graph/__init__.py +15 -0
- tba_storage_core/tables/trust_federation_graph/_table.py +94 -0
- tba_storage_core/tables/user/__init__.py +13 -0
- tba_storage_core/tables/user/_table.py +127 -0
- tba_storage_core/tables/verifier_registration/__init__.py +3 -0
- tba_storage_core/tables/wallet_attestation/__init__.py +3 -0
- tba_storage_core/tables/wallet_instance/__init__.py +3 -0
- tba_storage_core/tables/wallet_key_binding/__init__.py +3 -0
- tba_storage_core/tables/wallet_registration/__init__.py +3 -0
- tba_storage_core/tables/webauthn_attestation_record/__init__.py +3 -0
- tba_storage_core/tables/webauthn_attestation_record/_table.py +28 -0
- tba_storage_core/tables/webauthn_ceremony/__init__.py +3 -0
- tba_storage_core/tables/webauthn_ceremony/_table.py +43 -0
- tba_storage_core/tables/webauthn_relying_party/__init__.py +3 -0
- tba_storage_core/tables/webauthn_relying_party/_table.py +24 -0
- tba_storage_core/tables/workload_credential_state.py +57 -0
- tba_storage_core/tables/workload_identity/__init__.py +9 -0
- tba_storage_core/tables/workload_identity/_table.py +89 -0
- tba_storage_core-0.4.0.dev2.dist-info/METADATA +126 -0
- tba_storage_core-0.4.0.dev2.dist-info/RECORD +294 -0
- tba_storage_core-0.4.0.dev2.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from . import _table as _table
|
|
4
|
+
from ._table import *
|
|
5
|
+
|
|
6
|
+
for _name in dir(_table):
|
|
7
|
+
if not _name.startswith("__"):
|
|
8
|
+
globals().setdefault(_name, getattr(_table, _name))
|
|
9
|
+
|
|
10
|
+
try:
|
|
11
|
+
__all__ = list(_table.__all__)
|
|
12
|
+
except AttributeError:
|
|
13
|
+
__all__ = [name for name in globals() if not name.startswith("_")]
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"""Durable provider-neutral crypto key version metadata."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import datetime as dt
|
|
6
|
+
import uuid
|
|
7
|
+
from typing import Any
|
|
8
|
+
|
|
9
|
+
from tba_storage_core.framework import (
|
|
10
|
+
ForeignKeySpec,
|
|
11
|
+
GUIDPk,
|
|
12
|
+
Integer,
|
|
13
|
+
JSON,
|
|
14
|
+
Mapped,
|
|
15
|
+
PgUUID,
|
|
16
|
+
RestOltpTable,
|
|
17
|
+
S,
|
|
18
|
+
String,
|
|
19
|
+
TZDateTime,
|
|
20
|
+
Timestamped,
|
|
21
|
+
acol,
|
|
22
|
+
)
|
|
23
|
+
from tba_contracts_security_trust import normalize_key_operations
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def _operation_list(values: Any) -> list[str]:
|
|
28
|
+
return [operation.value for operation in normalize_key_operations(values)]
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class CryptoKeyVersion(RestOltpTable, GUIDPk, Timestamped):
|
|
32
|
+
__tablename__ = "crypto_key_versions"
|
|
33
|
+
__table_args__ = ({"schema": "authn"},)
|
|
34
|
+
|
|
35
|
+
key_id: Mapped[uuid.UUID] = acol(
|
|
36
|
+
storage=S(PgUUID(as_uuid=True), fk=ForeignKeySpec(target="authn.crypto_keys.id"), nullable=False, index=True)
|
|
37
|
+
)
|
|
38
|
+
version: Mapped[int] = acol(storage=S(Integer, nullable=False, default=1))
|
|
39
|
+
status: Mapped[str] = acol(storage=S(String(32), nullable=False, default="active", index=True))
|
|
40
|
+
provider: Mapped[str | None] = acol(storage=S(String(255), nullable=True, index=True))
|
|
41
|
+
provider_key_ref: Mapped[str | None] = acol(storage=S(String(1000), nullable=True))
|
|
42
|
+
allowed_ops: Mapped[list[str] | None] = acol(storage=S(JSON, nullable=True))
|
|
43
|
+
public_material_format: Mapped[str | None] = acol(storage=S(String(64), nullable=True))
|
|
44
|
+
public_material: Mapped[dict | str | None] = acol(storage=S(JSON, nullable=True))
|
|
45
|
+
fingerprint: Mapped[str | None] = acol(storage=S(String(255), nullable=True, index=True))
|
|
46
|
+
not_before: Mapped[dt.datetime | None] = acol(storage=S(TZDateTime, nullable=True, index=True))
|
|
47
|
+
not_after: Mapped[dt.datetime | None] = acol(storage=S(TZDateTime, nullable=True, index=True))
|
|
48
|
+
activated_at: Mapped[dt.datetime | None] = acol(storage=S(TZDateTime, nullable=True, index=True))
|
|
49
|
+
retired_at: Mapped[dt.datetime | None] = acol(storage=S(TZDateTime, nullable=True, index=True))
|
|
50
|
+
version_metadata: Mapped[dict | None] = acol(storage=S(JSON, nullable=True))
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
__all__ = ["CryptoKeyVersion"]
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"""Durable delegated administration scopes."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
from tba_storage_core.framework import (
|
|
7
|
+
RestOltpTable,
|
|
8
|
+
GUIDPk,
|
|
9
|
+
JSON,
|
|
10
|
+
Mapped,
|
|
11
|
+
S,
|
|
12
|
+
String,
|
|
13
|
+
Timestamped,
|
|
14
|
+
acol,
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class DelegatedAdminScope(RestOltpTable, GUIDPk, Timestamped):
|
|
19
|
+
__tablename__ = "delegated_admin_scopes"
|
|
20
|
+
__table_args__ = ({"schema": "authn"},)
|
|
21
|
+
|
|
22
|
+
subject: Mapped[str] = acol(storage=S(String(255), nullable=False, index=True))
|
|
23
|
+
tenant_ids: Mapped[list] = acol(storage=S(JSON, nullable=False, default=list))
|
|
24
|
+
permissions: Mapped[list] = acol(storage=S(JSON, nullable=False, default=list))
|
|
25
|
+
visible_client_fields: Mapped[list | None] = acol(storage=S(JSON, nullable=True))
|
|
26
|
+
mutable_client_fields: Mapped[list | None] = acol(storage=S(JSON, nullable=True))
|
|
27
|
+
service_identity_permissions: Mapped[list | None] = acol(
|
|
28
|
+
storage=S(JSON, nullable=True)
|
|
29
|
+
)
|
|
30
|
+
status: Mapped[str] = acol(
|
|
31
|
+
storage=S(String(32), nullable=False, default="active", index=True)
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
__all__ = ["DelegatedAdminScope"]
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from . import _table as _table
|
|
4
|
+
from ._table import *
|
|
5
|
+
|
|
6
|
+
for _name in dir(_table):
|
|
7
|
+
if not _name.startswith("__"):
|
|
8
|
+
globals().setdefault(_name, getattr(_table, _name))
|
|
9
|
+
|
|
10
|
+
try:
|
|
11
|
+
__all__ = list(_table.__all__)
|
|
12
|
+
except AttributeError:
|
|
13
|
+
__all__ = [name for name in globals() if not name.startswith("_")]
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"""Canonical persisted DelegationGrant lifecycle tables."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import datetime as dt
|
|
6
|
+
import uuid
|
|
7
|
+
|
|
8
|
+
from tba_storage_core.framework import (
|
|
9
|
+
RestOltpTable,
|
|
10
|
+
Boolean,
|
|
11
|
+
ForeignKeySpec,
|
|
12
|
+
GUIDPk,
|
|
13
|
+
JSON,
|
|
14
|
+
Mapped,
|
|
15
|
+
PgUUID,
|
|
16
|
+
S,
|
|
17
|
+
String,
|
|
18
|
+
TZDateTime,
|
|
19
|
+
Timestamped,
|
|
20
|
+
acol,
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class DelegationGrant(RestOltpTable, GUIDPk, Timestamped):
|
|
25
|
+
__tablename__ = "delegation_grants"
|
|
26
|
+
__table_args__ = ({"schema": "authn"},)
|
|
27
|
+
|
|
28
|
+
tenant_id: Mapped[uuid.UUID | None] = acol(
|
|
29
|
+
storage=S(PgUUID(as_uuid=True), fk=ForeignKeySpec(target="authn.tenants.id"), nullable=True, index=True)
|
|
30
|
+
)
|
|
31
|
+
realm: Mapped[str] = acol(storage=S(String(120), nullable=False, default=""))
|
|
32
|
+
delegator_subject: Mapped[str] = acol(storage=S(String(255), nullable=False, index=True))
|
|
33
|
+
delegate_subject: Mapped[str] = acol(storage=S(String(255), nullable=False, index=True))
|
|
34
|
+
delegate_type: Mapped[str] = acol(storage=S(String(64), nullable=False, default="subject"))
|
|
35
|
+
status: Mapped[str] = acol(storage=S(String(32), nullable=False, index=True, default="draft"))
|
|
36
|
+
parent_grant_id: Mapped[uuid.UUID | None] = acol(
|
|
37
|
+
storage=S(PgUUID(as_uuid=True), fk=ForeignKeySpec(target="authn.delegation_grants.id"), nullable=True, index=True)
|
|
38
|
+
)
|
|
39
|
+
source_authority_ref: Mapped[str | None] = acol(storage=S(String(255), nullable=True))
|
|
40
|
+
policy_version: Mapped[str | None] = acol(storage=S(String(128), nullable=True))
|
|
41
|
+
provenance_id: Mapped[str | None] = acol(storage=S(String(128), nullable=True, index=True))
|
|
42
|
+
constraints: Mapped[dict | None] = acol(storage=S(JSON, nullable=True))
|
|
43
|
+
effective_at: Mapped[dt.datetime | None] = acol(storage=S(TZDateTime, nullable=True, index=True))
|
|
44
|
+
expires_at: Mapped[dt.datetime | None] = acol(storage=S(TZDateTime, nullable=True, index=True))
|
|
45
|
+
revoked_at: Mapped[dt.datetime | None] = acol(storage=S(TZDateTime, nullable=True, index=True))
|
|
46
|
+
revoked_by: Mapped[str | None] = acol(storage=S(String(255), nullable=True))
|
|
47
|
+
revoked_reason: Mapped[str | None] = acol(storage=S(String(255), nullable=True))
|
|
48
|
+
replaced_by_grant_id: Mapped[uuid.UUID | None] = acol(
|
|
49
|
+
storage=S(PgUUID(as_uuid=True), fk=ForeignKeySpec(target="authn.delegation_grants.id"), nullable=True)
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
class DelegationGrantScope(RestOltpTable, GUIDPk, Timestamped):
|
|
54
|
+
__tablename__ = "delegation_grant_scopes"
|
|
55
|
+
__table_args__ = ({"schema": "authn"},)
|
|
56
|
+
|
|
57
|
+
grant_id: Mapped[uuid.UUID] = acol(
|
|
58
|
+
storage=S(PgUUID(as_uuid=True), fk=ForeignKeySpec(target="authn.delegation_grants.id"), nullable=False, index=True)
|
|
59
|
+
)
|
|
60
|
+
tenant_id: Mapped[str] = acol(storage=S(String(255), nullable=False, index=True))
|
|
61
|
+
realm: Mapped[str] = acol(storage=S(String(120), nullable=False, default=""))
|
|
62
|
+
resource_type: Mapped[str | None] = acol(storage=S(String(120), nullable=True))
|
|
63
|
+
resource_id: Mapped[str] = acol(storage=S(String(255), nullable=False, default="*"))
|
|
64
|
+
action: Mapped[str] = acol(storage=S(String(255), nullable=False, index=True))
|
|
65
|
+
scope: Mapped[str | None] = acol(storage=S(String(255), nullable=True))
|
|
66
|
+
audience: Mapped[str | None] = acol(storage=S(String(255), nullable=True))
|
|
67
|
+
resource_indicator: Mapped[str | None] = acol(storage=S(String(255), nullable=True))
|
|
68
|
+
constraints: Mapped[dict | None] = acol(storage=S(JSON, nullable=True))
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
class DelegationGrantProof(RestOltpTable, GUIDPk, Timestamped):
|
|
72
|
+
__tablename__ = "delegation_grant_proofs"
|
|
73
|
+
__table_args__ = ({"schema": "authn"},)
|
|
74
|
+
|
|
75
|
+
grant_id: Mapped[uuid.UUID] = acol(
|
|
76
|
+
storage=S(PgUUID(as_uuid=True), fk=ForeignKeySpec(target="authn.delegation_grants.id"), nullable=False, index=True)
|
|
77
|
+
)
|
|
78
|
+
source_scope_hash: Mapped[str] = acol(storage=S(String(128), nullable=False))
|
|
79
|
+
delegated_scope_hash: Mapped[str] = acol(storage=S(String(128), nullable=False))
|
|
80
|
+
attenuation_result: Mapped[bool] = acol(storage=S(Boolean, nullable=False, default=False))
|
|
81
|
+
uncovered_scopes: Mapped[list | None] = acol(storage=S(JSON, nullable=True))
|
|
82
|
+
proof_version: Mapped[str] = acol(storage=S(String(32), nullable=False, default="v1"))
|
|
83
|
+
proof_hash: Mapped[str] = acol(storage=S(String(128), nullable=False, unique=True, index=True))
|
|
84
|
+
evaluated_at: Mapped[dt.datetime] = acol(
|
|
85
|
+
storage=S(TZDateTime, nullable=False, default=lambda: dt.datetime.now(dt.timezone.utc))
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
class DelegationGrantEdge(RestOltpTable, GUIDPk, Timestamped):
|
|
90
|
+
__tablename__ = "delegation_grant_edges"
|
|
91
|
+
__table_args__ = ({"schema": "authn"},)
|
|
92
|
+
|
|
93
|
+
parent_grant_id: Mapped[uuid.UUID | None] = acol(
|
|
94
|
+
storage=S(PgUUID(as_uuid=True), fk=ForeignKeySpec(target="authn.delegation_grants.id"), nullable=True, index=True)
|
|
95
|
+
)
|
|
96
|
+
child_grant_id: Mapped[uuid.UUID] = acol(
|
|
97
|
+
storage=S(PgUUID(as_uuid=True), fk=ForeignKeySpec(target="authn.delegation_grants.id"), nullable=False, index=True)
|
|
98
|
+
)
|
|
99
|
+
delegator_subject: Mapped[str] = acol(storage=S(String(255), nullable=False, index=True))
|
|
100
|
+
delegate_subject: Mapped[str] = acol(storage=S(String(255), nullable=False, index=True))
|
|
101
|
+
edge_type: Mapped[str] = acol(storage=S(String(64), nullable=False, default="grant"))
|
|
102
|
+
provenance_id: Mapped[str | None] = acol(storage=S(String(128), nullable=True))
|
|
103
|
+
active: Mapped[bool] = acol(storage=S(Boolean, nullable=False, default=True))
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
class DelegationGrantTokenLink(RestOltpTable, GUIDPk, Timestamped):
|
|
107
|
+
__tablename__ = "delegation_grant_token_links"
|
|
108
|
+
__table_args__ = ({"schema": "authn"},)
|
|
109
|
+
|
|
110
|
+
grant_id: Mapped[uuid.UUID] = acol(
|
|
111
|
+
storage=S(PgUUID(as_uuid=True), fk=ForeignKeySpec(target="authn.delegation_grants.id"), nullable=False, index=True)
|
|
112
|
+
)
|
|
113
|
+
token_hash: Mapped[str] = acol(storage=S(String(128), nullable=False, index=True))
|
|
114
|
+
token_kind: Mapped[str] = acol(storage=S(String(32), nullable=False, default="access"))
|
|
115
|
+
authorization_trace_id: Mapped[str | None] = acol(storage=S(String(128), nullable=True, index=True))
|
|
116
|
+
delegation_provenance_id: Mapped[str | None] = acol(storage=S(String(128), nullable=True, index=True))
|
|
117
|
+
actor_subject: Mapped[str | None] = acol(storage=S(String(255), nullable=True, index=True))
|
|
118
|
+
subject: Mapped[str] = acol(storage=S(String(255), nullable=False, index=True))
|
|
119
|
+
exchange_mode: Mapped[str] = acol(storage=S(String(32), nullable=False, default="delegation"))
|
|
120
|
+
source_token_hash: Mapped[str | None] = acol(storage=S(String(128), nullable=True))
|
|
121
|
+
actor_token_hash: Mapped[str | None] = acol(storage=S(String(128), nullable=True))
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
DelegationGrantRecord = DelegationGrant
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
__all__ = [
|
|
128
|
+
"DelegationGrant",
|
|
129
|
+
"DelegationGrantEdge",
|
|
130
|
+
"DelegationGrantProof",
|
|
131
|
+
"DelegationGrantRecord",
|
|
132
|
+
"DelegationGrantScope",
|
|
133
|
+
"DelegationGrantTokenLink",
|
|
134
|
+
]
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from . import _table as _table
|
|
4
|
+
from ._table import *
|
|
5
|
+
|
|
6
|
+
for _name in dir(_table):
|
|
7
|
+
if not _name.startswith("__"):
|
|
8
|
+
globals().setdefault(_name, getattr(_table, _name))
|
|
9
|
+
|
|
10
|
+
try:
|
|
11
|
+
__all__ = list(_table.__all__)
|
|
12
|
+
except AttributeError:
|
|
13
|
+
__all__ = [name for name in globals() if not name.startswith("_")]
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"""Device code model with durable authorization lifecycle fields."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import datetime as dt
|
|
6
|
+
import uuid
|
|
7
|
+
|
|
8
|
+
from tba_storage_core.framework import (
|
|
9
|
+
RestOltpTable,
|
|
10
|
+
Timestamped,
|
|
11
|
+
S,
|
|
12
|
+
acol,
|
|
13
|
+
ForeignKeySpec,
|
|
14
|
+
Boolean,
|
|
15
|
+
Integer,
|
|
16
|
+
Mapped,
|
|
17
|
+
PgUUID,
|
|
18
|
+
String,
|
|
19
|
+
TZDateTime,
|
|
20
|
+
GUIDPk,
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class DeviceCode(RestOltpTable, GUIDPk, Timestamped):
|
|
25
|
+
__tablename__ = "device_codes"
|
|
26
|
+
__table_args__ = ({"schema": "authn"},)
|
|
27
|
+
|
|
28
|
+
device_code: Mapped[str] = acol(storage=S(String(128), nullable=False, unique=True))
|
|
29
|
+
user_code: Mapped[str] = acol(storage=S(String(32), nullable=False, index=True))
|
|
30
|
+
client_id: Mapped[uuid.UUID] = acol(
|
|
31
|
+
storage=S(PgUUID(as_uuid=True), fk=ForeignKeySpec(target="authn.clients.id"), nullable=False)
|
|
32
|
+
)
|
|
33
|
+
scope: Mapped[str | None] = acol(storage=S(String(1000), nullable=True))
|
|
34
|
+
audience: Mapped[str | None] = acol(storage=S(String(1000), nullable=True))
|
|
35
|
+
resource: Mapped[str | None] = acol(storage=S(String(1000), nullable=True))
|
|
36
|
+
expires_at: Mapped[dt.datetime] = acol(storage=S(TZDateTime, nullable=False))
|
|
37
|
+
interval: Mapped[int] = acol(storage=S(Integer, nullable=False))
|
|
38
|
+
poll_count: Mapped[int] = acol(storage=S(Integer, nullable=False, default=0))
|
|
39
|
+
slow_down_count: Mapped[int] = acol(storage=S(Integer, nullable=False, default=0))
|
|
40
|
+
last_polled_at: Mapped[dt.datetime | None] = acol(storage=S(TZDateTime, nullable=True, index=True))
|
|
41
|
+
authorized: Mapped[bool] = acol(storage=S(Boolean, nullable=False, default=False))
|
|
42
|
+
authorized_at: Mapped[dt.datetime | None] = acol(storage=S(TZDateTime, nullable=True, index=True))
|
|
43
|
+
denied_at: Mapped[dt.datetime | None] = acol(storage=S(TZDateTime, nullable=True, index=True))
|
|
44
|
+
denial_reason: Mapped[str | None] = acol(storage=S(String(255), nullable=True))
|
|
45
|
+
consumed_at: Mapped[dt.datetime | None] = acol(storage=S(TZDateTime, nullable=True, index=True))
|
|
46
|
+
user_id: Mapped[uuid.UUID | None] = acol(
|
|
47
|
+
storage=S(PgUUID(as_uuid=True), fk=ForeignKeySpec(target="authn.users.id"), nullable=True, index=True)
|
|
48
|
+
)
|
|
49
|
+
tenant_id: Mapped[uuid.UUID | None] = acol(
|
|
50
|
+
storage=S(PgUUID(as_uuid=True), fk=ForeignKeySpec(target="authn.tenants.id"), nullable=True, index=True)
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
__all__ = ["DeviceCode"]
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
"""Optional durable DID authority/cache and GNAP transaction state."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
import datetime as dt
|
|
5
|
+
from tba_storage_core.framework import (
|
|
6
|
+
Boolean,
|
|
7
|
+
GUIDPk,
|
|
8
|
+
JSON,
|
|
9
|
+
Mapped,
|
|
10
|
+
RestOltpTable,
|
|
11
|
+
S,
|
|
12
|
+
String,
|
|
13
|
+
TZDateTime,
|
|
14
|
+
Timestamped,
|
|
15
|
+
acol,
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class DidDocument(RestOltpTable, GUIDPk, Timestamped):
|
|
20
|
+
__tablename__ = "did_documents"
|
|
21
|
+
__table_args__ = ({"schema": "authn"},)
|
|
22
|
+
did: Mapped[str] = acol(
|
|
23
|
+
storage=S(String(1000), nullable=False, unique=True, index=True)
|
|
24
|
+
)
|
|
25
|
+
method: Mapped[str] = acol(storage=S(String(64), nullable=False, index=True))
|
|
26
|
+
authoritative: Mapped[bool] = acol(
|
|
27
|
+
storage=S(Boolean, nullable=False, default=False, index=True)
|
|
28
|
+
)
|
|
29
|
+
current_version: Mapped[str | None] = acol(
|
|
30
|
+
storage=S(String(128), nullable=True, index=True)
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class DidDocumentVersion(RestOltpTable, GUIDPk, Timestamped):
|
|
35
|
+
__tablename__ = "did_document_versions"
|
|
36
|
+
__table_args__ = ({"schema": "authn"},)
|
|
37
|
+
did: Mapped[str] = acol(storage=S(String(1000), nullable=False, index=True))
|
|
38
|
+
version: Mapped[str] = acol(storage=S(String(128), nullable=False, index=True))
|
|
39
|
+
document: Mapped[dict] = acol(storage=S(JSON, nullable=False))
|
|
40
|
+
document_digest: Mapped[str] = acol(
|
|
41
|
+
storage=S(String(128), nullable=False, index=True)
|
|
42
|
+
)
|
|
43
|
+
valid_until: Mapped[dt.datetime | None] = acol(
|
|
44
|
+
storage=S(TZDateTime, nullable=True, index=True)
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class DidVerificationMethod(RestOltpTable, GUIDPk, Timestamped):
|
|
49
|
+
__tablename__ = "did_verification_methods"
|
|
50
|
+
__table_args__ = ({"schema": "authn"},)
|
|
51
|
+
did: Mapped[str] = acol(storage=S(String(1000), nullable=False, index=True))
|
|
52
|
+
method_id: Mapped[str] = acol(
|
|
53
|
+
storage=S(String(1000), nullable=False, unique=True, index=True)
|
|
54
|
+
)
|
|
55
|
+
method_type: Mapped[str] = acol(storage=S(String(255), nullable=False, index=True))
|
|
56
|
+
controller: Mapped[str] = acol(storage=S(String(1000), nullable=False, index=True))
|
|
57
|
+
public_key: Mapped[dict] = acol(storage=S(JSON, nullable=False))
|
|
58
|
+
relationships: Mapped[list | None] = acol(storage=S(JSON, nullable=True))
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
class DidService(RestOltpTable, GUIDPk, Timestamped):
|
|
62
|
+
__tablename__ = "did_services"
|
|
63
|
+
__table_args__ = ({"schema": "authn"},)
|
|
64
|
+
did: Mapped[str] = acol(storage=S(String(1000), nullable=False, index=True))
|
|
65
|
+
service_id: Mapped[str] = acol(
|
|
66
|
+
storage=S(String(1000), nullable=False, unique=True, index=True)
|
|
67
|
+
)
|
|
68
|
+
service_type: Mapped[str] = acol(storage=S(String(255), nullable=False, index=True))
|
|
69
|
+
endpoint: Mapped[dict | list | str] = acol(storage=S(JSON, nullable=False))
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
class DidResolutionCache(RestOltpTable, GUIDPk, Timestamped):
|
|
73
|
+
__tablename__ = "did_resolution_cache"
|
|
74
|
+
__table_args__ = ({"schema": "authn"},)
|
|
75
|
+
did_url: Mapped[str] = acol(
|
|
76
|
+
storage=S(String(1000), nullable=False, unique=True, index=True)
|
|
77
|
+
)
|
|
78
|
+
result_digest: Mapped[str] = acol(
|
|
79
|
+
storage=S(String(128), nullable=False, index=True)
|
|
80
|
+
)
|
|
81
|
+
result: Mapped[dict] = acol(storage=S(JSON, nullable=False))
|
|
82
|
+
resolved_at: Mapped[dt.datetime | None] = acol(
|
|
83
|
+
storage=S(TZDateTime, nullable=True, index=True)
|
|
84
|
+
)
|
|
85
|
+
expires_at: Mapped[dt.datetime | None] = acol(
|
|
86
|
+
storage=S(TZDateTime, nullable=True, index=True)
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
class GnapGrant(RestOltpTable, GUIDPk, Timestamped):
|
|
91
|
+
__tablename__ = "gnap_grants"
|
|
92
|
+
__table_args__ = ({"schema": "authn"},)
|
|
93
|
+
grant_id: Mapped[str] = acol(
|
|
94
|
+
storage=S(String(255), nullable=False, unique=True, index=True)
|
|
95
|
+
)
|
|
96
|
+
client_instance_id: Mapped[str] = acol(
|
|
97
|
+
storage=S(String(255), nullable=False, index=True)
|
|
98
|
+
)
|
|
99
|
+
access_request: Mapped[dict | list] = acol(storage=S(JSON, nullable=False))
|
|
100
|
+
status: Mapped[str] = acol(
|
|
101
|
+
storage=S(String(32), nullable=False, default="pending", index=True)
|
|
102
|
+
)
|
|
103
|
+
subject_id: Mapped[str | None] = acol(
|
|
104
|
+
storage=S(String(255), nullable=True, index=True)
|
|
105
|
+
)
|
|
106
|
+
expires_at: Mapped[dt.datetime | None] = acol(
|
|
107
|
+
storage=S(TZDateTime, nullable=True, index=True)
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
class GnapContinuation(RestOltpTable, GUIDPk, Timestamped):
|
|
112
|
+
__tablename__ = "gnap_continuations"
|
|
113
|
+
__table_args__ = ({"schema": "authn"},)
|
|
114
|
+
grant_id: Mapped[str] = acol(storage=S(String(255), nullable=False, index=True))
|
|
115
|
+
continuation_id: Mapped[str] = acol(
|
|
116
|
+
storage=S(String(255), nullable=False, unique=True, index=True)
|
|
117
|
+
)
|
|
118
|
+
token_digest: Mapped[str] = acol(storage=S(String(128), nullable=False, index=True))
|
|
119
|
+
wait_seconds: Mapped[str | None] = acol(storage=S(String(16), nullable=True))
|
|
120
|
+
expires_at: Mapped[dt.datetime | None] = acol(
|
|
121
|
+
storage=S(TZDateTime, nullable=True, index=True)
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
class GnapClientInstance(RestOltpTable, GUIDPk, Timestamped):
|
|
126
|
+
__tablename__ = "gnap_client_instances"
|
|
127
|
+
__table_args__ = ({"schema": "authn"},)
|
|
128
|
+
instance_id: Mapped[str] = acol(
|
|
129
|
+
storage=S(String(255), nullable=False, unique=True, index=True)
|
|
130
|
+
)
|
|
131
|
+
key_reference: Mapped[str | None] = acol(
|
|
132
|
+
storage=S(String(255), nullable=True, index=True)
|
|
133
|
+
)
|
|
134
|
+
client_display: Mapped[dict | None] = acol(storage=S(JSON, nullable=True))
|
|
135
|
+
status: Mapped[str] = acol(
|
|
136
|
+
storage=S(String(32), nullable=False, default="active", index=True)
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
class GnapInteraction(RestOltpTable, GUIDPk, Timestamped):
|
|
141
|
+
__tablename__ = "gnap_interactions"
|
|
142
|
+
__table_args__ = ({"schema": "authn"},)
|
|
143
|
+
grant_id: Mapped[str] = acol(storage=S(String(255), nullable=False, index=True))
|
|
144
|
+
interaction_id: Mapped[str] = acol(
|
|
145
|
+
storage=S(String(255), nullable=False, unique=True, index=True)
|
|
146
|
+
)
|
|
147
|
+
mode: Mapped[str] = acol(storage=S(String(64), nullable=False, index=True))
|
|
148
|
+
finish_nonce_digest: Mapped[str | None] = acol(
|
|
149
|
+
storage=S(String(128), nullable=True, index=True)
|
|
150
|
+
)
|
|
151
|
+
status: Mapped[str] = acol(
|
|
152
|
+
storage=S(String(32), nullable=False, default="pending", index=True)
|
|
153
|
+
)
|
|
154
|
+
completed_at: Mapped[dt.datetime | None] = acol(
|
|
155
|
+
storage=S(TZDateTime, nullable=True, index=True)
|
|
156
|
+
)
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
__all__ = [
|
|
160
|
+
"DidDocument",
|
|
161
|
+
"DidDocumentVersion",
|
|
162
|
+
"DidVerificationMethod",
|
|
163
|
+
"DidService",
|
|
164
|
+
"DidResolutionCache",
|
|
165
|
+
"GnapGrant",
|
|
166
|
+
"GnapContinuation",
|
|
167
|
+
"GnapClientInstance",
|
|
168
|
+
"GnapInteraction",
|
|
169
|
+
]
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"""Durable DPoP nonce ledger."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import datetime as dt
|
|
6
|
+
import hashlib
|
|
7
|
+
from datetime import timezone
|
|
8
|
+
from typing import Any
|
|
9
|
+
|
|
10
|
+
from tba_storage_core.framework import (
|
|
11
|
+
GUIDPk,
|
|
12
|
+
Mapped,
|
|
13
|
+
RestOltpTable,
|
|
14
|
+
S,
|
|
15
|
+
String,
|
|
16
|
+
TZDateTime,
|
|
17
|
+
Timestamped,
|
|
18
|
+
acol,
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class DpopNonce(RestOltpTable, GUIDPk, Timestamped):
|
|
23
|
+
__tablename__ = "dpop_nonces"
|
|
24
|
+
__table_args__ = ({"schema": "authn"},)
|
|
25
|
+
|
|
26
|
+
nonce_hash: Mapped[str] = acol(storage=S(String(64), nullable=False, unique=True, index=True))
|
|
27
|
+
issued_at: Mapped[dt.datetime] = acol(storage=S(TZDateTime, nullable=False, index=True))
|
|
28
|
+
expires_at: Mapped[dt.datetime] = acol(storage=S(TZDateTime, nullable=False, index=True))
|
|
29
|
+
consumed_at: Mapped[dt.datetime | None] = acol(storage=S(TZDateTime, nullable=True, index=True))
|
|
30
|
+
client_id: Mapped[str | None] = acol(storage=S(String(255), nullable=True, index=True))
|
|
31
|
+
authorization_server_id: Mapped[str | None] = acol(storage=S(String(255), nullable=True, index=True))
|
|
32
|
+
resource_server_id: Mapped[str | None] = acol(storage=S(String(255), nullable=True, index=True))
|
|
33
|
+
jkt: Mapped[str | None] = acol(storage=S(String(255), nullable=True, index=True))
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def _as_aware(value: Any) -> dt.datetime:
|
|
37
|
+
if isinstance(value, dt.datetime):
|
|
38
|
+
parsed = value
|
|
39
|
+
elif isinstance(value, (int, float)):
|
|
40
|
+
parsed = dt.datetime.fromtimestamp(value, tz=timezone.utc)
|
|
41
|
+
else:
|
|
42
|
+
parsed = dt.datetime.fromisoformat(str(value))
|
|
43
|
+
if parsed.tzinfo is None:
|
|
44
|
+
return parsed.replace(tzinfo=timezone.utc)
|
|
45
|
+
return parsed.astimezone(timezone.utc)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def nonce_hash(nonce: str) -> str:
|
|
49
|
+
return hashlib.sha256(str(nonce).strip().encode("utf-8")).hexdigest()
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def nonce_payload(
|
|
53
|
+
*,
|
|
54
|
+
nonce: str,
|
|
55
|
+
issued_at: dt.datetime,
|
|
56
|
+
expires_at: dt.datetime,
|
|
57
|
+
consumed_at: dt.datetime | None = None,
|
|
58
|
+
client_id: str | None = None,
|
|
59
|
+
authorization_server_id: str | None = None,
|
|
60
|
+
resource_server_id: str | None = None,
|
|
61
|
+
jkt: str | None = None,
|
|
62
|
+
) -> dict[str, Any]:
|
|
63
|
+
return {
|
|
64
|
+
"nonce_hash": nonce_hash(nonce),
|
|
65
|
+
"issued_at": _as_aware(issued_at),
|
|
66
|
+
"expires_at": _as_aware(expires_at),
|
|
67
|
+
"consumed_at": _as_aware(consumed_at) if consumed_at is not None else None,
|
|
68
|
+
"client_id": str(client_id).strip() if client_id not in {None, ""} else None,
|
|
69
|
+
"authorization_server_id": (
|
|
70
|
+
str(authorization_server_id).strip() if authorization_server_id not in {None, ""} else None
|
|
71
|
+
),
|
|
72
|
+
"resource_server_id": str(resource_server_id).strip() if resource_server_id not in {None, ""} else None,
|
|
73
|
+
"jkt": str(jkt).strip() if jkt not in {None, ""} else None,
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
__all__ = ["DpopNonce", "nonce_hash", "nonce_payload"]
|