spakky-auth¶
spakky-auth는 인증 상태, 인가 요구사항, provider capability, snapshot 전파 계약을 정의합니다.
Provider-neutral 인증/인가 의미 모델입니다.
패키지 루트¶
Provider-neutral authentication and authorization package root.
AUTH_CONTEXT_CONTEXT_KEY = 'spakky.auth.context'
module-attribute
¶
ApplicationContext context value key for the current AuthContext.
AUTH_CONTEXT_SNAPSHOT_HEADER_KEY = 'x-spakky-auth-context-snapshot'
module-attribute
¶
HTTP/gRPC-style header key for signed AuthContextSnapshot propagation.
AUTH_CONTEXT_SNAPSHOT_METADATA_KEY = 'spakky.auth.context_snapshot'
module-attribute
¶
Transport metadata key for signed AuthContextSnapshot propagation.
AUTH_CONTEXT_SNAPSHOT_SCHEMA_VERSION = 1
module-attribute
¶
Current signed AuthContextSnapshot envelope schema version.
DEFAULT_AUTH_CLOCK_SKEW_SECONDS = 60
module-attribute
¶
Default tolerated clock skew for AuthContextSnapshot validation.
AUTH_CONTRIBUTION_ENTRY_POINT_GROUP = 'spakky.contributions.spakky.auth'
module-attribute
¶
Entry point group used by providers contributing to spakky-auth.
EXPIRED_SNAPSHOT_DECISION = AuthorizationDecision.challenge(AuthorizationReasonCode.SNAPSHOT_EXPIRED)
module-attribute
¶
Default decision for expired AuthContextSnapshot metadata.
INVALID_SNAPSHOT_DECISION = AuthorizationDecision.challenge(AuthorizationReasonCode.SNAPSHOT_INVALID)
module-attribute
¶
Default decision for malformed or unsigned AuthContextSnapshot metadata.
MISSING_SNAPSHOT_DECISION = AuthorizationDecision.challenge(AuthorizationReasonCode.SNAPSHOT_MISSING)
module-attribute
¶
Default decision for missing AuthContextSnapshot propagation metadata.
VERIFICATION_PROVIDER_UNAVAILABLE_DECISION = AuthorizationDecision.error(AuthorizationReasonCode.VERIFICATION_PROVIDER_UNAVAILABLE)
module-attribute
¶
Default decision when snapshot verification provider is unavailable.
AUTH_STARTUP_VALIDATION_ERROR_DETAIL_KEY = 'auth.capability.validation.error'
module-attribute
¶
Startup diagnostic detail key for invalid auth capability provider counts.
SPAKKY_AUTH_SNAPSHOT_PROPAGATION_CONFIG_ENV_PREFIX = 'SPAKKY_AUTH_SNAPSHOT_PROPAGATION_'
module-attribute
¶
Environment prefix for signed AuthContextSnapshot propagation settings.
PLUGIN_NAME = Plugin(name='spakky-auth')
module-attribute
¶
Plugin identifier for the Spakky Auth package.
AsyncAuthorizationAspect(application_context=None, authorization_policy_evaluator=None, permission_checker=None, relation_checker=None, role_checker=None, scope_checker=None)
¶
Bases: IAsyncAspect, IApplicationContextAware
Asynchronous aspect enforcing protected auth metadata.
Source code in core/spakky-auth/src/spakky/auth/aspects/authorization.py
set_application_context(application_context)
¶
Inject the application context when managed as a Pod.
AuthorizationAspect(application_context=None, authorization_policy_evaluator=None, permission_checker=None, relation_checker=None, role_checker=None, scope_checker=None)
¶
Bases: IAspect, IApplicationContextAware
Synchronous aspect enforcing protected auth metadata.
Source code in core/spakky-auth/src/spakky/auth/aspects/authorization.py
set_application_context(application_context)
¶
Inject the application context when managed as a Pod.
AuthCapability
¶
Bases: StrEnum
Auth provider capabilities declared by feature contributions.
AuthProviderContribution(*, provider_id, capabilities)
dataclass
¶
AuthClaim(*, name, value)
dataclass
¶
AuthContext(*, subject, issuer, tenant=None, roles=(), scopes=(), claims=(), credential_carrier=None, metadata=tuple())
dataclass
¶
Request/context-scoped authentication state seeded by inbound adapters.
subject
instance-attribute
¶
Authenticated subject.
issuer
instance-attribute
¶
Authority that authenticated the subject.
tenant = None
class-attribute
instance-attribute
¶
Optional tenant canonical reference.
roles = ()
class-attribute
instance-attribute
¶
Role canonical references granted to the subject.
scopes = ()
class-attribute
instance-attribute
¶
Scope canonical references granted to the subject.
claims = ()
class-attribute
instance-attribute
¶
Selected provider claims retained for downstream decisions.
credential_carrier = None
class-attribute
instance-attribute
¶
Boundary-local credential carrier that produced this context.
metadata = field(default_factory=tuple)
class-attribute
instance-attribute
¶
Framework-safe metadata associated with this auth context.
AuthSubject(*, id, display_name=None)
dataclass
¶
CredentialCarrier(*, kind, location, material, name=None, scheme=None)
dataclass
¶
Boundary-local credential material handed to an auth provider.
kind
instance-attribute
¶
Provider-neutral credential category.
location
instance-attribute
¶
Transport location where the credential was discovered.
material
instance-attribute
¶
Opaque credential material read by the inbound adapter.
name = None
class-attribute
instance-attribute
¶
Optional transport field name, such as an HTTP header name.
scheme = None
class-attribute
instance-attribute
¶
Optional credential scheme, such as Bearer.
CredentialCarrierKind
¶
Bases: StrEnum
Canonical credential material categories accepted by auth providers.
CredentialCarrierLocation
¶
Bases: StrEnum
Where an inbound adapter observed credential material.
AuthorizationDecision(*, state, reason_code, reason=None)
dataclass
¶
Provider-neutral result of an auth enforcement decision.
state
instance-attribute
¶
ALLOW, CHALLENGE, DENY, or ERROR.
reason_code
instance-attribute
¶
Machine-readable reason for the decision.
reason = None
class-attribute
instance-attribute
¶
Optional operator-facing reason text.
allow(reason_code=AuthorizationReasonCode.AUTHORIZED, reason=None)
classmethod
¶
Create an ALLOW decision.
Source code in core/spakky-auth/src/spakky/auth/decision.py
challenge(reason_code, reason=None)
classmethod
¶
Create a CHALLENGE decision.
Source code in core/spakky-auth/src/spakky/auth/decision.py
deny(reason_code, reason=None)
classmethod
¶
Create a DENY decision.
Source code in core/spakky-auth/src/spakky/auth/decision.py
error(reason_code, reason=None)
classmethod
¶
Create an ERROR decision.
Source code in core/spakky-auth/src/spakky/auth/decision.py
AuthorizationDecisionState
¶
Bases: StrEnum
Canonical auth enforcement outcomes.
AuthorizationReasonCode
¶
Bases: StrEnum
Machine-readable reason codes attached to authorization decisions.
AbstractSpakkyAuthError
¶
AuthContextError
¶
AuthContextNotFoundError
¶
AuthRequirementDeniedError(decision=None)
¶
Bases: AuthorizationError
Raised when an auth requirement decision is not ALLOW.
Source code in core/spakky-auth/src/spakky/auth/error.py
AuthRequirementProviderUnavailableError
¶
AuthContextSnapshotError
¶
AuthVerificationProviderUnavailableError
¶
AuthenticationError
¶
Bases: AbstractSpakkyAuthError
Raised when authentication fails before authorization policy evaluation.
AuthorizationError
¶
ConflictingAuthMetadataError
¶
CredentialCarrierError
¶
ExpiredAuthContextSnapshotError
¶
Bases: AuthContextSnapshotError
Raised when snapshot propagation metadata is outside its time window.
InvalidAuthContextSnapshotError
¶
InvalidAuthContextValueError
¶
MissingAuthContextSnapshotError
¶
AuthDynamicRef(*, kind, expression)
dataclass
¶
AuthDynamicRefKind
¶
Bases: StrEnum
Dynamic auth reference target kinds resolved from an invocation.
AuthInvocation(*, boundary, operation, subject=None, attributes=())
dataclass
¶
Provider-neutral description of the boundary call being authorized.
boundary
instance-attribute
¶
Boundary category such as HTTP, gRPC, CLI, task, event, or saga.
operation
instance-attribute
¶
Canonical operation or handler reference at the boundary.
subject = None
class-attribute
instance-attribute
¶
Optional pre-authenticated subject when a boundary already has one.
attributes = ()
class-attribute
instance-attribute
¶
Scalar invocation attributes available to dynamic ref resolvers.
AuthInvocationAttribute(*, name, value)
dataclass
¶
ResolvedAuthReference(*, kind, value)
dataclass
¶
EffectiveAuthMetadata(*, public_access, requirements)
dataclass
¶
Effective auth metadata after class/method aggregation.
AuthRequirement(*, kind, ref, resource=None, action=None, tenant=None)
dataclass
¶
Canonical protected-boundary auth requirement.
kind
instance-attribute
¶
Requirement category used by enforcement to select the provider port.
ref
instance-attribute
¶
Canonical permission, role, scope, relation, or marker reference.
resource = None
class-attribute
instance-attribute
¶
Optional resource reference for permission, policy, or relation checks.
action = None
class-attribute
instance-attribute
¶
Optional action reference for policy checks.
tenant = None
class-attribute
instance-attribute
¶
Optional tenant reference for tenant-scoped checks.
AuthRequirementKind
¶
Bases: StrEnum
Canonical auth requirement categories supported by decorators.
ProtectedRequirement(requirement)
dataclass
¶
PublicAccess()
dataclass
¶
AuthorizationRequest(*, auth_context, resource, action, tenant=None)
dataclass
¶
Provider-neutral policy evaluation request.
auth_context
instance-attribute
¶
Authenticated subject context.
resource
instance-attribute
¶
Canonical resource reference being accessed.
action
instance-attribute
¶
Canonical action reference being attempted.
tenant = None
class-attribute
instance-attribute
¶
Optional tenant reference; None means tenant is not applicable.
IAuthContextSnapshotSigner
¶
Bases: ABC
Provider-neutral AuthContextSnapshot signing port.
sign_snapshot(request)
abstractmethod
¶
IAuthContextSnapshotVerifier
¶
Bases: ABC
Provider-neutral AuthContextSnapshot verification port.
verify_snapshot(snapshot_envelope, invocation)
abstractmethod
¶
Verify a signed snapshot envelope and return its auth context.
IAuthInvocationResolver
¶
Bases: ABC
Resolver for invocation-scoped resource, action, and tenant refs.
resolve_ref(invocation, dynamic_ref)
abstractmethod
¶
Resolve a late-bound auth reference from invocation attributes.
IAuthenticationProvider
¶
Bases: ABC
Provider-neutral authentication port.
authenticate(credential, invocation)
abstractmethod
¶
Authenticate a credential observed at an invocation boundary.
IAuthorizationPolicyEvaluator
¶
IPasswordHasher
¶
IPasswordVerifier
¶
Bases: ABC
Provider-neutral password verification port.
verify_password(password, password_hash)
abstractmethod
¶
Verify plaintext password material against a stored hash.
IPermissionChecker
¶
IRelationChecker
¶
IRoleChecker
¶
Bases: ABC
Provider-neutral role check port.
IScopeChecker
¶
Bases: ABC
Provider-neutral scope check port.
PermissionCheckRequest(*, auth_context, permission, resource=None, tenant=None)
dataclass
¶
Permission check request scoped to an authenticated subject.
auth_context
instance-attribute
¶
Authenticated subject context.
permission
instance-attribute
¶
Canonical permission reference.
resource = None
class-attribute
instance-attribute
¶
Optional resource reference; None means resource-independent.
tenant = None
class-attribute
instance-attribute
¶
Optional tenant reference; None means tenant is not applicable.
RelationCheckRequest(*, auth_context, relation, resource, tenant=None)
dataclass
¶
Relationship authorization request scoped to a resource.
auth_context
instance-attribute
¶
Authenticated subject context.
relation
instance-attribute
¶
Canonical relationship reference.
resource
instance-attribute
¶
Canonical resource reference for the relationship check.
tenant = None
class-attribute
instance-attribute
¶
Optional tenant reference; None means tenant is not applicable.
RoleCheckRequest(*, auth_context, role, tenant=None)
dataclass
¶
ScopeCheckRequest(*, auth_context, scope)
dataclass
¶
SnapshotSignRequest(*, auth_context, tenant=None)
dataclass
¶
AuthContextSnapshot(*, subject, issuer, issued_at, expires_at, signature, schema_version=AUTH_CONTEXT_SNAPSHOT_SCHEMA_VERSION, tenant=None, roles=(), scopes=(), selected_claims=(), correlation_id=None, delegation_chain=())
dataclass
¶
Canonical JSON signed envelope propagated instead of raw credentials.
subject
instance-attribute
¶
Subject represented by this snapshot.
issuer
instance-attribute
¶
Issuer that created the snapshot.
issued_at
instance-attribute
¶
Snapshot issue timestamp.
expires_at
instance-attribute
¶
Snapshot expiration timestamp.
signature
instance-attribute
¶
Signature material required by verification providers.
schema_version = AUTH_CONTEXT_SNAPSHOT_SCHEMA_VERSION
class-attribute
instance-attribute
¶
Canonical snapshot schema version.
tenant = None
class-attribute
instance-attribute
¶
Optional tenant canonical reference.
roles = ()
class-attribute
instance-attribute
¶
Role canonical references included in the snapshot.
scopes = ()
class-attribute
instance-attribute
¶
Scope canonical references included in the snapshot.
selected_claims = ()
class-attribute
instance-attribute
¶
Selected claims included in the signed snapshot.
correlation_id = None
class-attribute
instance-attribute
¶
Optional trace/correlation reference for the propagated context.
delegation_chain = ()
class-attribute
instance-attribute
¶
Ordered subject/service delegation references.
canonical_payload()
¶
Return canonical JSON-ready signed envelope payload.
Source code in core/spakky-auth/src/spakky/auth/snapshot.py
canonical_json()
¶
Return compact, sorted canonical JSON for the signed envelope.
base64url_canonical_json()
¶
Return unpadded base64url canonical JSON envelope text.
AuthContextSnapshotSignature(*, key_id, algorithm, signature)
dataclass
¶
Signature material carried with a signed AuthContextSnapshot envelope.
AuthCapabilityStartupValidationService()
¶
Bases: IService, IContainerAware
Service that runs auth capability validation before user services start.
Source code in core/spakky-auth/src/spakky/auth/startup.py
AuthSnapshotPropagationConfig
¶
Bases: BaseSettings
Feature-local config declaring signed AuthContextSnapshot propagation use.
enabled = False
class-attribute
instance-attribute
¶
Whether this application propagates signed AuthContextSnapshot envelopes.
AuthStartupCapabilityDiagnostic(*, capability, provider_count, provider_ids, required_by)
dataclass
¶
Structured diagnostic for one invalid required auth capability count.
capability
instance-attribute
¶
Capability required by protected metadata or snapshot propagation.
provider_count
instance-attribute
¶
Number of auth provider contributions declaring the capability.
provider_ids
instance-attribute
¶
Provider identifiers declaring the capability.
required_by
instance-attribute
¶
Startup configuration or scanned boundary sources requiring the capability.
as_startup_diagnostic_detail()
¶
Convert this auth diagnostic into a startup report detail.
Source code in core/spakky-auth/src/spakky/auth/startup.py
AuthStartupCapabilityValidationError(diagnostics)
¶
Bases: AbstractSpakkyAuthError, IStartupDiagnosticDetailProvider
Raised when required auth capabilities have zero or multiple providers.
Source code in core/spakky-auth/src/spakky/auth/startup.py
startup_diagnostic_details
property
¶
Return diagnostics attachable to the startup failure summary.
AuthStartupContainerUnavailableError
¶
require_auth_context(application_context)
¶
Load AuthContext from ApplicationContext or raise an auth error.
Source code in core/spakky-auth/src/spakky/auth/context.py
store_auth_context(application_context, auth_context)
¶
Store AuthContext in ApplicationContext context values.
Source code in core/spakky-auth/src/spakky/auth/context.py
get_effective_auth_metadata(obj, *, owner_type=None)
¶
Aggregate class and method auth metadata using AND semantics.
Source code in core/spakky-auth/src/spakky/auth/metadata.py
has_auth_boundary_metadata(obj)
¶
Return whether an object or any method declares auth metadata.
Source code in core/spakky-auth/src/spakky/auth/metadata.py
protected(obj)
¶
Require an authenticated request-scope AuthContext.
Source code in core/spakky-auth/src/spakky/auth/metadata.py
public_access(obj)
¶
require_permission(permission, *, resource=None, tenant=None)
¶
Require a permission decision for a class or method boundary.
Source code in core/spakky-auth/src/spakky/auth/metadata.py
require_policy(resource, action, *, tenant=None)
¶
Require a resource/action policy decision for a boundary.
Source code in core/spakky-auth/src/spakky/auth/metadata.py
require_relation(relation, *, resource, tenant=None)
¶
Require a relationship decision for a resource boundary.
Source code in core/spakky-auth/src/spakky/auth/metadata.py
require_role(role, *, tenant=None)
¶
Require a role decision for a class or method boundary.
Source code in core/spakky-auth/src/spakky/auth/metadata.py
require_scope(scope)
¶
Require a scope decision for a class or method boundary.
Source code in core/spakky-auth/src/spakky/auth/metadata.py
effective_auth_snapshot_propagation_config(configs)
¶
Collapse all registered snapshot propagation configs into one decision.
Source code in core/spakky-auth/src/spakky/auth/startup.py
플러그인 진입점¶
Plugin initialization entry point for spakky-auth.
initialize(app)
¶
Initialize the spakky-auth package.
Registers auth AOP enforcement components and feature-local startup capability validation. Provider implementations and boundary AuthContext seeding are added by downstream auth issues.
Source code in core/spakky-auth/src/spakky/auth/main.py
Stable keys and defaults for provider-neutral auth contracts.
AUTH_CONTEXT_CONTEXT_KEY = 'spakky.auth.context'
module-attribute
¶
ApplicationContext context value key for the current AuthContext.
AUTH_CONTEXT_SNAPSHOT_METADATA_KEY = 'spakky.auth.context_snapshot'
module-attribute
¶
Transport metadata key for signed AuthContextSnapshot propagation.
AUTH_CONTEXT_SNAPSHOT_HEADER_KEY = 'x-spakky-auth-context-snapshot'
module-attribute
¶
HTTP/gRPC-style header key for signed AuthContextSnapshot propagation.
AUTH_CONTEXT_SNAPSHOT_SCHEMA_VERSION = 1
module-attribute
¶
Current signed AuthContextSnapshot envelope schema version.
DEFAULT_AUTH_CLOCK_SKEW_SECONDS = 60
module-attribute
¶
Default tolerated clock skew for AuthContextSnapshot validation.
의미 모델¶
AuthContext model and ApplicationContext storage helpers.
AuthClaim(*, name, value)
dataclass
¶
AuthSubject(*, id, display_name=None)
dataclass
¶
AuthContext(*, subject, issuer, tenant=None, roles=(), scopes=(), claims=(), credential_carrier=None, metadata=tuple())
dataclass
¶
Request/context-scoped authentication state seeded by inbound adapters.
subject
instance-attribute
¶
Authenticated subject.
issuer
instance-attribute
¶
Authority that authenticated the subject.
tenant = None
class-attribute
instance-attribute
¶
Optional tenant canonical reference.
roles = ()
class-attribute
instance-attribute
¶
Role canonical references granted to the subject.
scopes = ()
class-attribute
instance-attribute
¶
Scope canonical references granted to the subject.
claims = ()
class-attribute
instance-attribute
¶
Selected provider claims retained for downstream decisions.
credential_carrier = None
class-attribute
instance-attribute
¶
Boundary-local credential carrier that produced this context.
metadata = field(default_factory=tuple)
class-attribute
instance-attribute
¶
Framework-safe metadata associated with this auth context.
store_auth_context(application_context, auth_context)
¶
Store AuthContext in ApplicationContext context values.
Source code in core/spakky-auth/src/spakky/auth/context.py
require_auth_context(application_context)
¶
Load AuthContext from ApplicationContext or raise an auth error.
Source code in core/spakky-auth/src/spakky/auth/context.py
Provider-neutral credential carrier model.
CredentialCarrierKind
¶
Bases: StrEnum
Canonical credential material categories accepted by auth providers.
CredentialCarrierLocation
¶
Bases: StrEnum
Where an inbound adapter observed credential material.
CredentialCarrier(*, kind, location, material, name=None, scheme=None)
dataclass
¶
Boundary-local credential material handed to an auth provider.
kind
instance-attribute
¶
Provider-neutral credential category.
location
instance-attribute
¶
Transport location where the credential was discovered.
material
instance-attribute
¶
Opaque credential material read by the inbound adapter.
name = None
class-attribute
instance-attribute
¶
Optional transport field name, such as an HTTP header name.
scheme = None
class-attribute
instance-attribute
¶
Optional credential scheme, such as Bearer.
Authorization decision state and reason model.
MISSING_SNAPSHOT_DECISION = AuthorizationDecision.challenge(AuthorizationReasonCode.SNAPSHOT_MISSING)
module-attribute
¶
Default decision for missing AuthContextSnapshot propagation metadata.
INVALID_SNAPSHOT_DECISION = AuthorizationDecision.challenge(AuthorizationReasonCode.SNAPSHOT_INVALID)
module-attribute
¶
Default decision for malformed or unsigned AuthContextSnapshot metadata.
EXPIRED_SNAPSHOT_DECISION = AuthorizationDecision.challenge(AuthorizationReasonCode.SNAPSHOT_EXPIRED)
module-attribute
¶
Default decision for expired AuthContextSnapshot metadata.
VERIFICATION_PROVIDER_UNAVAILABLE_DECISION = AuthorizationDecision.error(AuthorizationReasonCode.VERIFICATION_PROVIDER_UNAVAILABLE)
module-attribute
¶
Default decision when snapshot verification provider is unavailable.
AuthorizationDecisionState
¶
Bases: StrEnum
Canonical auth enforcement outcomes.
AuthorizationReasonCode
¶
Bases: StrEnum
Machine-readable reason codes attached to authorization decisions.
AuthorizationDecision(*, state, reason_code, reason=None)
dataclass
¶
Provider-neutral result of an auth enforcement decision.
state
instance-attribute
¶
ALLOW, CHALLENGE, DENY, or ERROR.
reason_code
instance-attribute
¶
Machine-readable reason for the decision.
reason = None
class-attribute
instance-attribute
¶
Optional operator-facing reason text.
allow(reason_code=AuthorizationReasonCode.AUTHORIZED, reason=None)
classmethod
¶
Create an ALLOW decision.
Source code in core/spakky-auth/src/spakky/auth/decision.py
challenge(reason_code, reason=None)
classmethod
¶
Create a CHALLENGE decision.
Source code in core/spakky-auth/src/spakky/auth/decision.py
deny(reason_code, reason=None)
classmethod
¶
Create a DENY decision.
Source code in core/spakky-auth/src/spakky/auth/decision.py
error(reason_code, reason=None)
classmethod
¶
Create an ERROR decision.
Source code in core/spakky-auth/src/spakky/auth/decision.py
Provider-neutral auth capability declarations.
AuthCapability
¶
Bases: StrEnum
Auth provider capabilities declared by feature contributions.
Feature-local contribution contract for auth providers.
AUTH_CONTRIBUTION_ENTRY_POINT_GROUP = 'spakky.contributions.spakky.auth'
module-attribute
¶
Entry point group used by providers contributing to spakky-auth.
AuthProviderContribution(*, provider_id, capabilities)
dataclass
¶
Provider-neutral invocation and dynamic auth reference contracts.
AuthDynamicRefKind
¶
Bases: StrEnum
Dynamic auth reference target kinds resolved from an invocation.
AuthInvocationAttribute(*, name, value)
dataclass
¶
AuthInvocation(*, boundary, operation, subject=None, attributes=())
dataclass
¶
Provider-neutral description of the boundary call being authorized.
boundary
instance-attribute
¶
Boundary category such as HTTP, gRPC, CLI, task, event, or saga.
operation
instance-attribute
¶
Canonical operation or handler reference at the boundary.
subject = None
class-attribute
instance-attribute
¶
Optional pre-authenticated subject when a boundary already has one.
attributes = ()
class-attribute
instance-attribute
¶
Scalar invocation attributes available to dynamic ref resolvers.
AuthDynamicRef(*, kind, expression)
dataclass
¶
Decorator metadata contracts for protected auth boundaries.
AuthRequirementKind
¶
Bases: StrEnum
Canonical auth requirement categories supported by decorators.
AuthRequirement(*, kind, ref, resource=None, action=None, tenant=None)
dataclass
¶
Canonical protected-boundary auth requirement.
kind
instance-attribute
¶
Requirement category used by enforcement to select the provider port.
ref
instance-attribute
¶
Canonical permission, role, scope, relation, or marker reference.
resource = None
class-attribute
instance-attribute
¶
Optional resource reference for permission, policy, or relation checks.
action = None
class-attribute
instance-attribute
¶
Optional action reference for policy checks.
tenant = None
class-attribute
instance-attribute
¶
Optional tenant reference for tenant-scoped checks.
EffectiveAuthMetadata(*, public_access, requirements)
dataclass
¶
Effective auth metadata after class/method aggregation.
PublicAccess()
dataclass
¶
ProtectedRequirement(requirement)
dataclass
¶
public_access(obj)
¶
protected(obj)
¶
Require an authenticated request-scope AuthContext.
Source code in core/spakky-auth/src/spakky/auth/metadata.py
require_permission(permission, *, resource=None, tenant=None)
¶
Require a permission decision for a class or method boundary.
Source code in core/spakky-auth/src/spakky/auth/metadata.py
require_policy(resource, action, *, tenant=None)
¶
Require a resource/action policy decision for a boundary.
Source code in core/spakky-auth/src/spakky/auth/metadata.py
require_relation(relation, *, resource, tenant=None)
¶
Require a relationship decision for a resource boundary.
Source code in core/spakky-auth/src/spakky/auth/metadata.py
require_role(role, *, tenant=None)
¶
Require a role decision for a class or method boundary.
Source code in core/spakky-auth/src/spakky/auth/metadata.py
require_scope(scope)
¶
Require a scope decision for a class or method boundary.
Source code in core/spakky-auth/src/spakky/auth/metadata.py
get_effective_auth_metadata(obj, *, owner_type=None)
¶
Aggregate class and method auth metadata using AND semantics.
Source code in core/spakky-auth/src/spakky/auth/metadata.py
has_auth_boundary_metadata(obj)
¶
Return whether an object or any method declares auth metadata.
Source code in core/spakky-auth/src/spakky/auth/metadata.py
ABC ports for provider-neutral auth providers.
AuthorizationRequest(*, auth_context, resource, action, tenant=None)
dataclass
¶
Provider-neutral policy evaluation request.
auth_context
instance-attribute
¶
Authenticated subject context.
resource
instance-attribute
¶
Canonical resource reference being accessed.
action
instance-attribute
¶
Canonical action reference being attempted.
tenant = None
class-attribute
instance-attribute
¶
Optional tenant reference; None means tenant is not applicable.
PermissionCheckRequest(*, auth_context, permission, resource=None, tenant=None)
dataclass
¶
Permission check request scoped to an authenticated subject.
auth_context
instance-attribute
¶
Authenticated subject context.
permission
instance-attribute
¶
Canonical permission reference.
resource = None
class-attribute
instance-attribute
¶
Optional resource reference; None means resource-independent.
tenant = None
class-attribute
instance-attribute
¶
Optional tenant reference; None means tenant is not applicable.
RoleCheckRequest(*, auth_context, role, tenant=None)
dataclass
¶
ScopeCheckRequest(*, auth_context, scope)
dataclass
¶
RelationCheckRequest(*, auth_context, relation, resource, tenant=None)
dataclass
¶
Relationship authorization request scoped to a resource.
auth_context
instance-attribute
¶
Authenticated subject context.
relation
instance-attribute
¶
Canonical relationship reference.
resource
instance-attribute
¶
Canonical resource reference for the relationship check.
tenant = None
class-attribute
instance-attribute
¶
Optional tenant reference; None means tenant is not applicable.
SnapshotSignRequest(*, auth_context, tenant=None)
dataclass
¶
IAuthenticationProvider
¶
Bases: ABC
Provider-neutral authentication port.
authenticate(credential, invocation)
abstractmethod
¶
Authenticate a credential observed at an invocation boundary.
IAuthorizationPolicyEvaluator
¶
IPermissionChecker
¶
IRoleChecker
¶
Bases: ABC
Provider-neutral role check port.
IScopeChecker
¶
Bases: ABC
Provider-neutral scope check port.
IRelationChecker
¶
IAuthContextSnapshotSigner
¶
Bases: ABC
Provider-neutral AuthContextSnapshot signing port.
sign_snapshot(request)
abstractmethod
¶
IAuthContextSnapshotVerifier
¶
Bases: ABC
Provider-neutral AuthContextSnapshot verification port.
verify_snapshot(snapshot_envelope, invocation)
abstractmethod
¶
Verify a signed snapshot envelope and return its auth context.
IPasswordHasher
¶
IPasswordVerifier
¶
Bases: ABC
Provider-neutral password verification port.
verify_password(password, password_hash)
abstractmethod
¶
Verify plaintext password material against a stored hash.
Signed AuthContextSnapshot envelope contract.
AuthContextSnapshotSignature(*, key_id, algorithm, signature)
dataclass
¶
Signature material carried with a signed AuthContextSnapshot envelope.
AuthContextSnapshot(*, subject, issuer, issued_at, expires_at, signature, schema_version=AUTH_CONTEXT_SNAPSHOT_SCHEMA_VERSION, tenant=None, roles=(), scopes=(), selected_claims=(), correlation_id=None, delegation_chain=())
dataclass
¶
Canonical JSON signed envelope propagated instead of raw credentials.
subject
instance-attribute
¶
Subject represented by this snapshot.
issuer
instance-attribute
¶
Issuer that created the snapshot.
issued_at
instance-attribute
¶
Snapshot issue timestamp.
expires_at
instance-attribute
¶
Snapshot expiration timestamp.
signature
instance-attribute
¶
Signature material required by verification providers.
schema_version = AUTH_CONTEXT_SNAPSHOT_SCHEMA_VERSION
class-attribute
instance-attribute
¶
Canonical snapshot schema version.
tenant = None
class-attribute
instance-attribute
¶
Optional tenant canonical reference.
roles = ()
class-attribute
instance-attribute
¶
Role canonical references included in the snapshot.
scopes = ()
class-attribute
instance-attribute
¶
Scope canonical references included in the snapshot.
selected_claims = ()
class-attribute
instance-attribute
¶
Selected claims included in the signed snapshot.
correlation_id = None
class-attribute
instance-attribute
¶
Optional trace/correlation reference for the propagated context.
delegation_chain = ()
class-attribute
instance-attribute
¶
Ordered subject/service delegation references.
canonical_payload()
¶
Return canonical JSON-ready signed envelope payload.
Source code in core/spakky-auth/src/spakky/auth/snapshot.py
canonical_json()
¶
Return compact, sorted canonical JSON for the signed envelope.
base64url_canonical_json()
¶
Return unpadded base64url canonical JSON envelope text.
Feature-local startup validation for auth capability contributions.
AUTH_STARTUP_VALIDATION_ERROR_DETAIL_KEY = 'auth.capability.validation.error'
module-attribute
¶
Startup diagnostic detail key for invalid auth capability provider counts.
SPAKKY_AUTH_SNAPSHOT_PROPAGATION_CONFIG_ENV_PREFIX = 'SPAKKY_AUTH_SNAPSHOT_PROPAGATION_'
module-attribute
¶
Environment prefix for signed AuthContextSnapshot propagation settings.
AuthSnapshotPropagationConfig
¶
Bases: BaseSettings
Feature-local config declaring signed AuthContextSnapshot propagation use.
enabled = False
class-attribute
instance-attribute
¶
Whether this application propagates signed AuthContextSnapshot envelopes.
AuthStartupCapabilityDiagnostic(*, capability, provider_count, provider_ids, required_by)
dataclass
¶
Structured diagnostic for one invalid required auth capability count.
capability
instance-attribute
¶
Capability required by protected metadata or snapshot propagation.
provider_count
instance-attribute
¶
Number of auth provider contributions declaring the capability.
provider_ids
instance-attribute
¶
Provider identifiers declaring the capability.
required_by
instance-attribute
¶
Startup configuration or scanned boundary sources requiring the capability.
as_startup_diagnostic_detail()
¶
Convert this auth diagnostic into a startup report detail.
Source code in core/spakky-auth/src/spakky/auth/startup.py
AuthStartupCapabilityValidationError(diagnostics)
¶
Bases: AbstractSpakkyAuthError, IStartupDiagnosticDetailProvider
Raised when required auth capabilities have zero or multiple providers.
Source code in core/spakky-auth/src/spakky/auth/startup.py
startup_diagnostic_details
property
¶
Return diagnostics attachable to the startup failure summary.
AuthStartupContainerUnavailableError
¶
AuthCapabilityStartupValidator(container)
¶
Validate auth capability providers required by this application.
Source code in core/spakky-auth/src/spakky/auth/startup.py
validate()
¶
Validate required capability provider counts and fail fast on mismatch.
Source code in core/spakky-auth/src/spakky/auth/startup.py
AuthCapabilityStartupValidationService()
¶
Bases: IService, IContainerAware
Service that runs auth capability validation before user services start.
Source code in core/spakky-auth/src/spakky/auth/startup.py
auth_snapshot_propagation_config()
¶
Load signed AuthContextSnapshot propagation settings from environment.
Source code in core/spakky-auth/src/spakky/auth/startup.py
effective_auth_snapshot_propagation_config(configs)
¶
Collapse all registered snapshot propagation configs into one decision.
Source code in core/spakky-auth/src/spakky/auth/startup.py
Aspect¶
AOP enforcement for protected auth metadata.
AuthorizationAspect(application_context=None, authorization_policy_evaluator=None, permission_checker=None, relation_checker=None, role_checker=None, scope_checker=None)
¶
Bases: IAspect, IApplicationContextAware
Synchronous aspect enforcing protected auth metadata.
Source code in core/spakky-auth/src/spakky/auth/aspects/authorization.py
set_application_context(application_context)
¶
Inject the application context when managed as a Pod.
AsyncAuthorizationAspect(application_context=None, authorization_policy_evaluator=None, permission_checker=None, relation_checker=None, role_checker=None, scope_checker=None)
¶
Bases: IAsyncAspect, IApplicationContextAware
Asynchronous aspect enforcing protected auth metadata.
Source code in core/spakky-auth/src/spakky/auth/aspects/authorization.py
set_application_context(application_context)
¶
Inject the application context when managed as a Pod.
Error hierarchy for spakky-auth semantic model contracts.
AbstractSpakkyAuthError
¶
AuthContextError
¶
AuthContextNotFoundError
¶
InvalidAuthContextValueError
¶
CredentialCarrierError
¶
AuthenticationError
¶
Bases: AbstractSpakkyAuthError
Raised when authentication fails before authorization policy evaluation.
AuthorizationError
¶
ConflictingAuthMetadataError
¶
AuthRequirementDeniedError(decision=None)
¶
Bases: AuthorizationError
Raised when an auth requirement decision is not ALLOW.
Source code in core/spakky-auth/src/spakky/auth/error.py
AuthRequirementProviderUnavailableError
¶
AuthContextSnapshotError
¶
MissingAuthContextSnapshotError
¶
InvalidAuthContextSnapshotError
¶
ExpiredAuthContextSnapshotError
¶
Bases: AuthContextSnapshotError
Raised when snapshot propagation metadata is outside its time window.