domain-security 0.1.0__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.
- domain_security/__init__.py +40 -0
- domain_security/config/__init__.py +1 -0
- domain_security/config/_version.py +3 -0
- domain_security/context/__init__.py +1 -0
- domain_security/context/constants/__init__.py +0 -0
- domain_security/context/constants/security_context.py +10 -0
- domain_security/context/security_context/__init__.py +11 -0
- domain_security/context/security_context/security_context_client.py +51 -0
- domain_security/context/security_context/security_context_objects.py +22 -0
- domain_security/decorators/__init__.py +1 -0
- domain_security/decorators/constants/__init__.py +0 -0
- domain_security/decorators/constants/tenant_scoped.py +15 -0
- domain_security/decorators/requires/__init__.py +5 -0
- domain_security/decorators/requires/requires_client.py +54 -0
- domain_security/decorators/tenant_scoped/__init__.py +8 -0
- domain_security/decorators/tenant_scoped/tenant_scoped_client.py +75 -0
- domain_security/errors/__init__.py +1 -0
- domain_security/errors/security_errors.py +37 -0
- domain_security/py.typed +0 -0
- domain_security/services/__init__.py +1 -0
- domain_security/services/authz/__init__.py +6 -0
- domain_security/services/authz/authz_client.py +40 -0
- domain_security/services/authz/authz_objects.py +20 -0
- domain_security/services/constants/__init__.py +0 -0
- domain_security/services/constants/authz.py +10 -0
- domain_security/services/constants/secrets.py +14 -0
- domain_security/services/constants/tenancy.py +10 -0
- domain_security/services/secrets/__init__.py +6 -0
- domain_security/services/secrets/secrets_client.py +27 -0
- domain_security/services/secrets/secrets_objects.py +29 -0
- domain_security/services/tenancy/__init__.py +5 -0
- domain_security/services/tenancy/tenancy_client.py +27 -0
- domain_security-0.1.0.dist-info/METADATA +306 -0
- domain_security-0.1.0.dist-info/RECORD +36 -0
- domain_security-0.1.0.dist-info/WHEEL +4 -0
- domain_security-0.1.0.dist-info/licenses/LICENSE +201 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"""Cross-cutting security concerns: authorization, tenancy, secrets, context management."""
|
|
2
|
+
|
|
3
|
+
from domain_security.config._version import __version__
|
|
4
|
+
from domain_security.context.security_context.security_context_client import (
|
|
5
|
+
SecurityContextManager,
|
|
6
|
+
)
|
|
7
|
+
from domain_security.context.security_context.security_context_objects import (
|
|
8
|
+
Principal,
|
|
9
|
+
SecurityContext,
|
|
10
|
+
)
|
|
11
|
+
from domain_security.decorators.requires.requires_client import requires
|
|
12
|
+
from domain_security.decorators.tenant_scoped.tenant_scoped_client import tenant_scoped
|
|
13
|
+
from domain_security.errors.security_errors import (
|
|
14
|
+
AuthzError,
|
|
15
|
+
SecretError,
|
|
16
|
+
SecurityError,
|
|
17
|
+
TenancyError,
|
|
18
|
+
)
|
|
19
|
+
from domain_security.services.authz.authz_client import Authorizer
|
|
20
|
+
from domain_security.services.authz.authz_objects import Permission, PolicyDecision
|
|
21
|
+
from domain_security.services.secrets.secrets_client import SecretRef
|
|
22
|
+
from domain_security.services.secrets.secrets_objects import SecretValue
|
|
23
|
+
|
|
24
|
+
__all__ = [
|
|
25
|
+
"Authorizer",
|
|
26
|
+
"AuthzError",
|
|
27
|
+
"Permission",
|
|
28
|
+
"PolicyDecision",
|
|
29
|
+
"Principal",
|
|
30
|
+
"SecretError",
|
|
31
|
+
"SecretRef",
|
|
32
|
+
"SecretValue",
|
|
33
|
+
"SecurityContext",
|
|
34
|
+
"SecurityContextManager",
|
|
35
|
+
"SecurityError",
|
|
36
|
+
"TenancyError",
|
|
37
|
+
"__version__",
|
|
38
|
+
"requires",
|
|
39
|
+
"tenant_scoped",
|
|
40
|
+
]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Package configuration."""
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Security context concern."""
|
|
File without changes
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"""Ambient security context: principal and tenant identity with set/get/bind/clear management."""
|
|
2
|
+
|
|
3
|
+
from domain_security.context.security_context.security_context_client import (
|
|
4
|
+
SecurityContextManager,
|
|
5
|
+
)
|
|
6
|
+
from domain_security.context.security_context.security_context_objects import (
|
|
7
|
+
Principal,
|
|
8
|
+
SecurityContext,
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
__all__ = ["Principal", "SecurityContext", "SecurityContextManager"]
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"""Ambient security context management across call boundaries."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from collections.abc import Generator
|
|
6
|
+
from contextlib import AbstractContextManager, contextmanager
|
|
7
|
+
from contextvars import ContextVar, Token
|
|
8
|
+
from typing import ClassVar
|
|
9
|
+
|
|
10
|
+
from domain_security.context.constants import security_context as const
|
|
11
|
+
from domain_security.context.security_context import security_context_objects as objs
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class SecurityContextManager:
|
|
15
|
+
"""Set, read, bind, and clear the ambient security context."""
|
|
16
|
+
|
|
17
|
+
_context: ClassVar[ContextVar[objs.SecurityContext | None]] = ContextVar(
|
|
18
|
+
const.CONTEXT_VAR_NAME, default=None
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
def set(self, ctx: objs.SecurityContext) -> Token[objs.SecurityContext | None]:
|
|
22
|
+
"""Store the context and return the reset token."""
|
|
23
|
+
return self._context.set(ctx)
|
|
24
|
+
|
|
25
|
+
def get(self) -> objs.SecurityContext | None:
|
|
26
|
+
"""Return the current context, or None when unset."""
|
|
27
|
+
return self._context.get()
|
|
28
|
+
|
|
29
|
+
def bind(
|
|
30
|
+
self,
|
|
31
|
+
*,
|
|
32
|
+
principal: objs.Principal | None = None,
|
|
33
|
+
tenant_id: str | None = None,
|
|
34
|
+
) -> AbstractContextManager[None]:
|
|
35
|
+
"""Temporarily bind a fresh context, restoring the prior one on exit."""
|
|
36
|
+
return self._bound(
|
|
37
|
+
objs.SecurityContext(principal=principal, tenant_id=tenant_id)
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
def clear(self, token: Token[objs.SecurityContext | None]) -> None:
|
|
41
|
+
"""Reset the context to its state before the matching set call."""
|
|
42
|
+
self._context.reset(token)
|
|
43
|
+
|
|
44
|
+
@contextmanager
|
|
45
|
+
def _bound(self, ctx: objs.SecurityContext) -> Generator[None, None, None]:
|
|
46
|
+
"""Set the context for the with-block and reset it afterward."""
|
|
47
|
+
token = self.set(ctx)
|
|
48
|
+
try:
|
|
49
|
+
yield
|
|
50
|
+
finally:
|
|
51
|
+
self.clear(token)
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"""Security context value objects: principal identity and the context pairing."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from dataclasses import dataclass
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@dataclass(frozen=True, slots=True)
|
|
9
|
+
class Principal:
|
|
10
|
+
"""Authenticated identity with role and scope membership."""
|
|
11
|
+
|
|
12
|
+
id: str
|
|
13
|
+
roles: frozenset[str] = frozenset()
|
|
14
|
+
scopes: frozenset[str] = frozenset()
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@dataclass(frozen=True, slots=True)
|
|
18
|
+
class SecurityContext:
|
|
19
|
+
"""Immutable pairing of acting principal and tenant boundary."""
|
|
20
|
+
|
|
21
|
+
principal: Principal | None
|
|
22
|
+
tenant_id: str | None
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Declarative security enforcement decorators."""
|
|
File without changes
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"""Tenant-scoped decorator constants. Imported as const."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Final
|
|
6
|
+
|
|
7
|
+
"""Sentinel selecting the instance attribute as the tenant source."""
|
|
8
|
+
|
|
9
|
+
SELF_TENANT_ID: Final = "self.tenant_id"
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
"""Error messages raised during tenant argument extraction (source-side; tests match against these via const.ERR_*)."""
|
|
13
|
+
|
|
14
|
+
ERR_TENANT_SCOPED_UNBOUND_SELF: Final = "self.tenant_id requires a bound method call"
|
|
15
|
+
ERR_TENANT_SCOPED_PARAM_MISSING: Final = "tenant parameter missing from call"
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"""Declarative permission enforcement for service methods."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import functools
|
|
6
|
+
from collections.abc import Callable
|
|
7
|
+
from typing import ParamSpec, TypeVar
|
|
8
|
+
|
|
9
|
+
from domain_security.context.security_context.security_context_client import (
|
|
10
|
+
SecurityContextManager,
|
|
11
|
+
)
|
|
12
|
+
from domain_security.context.security_context.security_context_objects import (
|
|
13
|
+
SecurityContext,
|
|
14
|
+
)
|
|
15
|
+
from domain_security.services.authz.authz_client import Authorizer
|
|
16
|
+
from domain_security.services.authz.authz_objects import Permission
|
|
17
|
+
|
|
18
|
+
Params = ParamSpec("Params")
|
|
19
|
+
Return = TypeVar("Return")
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class Requires:
|
|
23
|
+
"""Decorator factory enforcing a permission from the ambient security context."""
|
|
24
|
+
|
|
25
|
+
def __init__(self, authorizer: Authorizer | None = None) -> None:
|
|
26
|
+
"""Store the authorizer, defaulting to the scope-based Authorizer."""
|
|
27
|
+
self._authorizer = authorizer or Authorizer()
|
|
28
|
+
|
|
29
|
+
def __call__(
|
|
30
|
+
self,
|
|
31
|
+
permission: str,
|
|
32
|
+
) -> Callable[[Callable[Params, Return]], Callable[Params, Return]]:
|
|
33
|
+
"""Return a decorator that enforces the permission before each call."""
|
|
34
|
+
|
|
35
|
+
def decorate(func: Callable[Params, Return]) -> Callable[Params, Return]:
|
|
36
|
+
@functools.wraps(func)
|
|
37
|
+
def wrapper(*args: Params.args, **kwargs: Params.kwargs) -> Return:
|
|
38
|
+
self._authorizer.require(
|
|
39
|
+
self._current_context(), Permission(permission)
|
|
40
|
+
)
|
|
41
|
+
return func(*args, **kwargs)
|
|
42
|
+
|
|
43
|
+
return wrapper
|
|
44
|
+
|
|
45
|
+
return decorate
|
|
46
|
+
|
|
47
|
+
@staticmethod
|
|
48
|
+
def _current_context() -> SecurityContext:
|
|
49
|
+
"""Return the ambient context, or an anonymous one when unset."""
|
|
50
|
+
current = SecurityContextManager().get()
|
|
51
|
+
return current or SecurityContext(principal=None, tenant_id=None)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
requires = Requires()
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"""Declarative tenant-boundary enforcement for service methods."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import functools
|
|
6
|
+
import inspect
|
|
7
|
+
from collections.abc import Callable
|
|
8
|
+
from typing import Any, ParamSpec, TypeVar
|
|
9
|
+
|
|
10
|
+
from domain_security.context.security_context.security_context_client import (
|
|
11
|
+
SecurityContextManager,
|
|
12
|
+
)
|
|
13
|
+
from domain_security.context.security_context.security_context_objects import (
|
|
14
|
+
SecurityContext,
|
|
15
|
+
)
|
|
16
|
+
from domain_security.decorators.constants import tenant_scoped as const
|
|
17
|
+
from domain_security.errors.security_errors import TenancyError
|
|
18
|
+
from domain_security.services.tenancy.tenancy_client import TenancyGuard
|
|
19
|
+
|
|
20
|
+
Params = ParamSpec("Params")
|
|
21
|
+
Return = TypeVar("Return")
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class TenantScoped:
|
|
25
|
+
"""Decorator factory enforcing the tenant boundary from the ambient security context."""
|
|
26
|
+
|
|
27
|
+
def __init__(self, guard: TenancyGuard | None = None) -> None:
|
|
28
|
+
"""Store the tenancy guard, defaulting to the standard TenancyGuard."""
|
|
29
|
+
self._guard = guard or TenancyGuard()
|
|
30
|
+
|
|
31
|
+
def __call__(
|
|
32
|
+
self,
|
|
33
|
+
param_name: str,
|
|
34
|
+
) -> Callable[[Callable[Params, Return]], Callable[Params, Return]]:
|
|
35
|
+
"""Return a decorator that checks the named tenant argument before each call."""
|
|
36
|
+
|
|
37
|
+
def decorate(func: Callable[Params, Return]) -> Callable[Params, Return]:
|
|
38
|
+
@functools.wraps(func)
|
|
39
|
+
def wrapper(*args: Params.args, **kwargs: Params.kwargs) -> Return:
|
|
40
|
+
tenant_id = self._tenant_argument(func, param_name, args, kwargs)
|
|
41
|
+
self._guard.check(self._current_context(), tenant_id)
|
|
42
|
+
return func(*args, **kwargs)
|
|
43
|
+
|
|
44
|
+
return wrapper
|
|
45
|
+
|
|
46
|
+
return decorate
|
|
47
|
+
|
|
48
|
+
@staticmethod
|
|
49
|
+
def _tenant_argument(
|
|
50
|
+
func: Callable[..., Any],
|
|
51
|
+
param_name: str,
|
|
52
|
+
args: tuple[Any, ...],
|
|
53
|
+
kwargs: dict[str, Any],
|
|
54
|
+
) -> str:
|
|
55
|
+
"""Extract the tenant id from the call arguments or the instance attribute."""
|
|
56
|
+
if param_name == const.SELF_TENANT_ID:
|
|
57
|
+
if not args:
|
|
58
|
+
raise TenancyError(message=const.ERR_TENANT_SCOPED_UNBOUND_SELF)
|
|
59
|
+
return str(args[0].tenant_id)
|
|
60
|
+
bound = inspect.signature(func).bind(*args, **kwargs)
|
|
61
|
+
if param_name not in bound.arguments:
|
|
62
|
+
raise TenancyError(
|
|
63
|
+
message=const.ERR_TENANT_SCOPED_PARAM_MISSING,
|
|
64
|
+
param_name=param_name,
|
|
65
|
+
)
|
|
66
|
+
return str(bound.arguments[param_name])
|
|
67
|
+
|
|
68
|
+
@staticmethod
|
|
69
|
+
def _current_context() -> SecurityContext:
|
|
70
|
+
"""Return the ambient context, or an anonymous one when unset."""
|
|
71
|
+
current = SecurityContextManager().get()
|
|
72
|
+
return current or SecurityContext(principal=None, tenant_id=None)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
tenant_scoped = TenantScoped()
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Security error hierarchy."""
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"""Typed security error hierarchy for authorization, tenancy, and secret failures."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from domain_errors import DomainError
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class SecurityError(DomainError):
|
|
9
|
+
"""Base error for all security-domain failures."""
|
|
10
|
+
|
|
11
|
+
domain = "security"
|
|
12
|
+
code = "security_error"
|
|
13
|
+
http_status = 403
|
|
14
|
+
retryable = False
|
|
15
|
+
default_message = "Security constraint violated."
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class AuthzError(SecurityError):
|
|
19
|
+
"""Permission denied by authorization policy."""
|
|
20
|
+
|
|
21
|
+
code = "authz_denied"
|
|
22
|
+
default_message = "Permission denied."
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class TenancyError(SecurityError):
|
|
26
|
+
"""Operation crossed or lacked a tenant boundary."""
|
|
27
|
+
|
|
28
|
+
code = "tenant_boundary_violation"
|
|
29
|
+
default_message = "Tenant boundary violation."
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class SecretError(SecurityError):
|
|
33
|
+
"""Secret resolution or access failure."""
|
|
34
|
+
|
|
35
|
+
code = "secret_access_failed"
|
|
36
|
+
http_status = 500
|
|
37
|
+
default_message = "Secret access failed."
|
domain_security/py.typed
ADDED
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Security services: authorization, tenancy, secrets."""
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"""Authorization: scope-based policy evaluation over permissions and decisions."""
|
|
2
|
+
|
|
3
|
+
from domain_security.services.authz.authz_client import Authorizer
|
|
4
|
+
from domain_security.services.authz.authz_objects import Permission, PolicyDecision
|
|
5
|
+
|
|
6
|
+
__all__ = ["Authorizer", "Permission", "PolicyDecision"]
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"""Scope-based authorization policy evaluation."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from domain_security.context.security_context.security_context_objects import (
|
|
6
|
+
SecurityContext,
|
|
7
|
+
)
|
|
8
|
+
from domain_security.errors.security_errors import AuthzError
|
|
9
|
+
from domain_security.services.authz import authz_objects as objs
|
|
10
|
+
from domain_security.services.constants import authz as const
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class Authorizer:
|
|
14
|
+
"""Scope-based policy evaluation; subclasses override check for richer policy sources."""
|
|
15
|
+
|
|
16
|
+
def check(
|
|
17
|
+
self,
|
|
18
|
+
ctx: SecurityContext,
|
|
19
|
+
permission: objs.Permission,
|
|
20
|
+
) -> objs.PolicyDecision:
|
|
21
|
+
"""Evaluate the permission against the context and return the decision."""
|
|
22
|
+
if ctx.principal is None:
|
|
23
|
+
return objs.PolicyDecision(
|
|
24
|
+
allowed=False, reason=const.ERR_AUTHZ_NO_PRINCIPAL
|
|
25
|
+
)
|
|
26
|
+
if permission.value not in ctx.principal.scopes:
|
|
27
|
+
return objs.PolicyDecision(
|
|
28
|
+
allowed=False,
|
|
29
|
+
reason=const.ERR_AUTHZ_MISSING_SCOPE.format(scope=permission.value),
|
|
30
|
+
)
|
|
31
|
+
return objs.PolicyDecision(allowed=True)
|
|
32
|
+
|
|
33
|
+
def require(self, ctx: SecurityContext, permission: objs.Permission) -> None:
|
|
34
|
+
"""Enforce the permission, raising AuthzError when denied."""
|
|
35
|
+
decision = self.check(ctx, permission)
|
|
36
|
+
if not decision.allowed:
|
|
37
|
+
raise AuthzError(
|
|
38
|
+
message=decision.reason,
|
|
39
|
+
permission=permission.value,
|
|
40
|
+
)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"""Authorization value objects: permissions and policy decisions."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from dataclasses import dataclass
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@dataclass(frozen=True, slots=True)
|
|
9
|
+
class Permission:
|
|
10
|
+
"""Named permission evaluated against a principal's scopes."""
|
|
11
|
+
|
|
12
|
+
value: str
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@dataclass(frozen=True, slots=True)
|
|
16
|
+
class PolicyDecision:
|
|
17
|
+
"""Allow-or-deny outcome with an optional denial rationale."""
|
|
18
|
+
|
|
19
|
+
allowed: bool
|
|
20
|
+
reason: str | None = None
|
|
File without changes
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"""Authorization constants. Imported as const."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Final
|
|
6
|
+
|
|
7
|
+
"""Denial reasons returned in PolicyDecision and raised via AuthzError (source-side; tests match against these via const.ERR_*)."""
|
|
8
|
+
|
|
9
|
+
ERR_AUTHZ_NO_PRINCIPAL: Final = "no authenticated principal"
|
|
10
|
+
ERR_AUTHZ_MISSING_SCOPE: Final = "missing scope {scope}"
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"""Secrets constants. Imported as const."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Final
|
|
6
|
+
|
|
7
|
+
"""Masked repr token for resolved secrets."""
|
|
8
|
+
|
|
9
|
+
SECRET_VALUE_MASKED_REPR: Final = "<SecretValue ***>"
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
"""Error messages raised during secret resolution (source-side; tests match against these via const.ERR_*)."""
|
|
13
|
+
|
|
14
|
+
ERR_SECRETS_NO_BACKEND: Final = "no secrets backend provided"
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"""Tenancy constants. Imported as const."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Final
|
|
6
|
+
|
|
7
|
+
"""Error messages raised at the tenancy boundary (source-side; tests match against these via const.ERR_*)."""
|
|
8
|
+
|
|
9
|
+
ERR_TENANCY_NO_TENANT_BOUND: Final = "no tenant bound in security context"
|
|
10
|
+
ERR_TENANCY_BOUNDARY_VIOLATION: Final = "tenant boundary violation"
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"""Secrets: lazy secret resolution through a pluggable backend."""
|
|
2
|
+
|
|
3
|
+
from domain_security.services.secrets.secrets_client import SecretRef
|
|
4
|
+
from domain_security.services.secrets.secrets_objects import SecretsBackend, SecretValue
|
|
5
|
+
|
|
6
|
+
__all__ = ["SecretRef", "SecretValue", "SecretsBackend"]
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"""Secret references resolved at call time through a pluggable backend."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from domain_errors import wrap_errors
|
|
6
|
+
|
|
7
|
+
from domain_security.errors.security_errors import SecretError
|
|
8
|
+
from domain_security.services.constants import secrets as const
|
|
9
|
+
from domain_security.services.secrets import secrets_objects as objs
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class SecretRef:
|
|
13
|
+
"""Named reference to a secret, resolved lazily against a backend."""
|
|
14
|
+
|
|
15
|
+
def __init__(self, name: str) -> None:
|
|
16
|
+
"""Store the secret name for later resolution."""
|
|
17
|
+
self.name = name
|
|
18
|
+
|
|
19
|
+
@wrap_errors(SecretError, capture=False)
|
|
20
|
+
def resolve(self, backend: objs.SecretsBackend | None = None) -> objs.SecretValue:
|
|
21
|
+
"""Fetch the named secret from the backend and wrap it in a SecretValue."""
|
|
22
|
+
if backend is None:
|
|
23
|
+
raise SecretError(
|
|
24
|
+
message=const.ERR_SECRETS_NO_BACKEND,
|
|
25
|
+
secret_name=self.name,
|
|
26
|
+
)
|
|
27
|
+
return objs.SecretValue(backend.fetch(self.name))
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"""Secret value objects: the backend contract and the masked resolved value."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from dataclasses import dataclass
|
|
6
|
+
from typing import Protocol
|
|
7
|
+
|
|
8
|
+
from domain_security.services.constants import secrets as const
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class SecretsBackend(Protocol):
|
|
12
|
+
"""Contract for fetching a secret's plaintext value by name."""
|
|
13
|
+
|
|
14
|
+
def fetch(self, name: str) -> str: ...
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@dataclass(frozen=True, slots=True)
|
|
18
|
+
class SecretValue:
|
|
19
|
+
"""Resolved secret whose value never appears in repr output."""
|
|
20
|
+
|
|
21
|
+
_value: str
|
|
22
|
+
|
|
23
|
+
def get(self) -> str:
|
|
24
|
+
"""Return the plaintext secret value."""
|
|
25
|
+
return self._value
|
|
26
|
+
|
|
27
|
+
def __repr__(self) -> str:
|
|
28
|
+
"""Mask the secret value."""
|
|
29
|
+
return const.SECRET_VALUE_MASKED_REPR
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"""Tenant-boundary enforcement against the ambient security context."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from domain_security.context.security_context.security_context_objects import (
|
|
6
|
+
SecurityContext,
|
|
7
|
+
)
|
|
8
|
+
from domain_security.errors.security_errors import TenancyError
|
|
9
|
+
from domain_security.services.constants import tenancy as const
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class TenancyGuard:
|
|
13
|
+
"""Verify that an operation stays inside the context's tenant boundary."""
|
|
14
|
+
|
|
15
|
+
def check(self, ctx: SecurityContext, tenant_id: str) -> None:
|
|
16
|
+
"""Raise TenancyError unless the context is bound to the given tenant."""
|
|
17
|
+
if ctx.tenant_id is None:
|
|
18
|
+
raise TenancyError(
|
|
19
|
+
message=const.ERR_TENANCY_NO_TENANT_BOUND,
|
|
20
|
+
tenant_id=tenant_id,
|
|
21
|
+
)
|
|
22
|
+
if ctx.tenant_id != tenant_id:
|
|
23
|
+
raise TenancyError(
|
|
24
|
+
message=const.ERR_TENANCY_BOUNDARY_VIOLATION,
|
|
25
|
+
tenant_id=tenant_id,
|
|
26
|
+
context_tenant_id=ctx.tenant_id,
|
|
27
|
+
)
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: domain-security
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Cross-cutting security concerns: authorization, tenancy, secrets, context management
|
|
5
|
+
Project-URL: Homepage, https://pypi.org/project/domain-security/
|
|
6
|
+
Project-URL: Repository, https://github.com/jekhator/domain-security
|
|
7
|
+
Project-URL: Issues, https://github.com/jekhator/domain-security/issues
|
|
8
|
+
Project-URL: Changelog, https://github.com/jekhator/domain-security/blob/main/CHANGELOG.md
|
|
9
|
+
Author: James Ekhator
|
|
10
|
+
License: Apache-2.0
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: authorization,context,secrets,security,tenancy
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Typing :: Typed
|
|
20
|
+
Requires-Python: >=3.11
|
|
21
|
+
Requires-Dist: domain-errors>=0.1.0
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
|
|
24
|
+
# domain-security
|
|
25
|
+
|
|
26
|
+
[](https://pypi.org/project/domain-security/)
|
|
27
|
+
[](https://github.com/jekhator/domain-security/actions)
|
|
28
|
+
[](LICENSE)
|
|
29
|
+
[](https://www.python.org/downloads/)
|
|
30
|
+
|
|
31
|
+
Ambient security context management, scope-based authorization, tenant isolation, and secrets resolution for Python services. Provides a composable foundation for authorization, tenancy enforcement, and secret handling across asynchronous and synchronous code.
|
|
32
|
+
|
|
33
|
+
## Why domain-security?
|
|
34
|
+
|
|
35
|
+
Authorization policies, tenant boundaries, and secret handling cut across every service. domain-security provides a single, testable foundation: bind a Principal and tenant_id once, then enforce them declaratively with decorators (`@requires`, `@tenant_scoped`) and inline checks. Context is stored in Python's ContextVar, flowing automatically through async tasks, thread pools, and call stacks. Error types inherit from domain-errors, integrating with structured logging. Secrets are resolved lazily at call time, never stored as literals. Immutable frozen dataclasses mean no accidental mutation.
|
|
36
|
+
|
|
37
|
+
## Installation
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
pip install domain-security
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Or with uv:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
uv add domain-security
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Requires Python 3.11+. Depends on domain-errors >= 0.1.0.
|
|
50
|
+
|
|
51
|
+
## Quick Start
|
|
52
|
+
|
|
53
|
+
### 1. Bind the ambient security context
|
|
54
|
+
|
|
55
|
+
```python
|
|
56
|
+
from domain_security import Principal, SecurityContext, SecurityContextManager
|
|
57
|
+
|
|
58
|
+
# Create a principal with scopes.
|
|
59
|
+
principal = Principal(id="user123", roles=frozenset(["admin"]), scopes=frozenset(["docs:read", "docs:write"]))
|
|
60
|
+
ctx = SecurityContext(principal=principal, tenant_id="acme-corp")
|
|
61
|
+
|
|
62
|
+
# Bind it for the duration of a request or async task.
|
|
63
|
+
manager = SecurityContextManager()
|
|
64
|
+
with manager.bind(principal=principal, tenant_id="acme-corp"):
|
|
65
|
+
# Context is now ambient; decorators and manual checks see it.
|
|
66
|
+
pass
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### 2. Enforce permissions with @requires
|
|
70
|
+
|
|
71
|
+
```python
|
|
72
|
+
from domain_security import requires, AuthzError
|
|
73
|
+
|
|
74
|
+
@requires("docs:write")
|
|
75
|
+
def create_document(title: str) -> dict:
|
|
76
|
+
return {"id": "doc1", "title": title}
|
|
77
|
+
|
|
78
|
+
# With context bound and the principal has the "docs:write" scope, the call succeeds.
|
|
79
|
+
# Without context or if the principal lacks the scope, AuthzError is raised.
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### 3. Enforce tenant boundaries with @tenant_scoped
|
|
83
|
+
|
|
84
|
+
```python
|
|
85
|
+
from domain_security import tenant_scoped, TenancyError
|
|
86
|
+
|
|
87
|
+
@tenant_scoped("tenant_id")
|
|
88
|
+
def delete_document(doc_id: str, tenant_id: str) -> None:
|
|
89
|
+
pass
|
|
90
|
+
|
|
91
|
+
# The call succeeds only if the ambient context's tenant_id matches the argument.
|
|
92
|
+
# Mismatch raises TenancyError.
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
You can also bind tenant_id to a class instance:
|
|
96
|
+
|
|
97
|
+
```python
|
|
98
|
+
class DocumentService:
|
|
99
|
+
def __init__(self, tenant_id: str):
|
|
100
|
+
self.tenant_id = tenant_id
|
|
101
|
+
|
|
102
|
+
@tenant_scoped("self.tenant_id")
|
|
103
|
+
def list_documents(self) -> list:
|
|
104
|
+
return []
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### 4. Resolve secrets at call time
|
|
108
|
+
|
|
109
|
+
```python
|
|
110
|
+
from domain_security import SecretRef, SecretValue, SecretError
|
|
111
|
+
|
|
112
|
+
class MySecretsBackend:
|
|
113
|
+
def fetch(self, name: str) -> str:
|
|
114
|
+
if name == "api_key":
|
|
115
|
+
return "secret123"
|
|
116
|
+
raise ValueError(f"Unknown secret: {name}")
|
|
117
|
+
|
|
118
|
+
ref = SecretRef("api_key")
|
|
119
|
+
backend = MySecretsBackend()
|
|
120
|
+
|
|
121
|
+
try:
|
|
122
|
+
secret = ref.resolve(backend)
|
|
123
|
+
# secret is a SecretValue; its repr is masked.
|
|
124
|
+
print(repr(secret)) # <SecretValue ***>
|
|
125
|
+
plaintext = secret.get() # "secret123"
|
|
126
|
+
except SecretError as e:
|
|
127
|
+
# Backend errors are wrapped as SecretError with __cause__ preserved.
|
|
128
|
+
print(f"Secret access failed: {e}")
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### 5. Manually check permissions
|
|
132
|
+
|
|
133
|
+
```python
|
|
134
|
+
from domain_security import Authorizer, Permission, SecurityContext, Principal
|
|
135
|
+
|
|
136
|
+
principal = Principal(id="user1", scopes=frozenset(["admin"]))
|
|
137
|
+
ctx = SecurityContext(principal=principal, tenant_id="tenant1")
|
|
138
|
+
|
|
139
|
+
authorizer = Authorizer()
|
|
140
|
+
decision = authorizer.check(ctx, Permission("admin"))
|
|
141
|
+
if not decision.allowed:
|
|
142
|
+
print(f"Denied: {decision.reason}")
|
|
143
|
+
|
|
144
|
+
# If you call require() instead of check(), it raises AuthzError on denial.
|
|
145
|
+
authorizer.require(ctx, Permission("admin"))
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## Public API
|
|
149
|
+
|
|
150
|
+
### SecurityContext and Principal
|
|
151
|
+
|
|
152
|
+
```python
|
|
153
|
+
from domain_security import SecurityContext, Principal
|
|
154
|
+
|
|
155
|
+
# Frozen dataclasses; immutable after creation.
|
|
156
|
+
principal = Principal(
|
|
157
|
+
id: str, # Principal identifier
|
|
158
|
+
roles: frozenset[str] = frozenset(), # Role memberships
|
|
159
|
+
scopes: frozenset[str] = frozenset() # Delegated scopes
|
|
160
|
+
)
|
|
161
|
+
|
|
162
|
+
ctx = SecurityContext(
|
|
163
|
+
principal: Principal | None, # Authenticated principal (None = anonymous)
|
|
164
|
+
tenant_id: str | None # Tenant isolation boundary
|
|
165
|
+
)
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### SecurityContextManager
|
|
169
|
+
|
|
170
|
+
```python
|
|
171
|
+
from domain_security import SecurityContextManager
|
|
172
|
+
|
|
173
|
+
manager = SecurityContextManager()
|
|
174
|
+
|
|
175
|
+
# Store context and return a reset token.
|
|
176
|
+
token = manager.set(ctx)
|
|
177
|
+
|
|
178
|
+
# Retrieve the current ambient context (or None).
|
|
179
|
+
ctx = manager.get()
|
|
180
|
+
|
|
181
|
+
# Temporarily bind a context, restoring the prior one on exit.
|
|
182
|
+
with manager.bind(principal=principal, tenant_id="tenant1"):
|
|
183
|
+
# Code here runs with the bound context.
|
|
184
|
+
pass
|
|
185
|
+
|
|
186
|
+
# Reset the context to the state before a matching set() call.
|
|
187
|
+
manager.clear(token)
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
### Authorizer and Permission
|
|
191
|
+
|
|
192
|
+
```python
|
|
193
|
+
from domain_security import Authorizer, Permission, PolicyDecision
|
|
194
|
+
|
|
195
|
+
authorizer = Authorizer()
|
|
196
|
+
|
|
197
|
+
# Evaluate a permission against the context. Returns PolicyDecision.
|
|
198
|
+
decision = authorizer.check(ctx, Permission("scope_name"))
|
|
199
|
+
# decision.allowed: bool
|
|
200
|
+
# decision.reason: str | None
|
|
201
|
+
|
|
202
|
+
# Enforce the permission, raising AuthzError if denied.
|
|
203
|
+
authorizer.require(ctx, Permission("scope_name")) # May raise AuthzError.
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
Subclass `Authorizer` and override `check()` to implement richer policy sources (databases, external services).
|
|
207
|
+
|
|
208
|
+
### SecretRef and SecretValue
|
|
209
|
+
|
|
210
|
+
```python
|
|
211
|
+
from domain_security import SecretRef, SecretValue, SecretError, SecretsBackend
|
|
212
|
+
|
|
213
|
+
# Create a reference to a secret by name.
|
|
214
|
+
ref = SecretRef(name: str)
|
|
215
|
+
|
|
216
|
+
# Resolve it against a backend at call time.
|
|
217
|
+
secret = ref.resolve(backend: SecretsBackend | None = None)
|
|
218
|
+
# Returns: SecretValue
|
|
219
|
+
# Raises: SecretError if backend is None or fetch() fails
|
|
220
|
+
|
|
221
|
+
# Read the plaintext secret.
|
|
222
|
+
plaintext = secret.get() -> str
|
|
223
|
+
|
|
224
|
+
# repr() masks the value to prevent accidental logging.
|
|
225
|
+
repr(secret) # <SecretValue ***>
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
Implement `SecretsBackend` as a Protocol:
|
|
229
|
+
|
|
230
|
+
```python
|
|
231
|
+
class MySecretsBackend:
|
|
232
|
+
def fetch(self, name: str) -> str:
|
|
233
|
+
# Return the plaintext secret or raise any exception.
|
|
234
|
+
# Exceptions are wrapped as SecretError.
|
|
235
|
+
...
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
### Decorators
|
|
239
|
+
|
|
240
|
+
```python
|
|
241
|
+
from domain_security import requires, tenant_scoped
|
|
242
|
+
|
|
243
|
+
# Enforce a permission before the decorated method runs.
|
|
244
|
+
@requires("permission_name")
|
|
245
|
+
def my_method() -> None:
|
|
246
|
+
pass
|
|
247
|
+
|
|
248
|
+
# Enforce a tenant boundary using a named argument or self.tenant_id.
|
|
249
|
+
@tenant_scoped("tenant_id")
|
|
250
|
+
def another_method(tenant_id: str) -> None:
|
|
251
|
+
pass
|
|
252
|
+
|
|
253
|
+
@tenant_scoped("self.tenant_id") # Binds to the instance's tenant_id attribute.
|
|
254
|
+
def instance_method(self) -> None:
|
|
255
|
+
pass
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
Both decorators read the ambient context. No principal or missing scope/tenant raises the corresponding error.
|
|
259
|
+
|
|
260
|
+
### Error Types
|
|
261
|
+
|
|
262
|
+
```python
|
|
263
|
+
from domain_security import SecurityError, AuthzError, TenancyError, SecretError
|
|
264
|
+
|
|
265
|
+
# Base error for all security-domain failures.
|
|
266
|
+
# Subclasses DomainError; code="security_error", http_status=403
|
|
267
|
+
class SecurityError(DomainError):
|
|
268
|
+
pass
|
|
269
|
+
|
|
270
|
+
# Permission denied by authorization policy.
|
|
271
|
+
# code="authz_denied", http_status=403
|
|
272
|
+
class AuthzError(SecurityError):
|
|
273
|
+
pass
|
|
274
|
+
|
|
275
|
+
# Operation crossed or lacked a tenant boundary.
|
|
276
|
+
# code="tenant_boundary_violation", http_status=403
|
|
277
|
+
class TenancyError(SecurityError):
|
|
278
|
+
pass
|
|
279
|
+
|
|
280
|
+
# Secret resolution or access failure.
|
|
281
|
+
# code="secret_access_failed", http_status=500
|
|
282
|
+
class SecretError(SecurityError):
|
|
283
|
+
pass
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
All errors preserve `__cause__` when wrapping exceptions, integrate with domain-errors' structured logging, and carry typed context parameters.
|
|
287
|
+
|
|
288
|
+
## Documentation
|
|
289
|
+
|
|
290
|
+
For detailed documentation on each feature, see:
|
|
291
|
+
|
|
292
|
+
- [SecurityContext and SecurityContextManager](docs/apps/security_context.md)
|
|
293
|
+
- [Authorization with Authorizer and @requires](docs/apps/authz.md)
|
|
294
|
+
- [Tenant Isolation with TenancyGuard and @tenant_scoped](docs/apps/tenancy.md)
|
|
295
|
+
- [Secrets Management with SecretRef and SecretValue](docs/apps/secrets.md)
|
|
296
|
+
- [@requires decorator](docs/apps/requires.md)
|
|
297
|
+
- [@tenant_scoped decorator](docs/apps/tenant_scoped.md)
|
|
298
|
+
- [Error Types and Semantics](docs/apps/security_errors.md)
|
|
299
|
+
|
|
300
|
+
## License
|
|
301
|
+
|
|
302
|
+
Licensed under the Apache License, Version 2.0. See [LICENSE](LICENSE) for details.
|
|
303
|
+
|
|
304
|
+
## Contributing
|
|
305
|
+
|
|
306
|
+
This library is maintained by [James Ekhator](https://github.com/jekhator). Contributions welcome via pull requests. Please read [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines and [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) for community standards.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
domain_security/__init__.py,sha256=8abW5yj7FwxNQM8DmPinpkPjoYyX2YkC3KiB2UnEsDE,1269
|
|
2
|
+
domain_security/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
|
+
domain_security/config/__init__.py,sha256=GIjb9cYcaJ1Q9vRzF7_daH_S5KLOeg_oLGfPIhmn7A0,29
|
|
4
|
+
domain_security/config/_version.py,sha256=GtsljaQReBaQusaK0Zmip2AM7BWtdesXvaMQz35Aiic,60
|
|
5
|
+
domain_security/context/__init__.py,sha256=jBc3lgcpZcinvzyWX24GWzGdHUF48v3vbM-Lnppegi8,32
|
|
6
|
+
domain_security/context/constants/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
|
+
domain_security/context/constants/security_context.py,sha256=mL-pmG_n8KLaGhd6-17P2eRq1qGB5Qvp4-4O5K2zQDU,207
|
|
8
|
+
domain_security/context/security_context/__init__.py,sha256=Qa-yH2VN4FT962eN8mS5ls51k9f-LRRhT8rnFVC8l4U,396
|
|
9
|
+
domain_security/context/security_context/security_context_client.py,sha256=SyoDRhRaqMFsgW5-7tNXJzKSR56FOTlkepkAIkZtUIw,1817
|
|
10
|
+
domain_security/context/security_context/security_context_objects.py,sha256=4lELYDRCxrUMoED-Hy3QrsbqWXzsTgc47zEIa7jYRgw,556
|
|
11
|
+
domain_security/decorators/__init__.py,sha256=cpiruiIb4KAbSUlbtmShjLu4MPFGMVqKHbwhkZfxbpI,51
|
|
12
|
+
domain_security/decorators/constants/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
13
|
+
domain_security/decorators/constants/tenant_scoped.py,sha256=zzJM2dB4JI_tzgDAou5jz91J2pSOWTrhXMIzsXdKbKY,522
|
|
14
|
+
domain_security/decorators/requires/__init__.py,sha256=Ffm1q29OK2YOpAZiPfVbCsPhFuMQ6jTdULA7iKz8ZoY,160
|
|
15
|
+
domain_security/decorators/requires/requires_client.py,sha256=B0SeRJc0mzoS6cWAkm3AHkZEWN9MTOA3zR9sIi-BJ6E,1825
|
|
16
|
+
domain_security/decorators/tenant_scoped/__init__.py,sha256=2EMfqnL1dcRUlkPn7TIp_abUYjJxLNyjcoaczEdgzk4,206
|
|
17
|
+
domain_security/decorators/tenant_scoped/tenant_scoped_client.py,sha256=uQVpAee5Mow35xeMwEo1LfMlTNRTvYiaTdnOw8JoWuo,2735
|
|
18
|
+
domain_security/errors/__init__.py,sha256=yREQYr5oTV--15hlU56oj8nGMFu_s8WvW50zhecKGqE,32
|
|
19
|
+
domain_security/errors/security_errors.py,sha256=Ih_GMPHNF8LnbWOvyN00wXeVrxzXmVhqAPyRBo8UBeM,932
|
|
20
|
+
domain_security/services/__init__.py,sha256=6T1lDshJOmkmVZ1Ik-RwKMpsMY0wSt62FRJbGw34le8,58
|
|
21
|
+
domain_security/services/authz/__init__.py,sha256=kg1hzJnB8H7k3DQRq3C4SN2HijVHFhJO_CTcR_2MlN8,293
|
|
22
|
+
domain_security/services/authz/authz_client.py,sha256=I7_tWK5PhcMwTXk0dQHdWPnsoEqnVxVoD_8C6jZ4SyU,1498
|
|
23
|
+
domain_security/services/authz/authz_objects.py,sha256=3Qy67LrQhHez8LRxDIsT-zSXyAdiQquhwO2DFre4WfE,455
|
|
24
|
+
domain_security/services/constants/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
25
|
+
domain_security/services/constants/authz.py,sha256=yk887RfA1G6EkBgzNzLY8yx7alozZPabZ-EtvyzN_RA,364
|
|
26
|
+
domain_security/services/constants/secrets.py,sha256=ZytAFYnRMVVtMllAYRImI0yZVFuaz7_SyLZqmCmHQsI,384
|
|
27
|
+
domain_security/services/constants/tenancy.py,sha256=6k8g2eXgXieg-JWdzAiLnZ2bfbt_HLHxAPWGC_GAp64,361
|
|
28
|
+
domain_security/services/secrets/__init__.py,sha256=JmY85LYKguaQcUBaLkc_D7NcifgRfwG7_ngeMfcROVk,285
|
|
29
|
+
domain_security/services/secrets/secrets_client.py,sha256=bsNiCe-InFj4YDMumDxTnR8r_JtCasn3GOm-ri9xz_k,1008
|
|
30
|
+
domain_security/services/secrets/secrets_objects.py,sha256=HiT_vF3czmaEPVaeAh2ikxOotCcOMB6P4GzTr3a7e_o,750
|
|
31
|
+
domain_security/services/tenancy/__init__.py,sha256=-UOJdAQrJWvefkby-H5KwDazdygijzZa0b-KgR29NH4,146
|
|
32
|
+
domain_security/services/tenancy/tenancy_client.py,sha256=vnvBy4O2OKWcxlwgBhxuh6IZ8MliiSbuCs3SYrf3ltI,1000
|
|
33
|
+
domain_security-0.1.0.dist-info/METADATA,sha256=ZhsItmQRhq3wwlsgfkaUE-0SIPdAk0F76vN13--P0X0,9995
|
|
34
|
+
domain_security-0.1.0.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
|
|
35
|
+
domain_security-0.1.0.dist-info/licenses/LICENSE,sha256=afJnNvtqk-WIQDM8aNaqfuYQifp27Wa0Q5j5P_Aj_gQ,11343
|
|
36
|
+
domain_security-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 James Ekhator
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|