spakky-auth 6.5.0__tar.gz
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.
- spakky_auth-6.5.0/PKG-INFO +120 -0
- spakky_auth-6.5.0/README.md +109 -0
- spakky_auth-6.5.0/pyproject.toml +70 -0
- spakky_auth-6.5.0/src/spakky/auth/__init__.py +232 -0
- spakky_auth-6.5.0/src/spakky/auth/aspects/__init__.py +8 -0
- spakky_auth-6.5.0/src/spakky/auth/aspects/authorization.py +281 -0
- spakky_auth-6.5.0/src/spakky/auth/capability.py +18 -0
- spakky_auth-6.5.0/src/spakky/auth/constants.py +16 -0
- spakky_auth-6.5.0/src/spakky/auth/context.py +78 -0
- spakky_auth-6.5.0/src/spakky/auth/contribution.py +25 -0
- spakky_auth-6.5.0/src/spakky/auth/credential.py +46 -0
- spakky_auth-6.5.0/src/spakky/auth/decision.py +116 -0
- spakky_auth-6.5.0/src/spakky/auth/error.py +101 -0
- spakky_auth-6.5.0/src/spakky/auth/invocation.py +78 -0
- spakky_auth-6.5.0/src/spakky/auth/main.py +17 -0
- spakky_auth-6.5.0/src/spakky/auth/metadata.py +260 -0
- spakky_auth-6.5.0/src/spakky/auth/ports.py +228 -0
- spakky_auth-6.5.0/src/spakky/auth/py.typed +1 -0
- spakky_auth-6.5.0/src/spakky/auth/snapshot.py +96 -0
- spakky_auth-6.5.0/src/spakky/auth/startup.py +307 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: spakky-auth
|
|
3
|
+
Version: 6.5.0
|
|
4
|
+
Summary: Provider-neutral authentication and authorization contracts for Spakky Framework
|
|
5
|
+
Author: Spakky
|
|
6
|
+
Author-email: Spakky <sejong418@icloud.com>
|
|
7
|
+
License: MIT
|
|
8
|
+
Requires-Dist: spakky>=6.5.0
|
|
9
|
+
Requires-Python: >=3.12
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
|
|
12
|
+
# Spakky Auth
|
|
13
|
+
|
|
14
|
+
[Spakky Framework](https://github.com/E5presso/spakky-framework)를 위한 provider-neutral authentication and authorization core package입니다.
|
|
15
|
+
|
|
16
|
+
## 설치
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
pip install spakky-auth
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## 현재 범위
|
|
23
|
+
|
|
24
|
+
`spakky-auth`는 인증/인가 마일스톤의 provider-neutral semantic model과 public provider contract를 소유합니다. Provider plugin과 boundary integration이 의존할 수 있는 `spakky.auth` import root, package metadata, workspace registration, documentation API path와 함께 다음 core 계약을 제공합니다.
|
|
25
|
+
|
|
26
|
+
- `AuthContext`, `AuthSubject`, `AuthClaim`: inbound adapter가 사용자 호출 전에 `ApplicationContext` context value에 seed하는 인증 상태
|
|
27
|
+
- `CredentialCarrier`: provider가 해석할 boundary-local credential 전달체
|
|
28
|
+
- `AuthorizationDecision`, `AuthorizationDecisionState`, `AuthorizationReasonCode`: `ALLOW`, `CHALLENGE`, `DENY`, `ERROR` 판정 모델
|
|
29
|
+
- `AuthContextSnapshot`: raw bearer token 대신 task/broker/saga 등으로 전파하는 signed snapshot envelope 계약
|
|
30
|
+
- `AuthCapability`: authentication, policy evaluation, permission/role/scope/relation check, snapshot sign/verify, password hash/verify capability 선언
|
|
31
|
+
- `IAuthenticationProvider`, `IAuthorizationPolicyEvaluator`, `IPermissionChecker`, `IRoleChecker`, `IScopeChecker`, `IRelationChecker`, `IAuthContextSnapshotSigner`, `IAuthContextSnapshotVerifier`, `IPasswordHasher`, `IPasswordVerifier`: ABC + `abstractmethod` 기반 public provider port
|
|
32
|
+
- `AuthInvocation`, `AuthDynamicRef`, `IAuthInvocationResolver`: resource/action/tenant dynamic ref를 invocation에서 resolve하기 위한 provider-neutral 계약
|
|
33
|
+
- `AuthProviderContribution`: `spakky.contributions.spakky.auth` feature-local contribution이 capability set을 선언하기 위한 metadata 계약
|
|
34
|
+
- `AuthSnapshotPropagationConfig`: signed `AuthContextSnapshot` 전파 사용 여부를 선언하는 feature-local config
|
|
35
|
+
- `public_access`, `protected`, `require_scope`, `require_role`, `require_permission`, `require_policy`, `require_relation`: class/function boundary에 public/protected auth metadata를 선언하는 Spakky-native decorator
|
|
36
|
+
- `get_effective_auth_metadata`: class-level과 method-level requirement를 AND semantics로 결합하고 exact duplicate canonical requirement를 idempotent하게 deduplicate하는 metadata aggregation API
|
|
37
|
+
- `AuthorizationAspect`, `AsyncAuthorizationAspect`: request-scope `AuthContext`를 읽어 protected metadata를 sync/async AOP로 enforcement하는 component
|
|
38
|
+
- `AuthCapabilityStartupValidationService`: plugin load/scan 이후 service start 이전에 protected metadata와 snapshot propagation config가 요구하는 `AuthCapability` 제공자 count를 검증하는 startup service
|
|
39
|
+
- `AbstractSpakkyAuthError` 기반 auth 오류 hierarchy
|
|
40
|
+
|
|
41
|
+
Provider implementation과 boundary integration은 후속 이슈에서 추가됩니다. Decorator가 없는 boundary는 allow all이며, protected/decorated boundary는 request-scope `AuthContext`와 provider-neutral checker port를 통해 fail closed로 처리됩니다.
|
|
42
|
+
|
|
43
|
+
## Decorator Metadata & AOP Enforcement
|
|
44
|
+
|
|
45
|
+
Public boundary는 `@public_access`로 명시하고, 인증만 필요한 boundary는 `@protected`로 표시합니다. 권한 requirement는 다음 decorator로 추가합니다.
|
|
46
|
+
|
|
47
|
+
```python
|
|
48
|
+
from spakky.auth import protected, require_role, require_scope
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
@require_role("role:admin")
|
|
52
|
+
class DocumentController:
|
|
53
|
+
@require_scope("documents:read")
|
|
54
|
+
@protected
|
|
55
|
+
def read(self) -> str:
|
|
56
|
+
return "ok"
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Stacked requirement는 canonical `AuthRequirement` tuple로 aggregate되며, exact duplicate는 제거됩니다. Class-level requirement와 method-level requirement는 AND semantics로 결합됩니다. `public_access`와 protected requirement가 effective metadata에서 동시에 관찰되면 `ConflictingAuthMetadataError`가 발생합니다. OR/ANY semantics는 decorator 조합이 아니라 후속 `spakky-policy` named policy로 표현합니다.
|
|
60
|
+
|
|
61
|
+
`AuthorizationAspect`와 `AsyncAuthorizationAspect`는 메서드 인자로 `AuthContext`를 요구하지 않습니다. 각 inbound adapter가 `ApplicationContext` request/context scope에 seed한 `AuthContext`를 `require_auth_context()`로 읽고, provider-neutral checker port decision이 `ALLOW`가 아니면 `AuthRequirementDeniedError`로 실패합니다. 이 오류는 non-ALLOW `AuthorizationDecision`을 `decision` 속성에 보존하므로 inbound adapter는 원래 reason code를 CLI/HTTP/gRPC 등 transport별 응답으로 매핑할 수 있습니다.
|
|
62
|
+
|
|
63
|
+
## Provider Contribution Contract
|
|
64
|
+
|
|
65
|
+
Auth provider plugin은 base plugin entry point와 별도로 `spakky.contributions.spakky.auth` contribution entry point를 선언하고, 해당 contribution에서 `AuthProviderContribution` capability set과 필요한 port 구현 Pod을 등록합니다. Core `spakky-auth`는 provider plugin 이름이나 provider-specific 문자열로 분기하지 않습니다. Capability count 검증과 protected boundary enforcement는 feature-local startup validation 및 AOP로 연결됩니다.
|
|
66
|
+
|
|
67
|
+
## Startup Capability Validation
|
|
68
|
+
|
|
69
|
+
`initialize()`는 `AuthCapabilityStartupValidationService`를 등록합니다. 이 service는 `load_plugins()`와 `scan()`으로 등록된 Pod metadata 및 `AuthProviderContribution` contribution을 기준으로 service lifecycle start 전에 fail-fast validation을 수행합니다.
|
|
70
|
+
|
|
71
|
+
- protected metadata가 하나라도 있으면 `AUTHENTICATION` capability 제공자가 정확히 1개 필요합니다.
|
|
72
|
+
- `require_permission`, `require_role`, `require_scope`, `require_policy`, `require_relation` metadata는 각각 `PERMISSION_CHECK`, `ROLE_CHECK`, `SCOPE_CHECK`, `POLICY_EVALUATION`, `RELATION_CHECK` 제공자가 정확히 1개 필요합니다.
|
|
73
|
+
- enabled `AuthSnapshotPropagationConfig`가 있으면 `SNAPSHOT_SIGN`, `SNAPSHOT_VERIFY` 제공자가 각각 정확히 1개 필요합니다.
|
|
74
|
+
- protected usage와 enabled snapshot propagation config가 모두 없으면 provider가 없어도 startup fatal이 아닙니다.
|
|
75
|
+
|
|
76
|
+
count가 0 또는 2 이상이면 `AuthStartupCapabilityValidationError`가 발생하며, 각 mismatch는 `auth.capability.validation.error` startup diagnostic detail로 노출됩니다. 이 검증은 `spakky-auth` feature-local capability count 확인만 수행하며 generic contribution routing이나 provider priority/routing은 구현하지 않습니다.
|
|
77
|
+
|
|
78
|
+
## Context & Snapshot Keys
|
|
79
|
+
|
|
80
|
+
`AuthContext`는 `spakky.auth.context` key로 `ApplicationContext.set_context_value()`에 저장됩니다. 편의 함수 `store_auth_context()`와 `require_auth_context()`는 이 key를 사용합니다.
|
|
81
|
+
|
|
82
|
+
`AuthContextSnapshot` 전파 key는 다음과 같습니다.
|
|
83
|
+
|
|
84
|
+
| 용도 | Key |
|
|
85
|
+
|------|-----|
|
|
86
|
+
| metadata | `spakky.auth.context_snapshot` |
|
|
87
|
+
| header | `x-spakky-auth-context-snapshot` |
|
|
88
|
+
|
|
89
|
+
snapshot envelope는 schema version, subject, issuer, tenant, roles, scopes, selected claims, issued/expires timestamp, correlation id, delegation chain, signature material을 포함하는 canonical JSON을 unpadded base64url로 인코딩한 값입니다. 기본 clock skew는 60초입니다.
|
|
90
|
+
|
|
91
|
+
missing, invalid, expired snapshot은 기본적으로 `CHALLENGE` decision이며, verification provider unavailable은 `ERROR` decision입니다.
|
|
92
|
+
|
|
93
|
+
## Plugin Entry Point
|
|
94
|
+
|
|
95
|
+
패키지는 Spakky plugin discovery를 위해 다음 entry point를 등록합니다.
|
|
96
|
+
|
|
97
|
+
```toml
|
|
98
|
+
[project.entry-points."spakky.plugins"]
|
|
99
|
+
spakky-auth = "spakky.auth.main:initialize"
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
현재 `initialize()`는 `AuthCapabilityStartupValidationService`, `AuthorizationAspect`, `AsyncAuthorizationAspect`를 등록합니다. 후속 이슈에서 boundary integration이 추가되면 같은 entry point를 통해 feature-local component를 등록합니다.
|
|
103
|
+
|
|
104
|
+
## 개발 검증
|
|
105
|
+
|
|
106
|
+
패키지 단위 검증은 패키지 디렉토리에서 실행합니다.
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
cd core/spakky-auth
|
|
110
|
+
uv run ruff format .
|
|
111
|
+
uv run ruff check .
|
|
112
|
+
uv run pyrefly check
|
|
113
|
+
uv run pytest
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
`pytest`는 `pyproject.toml`의 coverage 설정을 사용하며 `src/spakky/auth/**/*.py`에 대해 100% coverage를 요구합니다.
|
|
117
|
+
|
|
118
|
+
## 라이선스
|
|
119
|
+
|
|
120
|
+
MIT License
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# Spakky Auth
|
|
2
|
+
|
|
3
|
+
[Spakky Framework](https://github.com/E5presso/spakky-framework)를 위한 provider-neutral authentication and authorization core package입니다.
|
|
4
|
+
|
|
5
|
+
## 설치
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install spakky-auth
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## 현재 범위
|
|
12
|
+
|
|
13
|
+
`spakky-auth`는 인증/인가 마일스톤의 provider-neutral semantic model과 public provider contract를 소유합니다. Provider plugin과 boundary integration이 의존할 수 있는 `spakky.auth` import root, package metadata, workspace registration, documentation API path와 함께 다음 core 계약을 제공합니다.
|
|
14
|
+
|
|
15
|
+
- `AuthContext`, `AuthSubject`, `AuthClaim`: inbound adapter가 사용자 호출 전에 `ApplicationContext` context value에 seed하는 인증 상태
|
|
16
|
+
- `CredentialCarrier`: provider가 해석할 boundary-local credential 전달체
|
|
17
|
+
- `AuthorizationDecision`, `AuthorizationDecisionState`, `AuthorizationReasonCode`: `ALLOW`, `CHALLENGE`, `DENY`, `ERROR` 판정 모델
|
|
18
|
+
- `AuthContextSnapshot`: raw bearer token 대신 task/broker/saga 등으로 전파하는 signed snapshot envelope 계약
|
|
19
|
+
- `AuthCapability`: authentication, policy evaluation, permission/role/scope/relation check, snapshot sign/verify, password hash/verify capability 선언
|
|
20
|
+
- `IAuthenticationProvider`, `IAuthorizationPolicyEvaluator`, `IPermissionChecker`, `IRoleChecker`, `IScopeChecker`, `IRelationChecker`, `IAuthContextSnapshotSigner`, `IAuthContextSnapshotVerifier`, `IPasswordHasher`, `IPasswordVerifier`: ABC + `abstractmethod` 기반 public provider port
|
|
21
|
+
- `AuthInvocation`, `AuthDynamicRef`, `IAuthInvocationResolver`: resource/action/tenant dynamic ref를 invocation에서 resolve하기 위한 provider-neutral 계약
|
|
22
|
+
- `AuthProviderContribution`: `spakky.contributions.spakky.auth` feature-local contribution이 capability set을 선언하기 위한 metadata 계약
|
|
23
|
+
- `AuthSnapshotPropagationConfig`: signed `AuthContextSnapshot` 전파 사용 여부를 선언하는 feature-local config
|
|
24
|
+
- `public_access`, `protected`, `require_scope`, `require_role`, `require_permission`, `require_policy`, `require_relation`: class/function boundary에 public/protected auth metadata를 선언하는 Spakky-native decorator
|
|
25
|
+
- `get_effective_auth_metadata`: class-level과 method-level requirement를 AND semantics로 결합하고 exact duplicate canonical requirement를 idempotent하게 deduplicate하는 metadata aggregation API
|
|
26
|
+
- `AuthorizationAspect`, `AsyncAuthorizationAspect`: request-scope `AuthContext`를 읽어 protected metadata를 sync/async AOP로 enforcement하는 component
|
|
27
|
+
- `AuthCapabilityStartupValidationService`: plugin load/scan 이후 service start 이전에 protected metadata와 snapshot propagation config가 요구하는 `AuthCapability` 제공자 count를 검증하는 startup service
|
|
28
|
+
- `AbstractSpakkyAuthError` 기반 auth 오류 hierarchy
|
|
29
|
+
|
|
30
|
+
Provider implementation과 boundary integration은 후속 이슈에서 추가됩니다. Decorator가 없는 boundary는 allow all이며, protected/decorated boundary는 request-scope `AuthContext`와 provider-neutral checker port를 통해 fail closed로 처리됩니다.
|
|
31
|
+
|
|
32
|
+
## Decorator Metadata & AOP Enforcement
|
|
33
|
+
|
|
34
|
+
Public boundary는 `@public_access`로 명시하고, 인증만 필요한 boundary는 `@protected`로 표시합니다. 권한 requirement는 다음 decorator로 추가합니다.
|
|
35
|
+
|
|
36
|
+
```python
|
|
37
|
+
from spakky.auth import protected, require_role, require_scope
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
@require_role("role:admin")
|
|
41
|
+
class DocumentController:
|
|
42
|
+
@require_scope("documents:read")
|
|
43
|
+
@protected
|
|
44
|
+
def read(self) -> str:
|
|
45
|
+
return "ok"
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Stacked requirement는 canonical `AuthRequirement` tuple로 aggregate되며, exact duplicate는 제거됩니다. Class-level requirement와 method-level requirement는 AND semantics로 결합됩니다. `public_access`와 protected requirement가 effective metadata에서 동시에 관찰되면 `ConflictingAuthMetadataError`가 발생합니다. OR/ANY semantics는 decorator 조합이 아니라 후속 `spakky-policy` named policy로 표현합니다.
|
|
49
|
+
|
|
50
|
+
`AuthorizationAspect`와 `AsyncAuthorizationAspect`는 메서드 인자로 `AuthContext`를 요구하지 않습니다. 각 inbound adapter가 `ApplicationContext` request/context scope에 seed한 `AuthContext`를 `require_auth_context()`로 읽고, provider-neutral checker port decision이 `ALLOW`가 아니면 `AuthRequirementDeniedError`로 실패합니다. 이 오류는 non-ALLOW `AuthorizationDecision`을 `decision` 속성에 보존하므로 inbound adapter는 원래 reason code를 CLI/HTTP/gRPC 등 transport별 응답으로 매핑할 수 있습니다.
|
|
51
|
+
|
|
52
|
+
## Provider Contribution Contract
|
|
53
|
+
|
|
54
|
+
Auth provider plugin은 base plugin entry point와 별도로 `spakky.contributions.spakky.auth` contribution entry point를 선언하고, 해당 contribution에서 `AuthProviderContribution` capability set과 필요한 port 구현 Pod을 등록합니다. Core `spakky-auth`는 provider plugin 이름이나 provider-specific 문자열로 분기하지 않습니다. Capability count 검증과 protected boundary enforcement는 feature-local startup validation 및 AOP로 연결됩니다.
|
|
55
|
+
|
|
56
|
+
## Startup Capability Validation
|
|
57
|
+
|
|
58
|
+
`initialize()`는 `AuthCapabilityStartupValidationService`를 등록합니다. 이 service는 `load_plugins()`와 `scan()`으로 등록된 Pod metadata 및 `AuthProviderContribution` contribution을 기준으로 service lifecycle start 전에 fail-fast validation을 수행합니다.
|
|
59
|
+
|
|
60
|
+
- protected metadata가 하나라도 있으면 `AUTHENTICATION` capability 제공자가 정확히 1개 필요합니다.
|
|
61
|
+
- `require_permission`, `require_role`, `require_scope`, `require_policy`, `require_relation` metadata는 각각 `PERMISSION_CHECK`, `ROLE_CHECK`, `SCOPE_CHECK`, `POLICY_EVALUATION`, `RELATION_CHECK` 제공자가 정확히 1개 필요합니다.
|
|
62
|
+
- enabled `AuthSnapshotPropagationConfig`가 있으면 `SNAPSHOT_SIGN`, `SNAPSHOT_VERIFY` 제공자가 각각 정확히 1개 필요합니다.
|
|
63
|
+
- protected usage와 enabled snapshot propagation config가 모두 없으면 provider가 없어도 startup fatal이 아닙니다.
|
|
64
|
+
|
|
65
|
+
count가 0 또는 2 이상이면 `AuthStartupCapabilityValidationError`가 발생하며, 각 mismatch는 `auth.capability.validation.error` startup diagnostic detail로 노출됩니다. 이 검증은 `spakky-auth` feature-local capability count 확인만 수행하며 generic contribution routing이나 provider priority/routing은 구현하지 않습니다.
|
|
66
|
+
|
|
67
|
+
## Context & Snapshot Keys
|
|
68
|
+
|
|
69
|
+
`AuthContext`는 `spakky.auth.context` key로 `ApplicationContext.set_context_value()`에 저장됩니다. 편의 함수 `store_auth_context()`와 `require_auth_context()`는 이 key를 사용합니다.
|
|
70
|
+
|
|
71
|
+
`AuthContextSnapshot` 전파 key는 다음과 같습니다.
|
|
72
|
+
|
|
73
|
+
| 용도 | Key |
|
|
74
|
+
|------|-----|
|
|
75
|
+
| metadata | `spakky.auth.context_snapshot` |
|
|
76
|
+
| header | `x-spakky-auth-context-snapshot` |
|
|
77
|
+
|
|
78
|
+
snapshot envelope는 schema version, subject, issuer, tenant, roles, scopes, selected claims, issued/expires timestamp, correlation id, delegation chain, signature material을 포함하는 canonical JSON을 unpadded base64url로 인코딩한 값입니다. 기본 clock skew는 60초입니다.
|
|
79
|
+
|
|
80
|
+
missing, invalid, expired snapshot은 기본적으로 `CHALLENGE` decision이며, verification provider unavailable은 `ERROR` decision입니다.
|
|
81
|
+
|
|
82
|
+
## Plugin Entry Point
|
|
83
|
+
|
|
84
|
+
패키지는 Spakky plugin discovery를 위해 다음 entry point를 등록합니다.
|
|
85
|
+
|
|
86
|
+
```toml
|
|
87
|
+
[project.entry-points."spakky.plugins"]
|
|
88
|
+
spakky-auth = "spakky.auth.main:initialize"
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
현재 `initialize()`는 `AuthCapabilityStartupValidationService`, `AuthorizationAspect`, `AsyncAuthorizationAspect`를 등록합니다. 후속 이슈에서 boundary integration이 추가되면 같은 entry point를 통해 feature-local component를 등록합니다.
|
|
92
|
+
|
|
93
|
+
## 개발 검증
|
|
94
|
+
|
|
95
|
+
패키지 단위 검증은 패키지 디렉토리에서 실행합니다.
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
cd core/spakky-auth
|
|
99
|
+
uv run ruff format .
|
|
100
|
+
uv run ruff check .
|
|
101
|
+
uv run pyrefly check
|
|
102
|
+
uv run pytest
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
`pytest`는 `pyproject.toml`의 coverage 설정을 사용하며 `src/spakky/auth/**/*.py`에 대해 100% coverage를 요구합니다.
|
|
106
|
+
|
|
107
|
+
## 라이선스
|
|
108
|
+
|
|
109
|
+
MIT License
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "spakky-auth"
|
|
3
|
+
version = "6.5.0"
|
|
4
|
+
description = "Provider-neutral authentication and authorization contracts for Spakky Framework"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.12"
|
|
7
|
+
license = { text = "MIT" }
|
|
8
|
+
authors = [{ name = "Spakky", email = "sejong418@icloud.com" }]
|
|
9
|
+
dependencies = ["spakky>=6.5.0"]
|
|
10
|
+
|
|
11
|
+
[project.entry-points."spakky.plugins"]
|
|
12
|
+
spakky-auth = "spakky.auth.main:initialize"
|
|
13
|
+
|
|
14
|
+
[build-system]
|
|
15
|
+
requires = ["uv_build>=0.10.10,<0.11.0"]
|
|
16
|
+
build-backend = "uv_build"
|
|
17
|
+
|
|
18
|
+
[tool.uv.build-backend]
|
|
19
|
+
module-root = "src"
|
|
20
|
+
module-name = "spakky.auth"
|
|
21
|
+
|
|
22
|
+
[tool.pyrefly]
|
|
23
|
+
python-version = "3.12"
|
|
24
|
+
search_path = ["src", ".", "../spakky/src"]
|
|
25
|
+
project_excludes = ["**/__pycache__", "**/*.pyc"]
|
|
26
|
+
|
|
27
|
+
[tool.ruff]
|
|
28
|
+
builtins = ["_"]
|
|
29
|
+
cache-dir = "~/.cache/ruff"
|
|
30
|
+
|
|
31
|
+
[tool.pytest.ini_options]
|
|
32
|
+
pythonpath = ["src", "../spakky/src"]
|
|
33
|
+
testpaths = "tests"
|
|
34
|
+
python_files = ["test_*.py"]
|
|
35
|
+
asyncio_mode = "auto"
|
|
36
|
+
addopts = """
|
|
37
|
+
--cov
|
|
38
|
+
--cov-report=term
|
|
39
|
+
--cov-report=xml
|
|
40
|
+
--no-cov-on-fail
|
|
41
|
+
--strict-markers
|
|
42
|
+
--dist=load
|
|
43
|
+
-p no:warnings
|
|
44
|
+
-n auto
|
|
45
|
+
--spec
|
|
46
|
+
"""
|
|
47
|
+
spec_test_format = "{result} {docstring_summary}"
|
|
48
|
+
|
|
49
|
+
[tool.coverage.run]
|
|
50
|
+
include = ["src/spakky/auth/**/*.py"]
|
|
51
|
+
branch = true
|
|
52
|
+
|
|
53
|
+
[tool.coverage.report]
|
|
54
|
+
show_missing = true
|
|
55
|
+
precision = 2
|
|
56
|
+
fail_under = 100
|
|
57
|
+
skip_empty = true
|
|
58
|
+
exclude_lines = [
|
|
59
|
+
"pragma: no cover",
|
|
60
|
+
"def __repr__",
|
|
61
|
+
"raise AssertionError",
|
|
62
|
+
"raise NotImplementedError",
|
|
63
|
+
"@(abc\\.)?abstractmethod",
|
|
64
|
+
"@(typing\\.)?overload",
|
|
65
|
+
"\\.\\.\\.",
|
|
66
|
+
"pass",
|
|
67
|
+
]
|
|
68
|
+
|
|
69
|
+
[tool.uv.sources]
|
|
70
|
+
spakky = { workspace = true }
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
"""Provider-neutral authentication and authorization package root."""
|
|
2
|
+
|
|
3
|
+
from spakky.auth.constants import (
|
|
4
|
+
AUTH_CONTEXT_CONTEXT_KEY,
|
|
5
|
+
AUTH_CONTEXT_SNAPSHOT_HEADER_KEY,
|
|
6
|
+
AUTH_CONTEXT_SNAPSHOT_METADATA_KEY,
|
|
7
|
+
AUTH_CONTEXT_SNAPSHOT_SCHEMA_VERSION,
|
|
8
|
+
DEFAULT_AUTH_CLOCK_SKEW_SECONDS,
|
|
9
|
+
)
|
|
10
|
+
from spakky.auth.aspects import AsyncAuthorizationAspect, AuthorizationAspect
|
|
11
|
+
from spakky.auth.capability import AuthCapability
|
|
12
|
+
from spakky.auth.contribution import (
|
|
13
|
+
AUTH_CONTRIBUTION_ENTRY_POINT_GROUP,
|
|
14
|
+
AuthContributionProviderId,
|
|
15
|
+
AuthProviderContribution,
|
|
16
|
+
)
|
|
17
|
+
from spakky.auth.context import (
|
|
18
|
+
AuthClaim,
|
|
19
|
+
AuthClaimValue,
|
|
20
|
+
AuthContext,
|
|
21
|
+
AuthSubject,
|
|
22
|
+
require_auth_context,
|
|
23
|
+
store_auth_context,
|
|
24
|
+
)
|
|
25
|
+
from spakky.auth.credential import (
|
|
26
|
+
CredentialCarrier,
|
|
27
|
+
CredentialCarrierKind,
|
|
28
|
+
CredentialCarrierLocation,
|
|
29
|
+
)
|
|
30
|
+
from spakky.auth.decision import (
|
|
31
|
+
EXPIRED_SNAPSHOT_DECISION,
|
|
32
|
+
INVALID_SNAPSHOT_DECISION,
|
|
33
|
+
MISSING_SNAPSHOT_DECISION,
|
|
34
|
+
VERIFICATION_PROVIDER_UNAVAILABLE_DECISION,
|
|
35
|
+
AuthorizationDecision,
|
|
36
|
+
AuthorizationDecisionState,
|
|
37
|
+
AuthorizationReasonCode,
|
|
38
|
+
)
|
|
39
|
+
from spakky.auth.error import (
|
|
40
|
+
AbstractSpakkyAuthError,
|
|
41
|
+
AuthContextError,
|
|
42
|
+
AuthContextNotFoundError,
|
|
43
|
+
AuthRequirementDeniedError,
|
|
44
|
+
AuthRequirementProviderUnavailableError,
|
|
45
|
+
AuthContextSnapshotError,
|
|
46
|
+
AuthVerificationProviderUnavailableError,
|
|
47
|
+
AuthenticationError,
|
|
48
|
+
AuthorizationError,
|
|
49
|
+
ConflictingAuthMetadataError,
|
|
50
|
+
CredentialCarrierError,
|
|
51
|
+
ExpiredAuthContextSnapshotError,
|
|
52
|
+
InvalidAuthContextSnapshotError,
|
|
53
|
+
InvalidAuthContextValueError,
|
|
54
|
+
MissingAuthContextSnapshotError,
|
|
55
|
+
)
|
|
56
|
+
from spakky.auth.invocation import (
|
|
57
|
+
AuthActionRef,
|
|
58
|
+
AuthBoundaryRef,
|
|
59
|
+
AuthDynamicRef,
|
|
60
|
+
AuthDynamicRefExpression,
|
|
61
|
+
AuthDynamicRefKind,
|
|
62
|
+
AuthInvocation,
|
|
63
|
+
AuthInvocationAttribute,
|
|
64
|
+
AuthInvocationAttributeName,
|
|
65
|
+
AuthInvocationAttributeValue,
|
|
66
|
+
AuthInvocationOperationRef,
|
|
67
|
+
AuthPermissionRef,
|
|
68
|
+
AuthRelationRef,
|
|
69
|
+
AuthResolvedRef,
|
|
70
|
+
AuthResourceRef,
|
|
71
|
+
AuthRoleRef,
|
|
72
|
+
AuthScopeRef,
|
|
73
|
+
AuthTenantRef,
|
|
74
|
+
ResolvedAuthReference,
|
|
75
|
+
)
|
|
76
|
+
from spakky.auth.metadata import (
|
|
77
|
+
AUTHENTICATED_REQUIREMENT_REF,
|
|
78
|
+
EffectiveAuthMetadata,
|
|
79
|
+
AuthRequirement,
|
|
80
|
+
AuthRequirementKind,
|
|
81
|
+
ProtectedRequirement,
|
|
82
|
+
PublicAccess,
|
|
83
|
+
get_effective_auth_metadata,
|
|
84
|
+
has_auth_boundary_metadata,
|
|
85
|
+
protected,
|
|
86
|
+
public_access,
|
|
87
|
+
require_permission,
|
|
88
|
+
require_policy,
|
|
89
|
+
require_relation,
|
|
90
|
+
require_role,
|
|
91
|
+
require_scope,
|
|
92
|
+
)
|
|
93
|
+
from spakky.auth.ports import (
|
|
94
|
+
AuthPasswordHash,
|
|
95
|
+
AuthPasswordPlaintext,
|
|
96
|
+
AuthorizationRequest,
|
|
97
|
+
IAuthContextSnapshotSigner,
|
|
98
|
+
IAuthContextSnapshotVerifier,
|
|
99
|
+
IAuthInvocationResolver,
|
|
100
|
+
IAuthenticationProvider,
|
|
101
|
+
IAuthorizationPolicyEvaluator,
|
|
102
|
+
IPasswordHasher,
|
|
103
|
+
IPasswordVerifier,
|
|
104
|
+
IPermissionChecker,
|
|
105
|
+
IRelationChecker,
|
|
106
|
+
IRoleChecker,
|
|
107
|
+
IScopeChecker,
|
|
108
|
+
PermissionCheckRequest,
|
|
109
|
+
RelationCheckRequest,
|
|
110
|
+
RoleCheckRequest,
|
|
111
|
+
ScopeCheckRequest,
|
|
112
|
+
SnapshotSignRequest,
|
|
113
|
+
)
|
|
114
|
+
from spakky.auth.snapshot import AuthContextSnapshot, AuthContextSnapshotSignature
|
|
115
|
+
from spakky.auth.startup import (
|
|
116
|
+
AUTH_STARTUP_VALIDATION_ERROR_DETAIL_KEY,
|
|
117
|
+
AuthCapabilityStartupValidationService,
|
|
118
|
+
AuthSnapshotPropagationConfig,
|
|
119
|
+
AuthStartupCapabilityDiagnostic,
|
|
120
|
+
AuthStartupCapabilityValidationError,
|
|
121
|
+
AuthStartupContainerUnavailableError,
|
|
122
|
+
)
|
|
123
|
+
from spakky.core.application.plugin import Plugin
|
|
124
|
+
|
|
125
|
+
PLUGIN_NAME = Plugin(name="spakky-auth")
|
|
126
|
+
"""Plugin identifier for the Spakky Auth package."""
|
|
127
|
+
|
|
128
|
+
__all__ = [
|
|
129
|
+
"AUTH_CONTEXT_CONTEXT_KEY",
|
|
130
|
+
"AUTH_CONTEXT_SNAPSHOT_HEADER_KEY",
|
|
131
|
+
"AUTH_CONTEXT_SNAPSHOT_METADATA_KEY",
|
|
132
|
+
"AUTH_CONTEXT_SNAPSHOT_SCHEMA_VERSION",
|
|
133
|
+
"AUTH_CONTRIBUTION_ENTRY_POINT_GROUP",
|
|
134
|
+
"AUTH_STARTUP_VALIDATION_ERROR_DETAIL_KEY",
|
|
135
|
+
"DEFAULT_AUTH_CLOCK_SKEW_SECONDS",
|
|
136
|
+
"EXPIRED_SNAPSHOT_DECISION",
|
|
137
|
+
"INVALID_SNAPSHOT_DECISION",
|
|
138
|
+
"MISSING_SNAPSHOT_DECISION",
|
|
139
|
+
"PLUGIN_NAME",
|
|
140
|
+
"VERIFICATION_PROVIDER_UNAVAILABLE_DECISION",
|
|
141
|
+
"AbstractSpakkyAuthError",
|
|
142
|
+
"AuthActionRef",
|
|
143
|
+
"AUTHENTICATED_REQUIREMENT_REF",
|
|
144
|
+
"AuthClaim",
|
|
145
|
+
"AuthClaimValue",
|
|
146
|
+
"AuthBoundaryRef",
|
|
147
|
+
"AuthCapability",
|
|
148
|
+
"AuthCapabilityStartupValidationService",
|
|
149
|
+
"AuthContext",
|
|
150
|
+
"AuthContextError",
|
|
151
|
+
"AuthContextNotFoundError",
|
|
152
|
+
"AuthContextSnapshot",
|
|
153
|
+
"AuthContextSnapshotError",
|
|
154
|
+
"AuthContextSnapshotSignature",
|
|
155
|
+
"AuthContributionProviderId",
|
|
156
|
+
"AuthDynamicRef",
|
|
157
|
+
"AuthDynamicRefExpression",
|
|
158
|
+
"AuthDynamicRefKind",
|
|
159
|
+
"AuthInvocation",
|
|
160
|
+
"AuthInvocationAttribute",
|
|
161
|
+
"AuthInvocationAttributeName",
|
|
162
|
+
"AuthInvocationAttributeValue",
|
|
163
|
+
"AuthInvocationOperationRef",
|
|
164
|
+
"AuthPasswordHash",
|
|
165
|
+
"AuthPasswordPlaintext",
|
|
166
|
+
"AuthPermissionRef",
|
|
167
|
+
"AuthProviderContribution",
|
|
168
|
+
"AuthRequirement",
|
|
169
|
+
"AuthRequirementDeniedError",
|
|
170
|
+
"AuthRequirementKind",
|
|
171
|
+
"AuthRequirementProviderUnavailableError",
|
|
172
|
+
"AuthRelationRef",
|
|
173
|
+
"AuthResolvedRef",
|
|
174
|
+
"AuthResourceRef",
|
|
175
|
+
"AuthRoleRef",
|
|
176
|
+
"AuthScopeRef",
|
|
177
|
+
"AuthSnapshotPropagationConfig",
|
|
178
|
+
"AuthStartupCapabilityDiagnostic",
|
|
179
|
+
"AuthStartupCapabilityValidationError",
|
|
180
|
+
"AuthStartupContainerUnavailableError",
|
|
181
|
+
"AuthSubject",
|
|
182
|
+
"AuthTenantRef",
|
|
183
|
+
"AuthVerificationProviderUnavailableError",
|
|
184
|
+
"AuthenticationError",
|
|
185
|
+
"AuthorizationDecision",
|
|
186
|
+
"AuthorizationDecisionState",
|
|
187
|
+
"AuthorizationError",
|
|
188
|
+
"AuthorizationAspect",
|
|
189
|
+
"AuthorizationRequest",
|
|
190
|
+
"AuthorizationReasonCode",
|
|
191
|
+
"AsyncAuthorizationAspect",
|
|
192
|
+
"ConflictingAuthMetadataError",
|
|
193
|
+
"CredentialCarrier",
|
|
194
|
+
"CredentialCarrierError",
|
|
195
|
+
"CredentialCarrierKind",
|
|
196
|
+
"CredentialCarrierLocation",
|
|
197
|
+
"ExpiredAuthContextSnapshotError",
|
|
198
|
+
"EffectiveAuthMetadata",
|
|
199
|
+
"IAuthContextSnapshotSigner",
|
|
200
|
+
"IAuthContextSnapshotVerifier",
|
|
201
|
+
"IAuthInvocationResolver",
|
|
202
|
+
"IAuthenticationProvider",
|
|
203
|
+
"IAuthorizationPolicyEvaluator",
|
|
204
|
+
"IPasswordHasher",
|
|
205
|
+
"IPasswordVerifier",
|
|
206
|
+
"IPermissionChecker",
|
|
207
|
+
"IRelationChecker",
|
|
208
|
+
"IRoleChecker",
|
|
209
|
+
"IScopeChecker",
|
|
210
|
+
"InvalidAuthContextSnapshotError",
|
|
211
|
+
"InvalidAuthContextValueError",
|
|
212
|
+
"MissingAuthContextSnapshotError",
|
|
213
|
+
"PermissionCheckRequest",
|
|
214
|
+
"ProtectedRequirement",
|
|
215
|
+
"PublicAccess",
|
|
216
|
+
"get_effective_auth_metadata",
|
|
217
|
+
"has_auth_boundary_metadata",
|
|
218
|
+
"protected",
|
|
219
|
+
"public_access",
|
|
220
|
+
"require_auth_context",
|
|
221
|
+
"require_permission",
|
|
222
|
+
"require_policy",
|
|
223
|
+
"require_relation",
|
|
224
|
+
"require_role",
|
|
225
|
+
"require_scope",
|
|
226
|
+
"RelationCheckRequest",
|
|
227
|
+
"ResolvedAuthReference",
|
|
228
|
+
"RoleCheckRequest",
|
|
229
|
+
"ScopeCheckRequest",
|
|
230
|
+
"SnapshotSignRequest",
|
|
231
|
+
"store_auth_context",
|
|
232
|
+
]
|