simple-module-api-tokens 0.0.43__tar.gz → 0.0.45__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.
- {simple_module_api_tokens-0.0.43 → simple_module_api_tokens-0.0.45}/PKG-INFO +7 -7
- simple_module_api_tokens-0.0.45/api_tokens/constants.py +11 -0
- {simple_module_api_tokens-0.0.43 → simple_module_api_tokens-0.0.45}/api_tokens/contracts/schemas.py +1 -1
- simple_module_api_tokens-0.0.45/api_tokens/core/__init__.py +4 -0
- {simple_module_api_tokens-0.0.43/api_tokens → simple_module_api_tokens-0.0.45/api_tokens/core}/constants.py +5 -0
- {simple_module_api_tokens-0.0.43/api_tokens → simple_module_api_tokens-0.0.45/api_tokens/core}/services.py +1 -1
- {simple_module_api_tokens-0.0.43/api_tokens → simple_module_api_tokens-0.0.45/api_tokens/core}/user_cleanup.py +1 -1
- simple_module_api_tokens-0.0.45/api_tokens/credentials/__init__.py +5 -0
- {simple_module_api_tokens-0.0.43/api_tokens → simple_module_api_tokens-0.0.45/api_tokens/credentials}/audit.py +1 -1
- simple_module_api_tokens-0.0.43/api_tokens/tokens.py → simple_module_api_tokens-0.0.45/api_tokens/credentials/format.py +1 -1
- {simple_module_api_tokens-0.0.43/api_tokens → simple_module_api_tokens-0.0.45/api_tokens/credentials}/resolver.py +3 -3
- {simple_module_api_tokens-0.0.43/api_tokens → simple_module_api_tokens-0.0.45/api_tokens/credentials}/scopes.py +2 -2
- {simple_module_api_tokens-0.0.43/api_tokens → simple_module_api_tokens-0.0.45/api_tokens/credentials}/service.py +4 -4
- {simple_module_api_tokens-0.0.43 → simple_module_api_tokens-0.0.45}/api_tokens/models.py +1 -1
- {simple_module_api_tokens-0.0.43 → simple_module_api_tokens-0.0.45}/api_tokens/module.py +13 -13
- {simple_module_api_tokens-0.0.43 → simple_module_api_tokens-0.0.45}/api_tokens/pages/Admin.tsx +7 -7
- {simple_module_api_tokens-0.0.43 → simple_module_api_tokens-0.0.45}/api_tokens/pages/Index.tsx +7 -7
- simple_module_api_tokens-0.0.45/api_tokens/resolver.py +11 -0
- simple_module_api_tokens-0.0.45/api_tokens/service.py +11 -0
- simple_module_api_tokens-0.0.45/api_tokens/tokens.py +11 -0
- simple_module_api_tokens-0.0.45/api_tokens/web/__init__.py +1 -0
- {simple_module_api_tokens-0.0.43/api_tokens → simple_module_api_tokens-0.0.45/api_tokens/web}/deps.py +2 -2
- {simple_module_api_tokens-0.0.43/api_tokens → simple_module_api_tokens-0.0.45/api_tokens/web}/endpoints/admin_api.py +9 -4
- {simple_module_api_tokens-0.0.43/api_tokens → simple_module_api_tokens-0.0.45/api_tokens/web}/endpoints/api.py +4 -4
- {simple_module_api_tokens-0.0.43/api_tokens → simple_module_api_tokens-0.0.45/api_tokens/web}/endpoints/views.py +4 -4
- {simple_module_api_tokens-0.0.43 → simple_module_api_tokens-0.0.45}/package.json +1 -1
- {simple_module_api_tokens-0.0.43 → simple_module_api_tokens-0.0.45}/pyproject.toml +7 -7
- {simple_module_api_tokens-0.0.43 → simple_module_api_tokens-0.0.45}/tests/_api_tokens_support.py +2 -2
- {simple_module_api_tokens-0.0.43 → simple_module_api_tokens-0.0.45}/tests/conftest.py +1 -1
- {simple_module_api_tokens-0.0.43/tests → simple_module_api_tokens-0.0.45/tests/core/cleanup}/test_api_tokens_user_cleanup.py +1 -1
- {simple_module_api_tokens-0.0.43/tests → simple_module_api_tokens-0.0.45/tests/credentials/format}/test_api_tokens_format.py +8 -2
- {simple_module_api_tokens-0.0.43/tests → simple_module_api_tokens-0.0.45/tests/credentials/resolver}/test_api_tokens_hardening.py +8 -8
- {simple_module_api_tokens-0.0.43/tests → simple_module_api_tokens-0.0.45/tests/credentials/resolver}/test_api_tokens_resolver.py +8 -8
- {simple_module_api_tokens-0.0.43/tests → simple_module_api_tokens-0.0.45/tests/credentials/scopes}/test_api_tokens_scopes.py +3 -3
- {simple_module_api_tokens-0.0.43/tests → simple_module_api_tokens-0.0.45/tests/credentials/service}/test_api_tokens_directory.py +3 -3
- {simple_module_api_tokens-0.0.43/tests → simple_module_api_tokens-0.0.45/tests/credentials/service}/test_api_tokens_service_keys.py +2 -2
- {simple_module_api_tokens-0.0.43/tests → simple_module_api_tokens-0.0.45/tests/credentials/service}/test_api_tokens_signup.py +3 -3
- {simple_module_api_tokens-0.0.43/tests → simple_module_api_tokens-0.0.45/tests/web/endpoints}/test_api_tokens_pagination.py +2 -2
- {simple_module_api_tokens-0.0.43 → simple_module_api_tokens-0.0.45}/tests-js/api_tokens_CreatedTokenDialog.test.tsx +1 -1
- {simple_module_api_tokens-0.0.43 → simple_module_api_tokens-0.0.45}/tests-js/fixtures.ts +1 -1
- {simple_module_api_tokens-0.0.43 → simple_module_api_tokens-0.0.45}/.gitignore +0 -0
- {simple_module_api_tokens-0.0.43 → simple_module_api_tokens-0.0.45}/LICENSE +0 -0
- {simple_module_api_tokens-0.0.43 → simple_module_api_tokens-0.0.45}/README.md +0 -0
- {simple_module_api_tokens-0.0.43 → simple_module_api_tokens-0.0.45}/api_tokens/__init__.py +0 -0
- {simple_module_api_tokens-0.0.43 → simple_module_api_tokens-0.0.45}/api_tokens/contracts/__init__.py +0 -0
- {simple_module_api_tokens-0.0.43/api_tokens → simple_module_api_tokens-0.0.45/api_tokens/core}/settings.py +0 -0
- {simple_module_api_tokens-0.0.43/api_tokens → simple_module_api_tokens-0.0.45/api_tokens/core}/tenant_cleanup.py +0 -0
- {simple_module_api_tokens-0.0.43/api_tokens → simple_module_api_tokens-0.0.45/api_tokens/credentials}/owner.py +0 -0
- {simple_module_api_tokens-0.0.43 → simple_module_api_tokens-0.0.45}/api_tokens/locales/de.json +0 -0
- {simple_module_api_tokens-0.0.43 → simple_module_api_tokens-0.0.45}/api_tokens/locales/en.json +0 -0
- {simple_module_api_tokens-0.0.43 → simple_module_api_tokens-0.0.45}/api_tokens/pages/api.generated.ts +0 -0
- {simple_module_api_tokens-0.0.43 → simple_module_api_tokens-0.0.45}/api_tokens/pages/api.ts +0 -0
- {simple_module_api_tokens-0.0.43 → simple_module_api_tokens-0.0.45}/api_tokens/py.typed +0 -0
- {simple_module_api_tokens-0.0.43/api_tokens/pages → simple_module_api_tokens-0.0.45/api_tokens/ui}/components/CreateTokenDialog.tsx +0 -0
- {simple_module_api_tokens-0.0.43/api_tokens/pages → simple_module_api_tokens-0.0.45/api_tokens/ui}/components/CreatedTokenDialog.tsx +0 -0
- {simple_module_api_tokens-0.0.43/api_tokens/pages → simple_module_api_tokens-0.0.45/api_tokens/ui}/components/RevokeTokenDialog.tsx +0 -0
- {simple_module_api_tokens-0.0.43/api_tokens/pages → simple_module_api_tokens-0.0.45/api_tokens/ui}/components/TokenPagination.tsx +0 -0
- {simple_module_api_tokens-0.0.43/api_tokens/pages → simple_module_api_tokens-0.0.45/api_tokens/ui}/components/TokenTable.tsx +0 -0
- {simple_module_api_tokens-0.0.43/api_tokens/pages → simple_module_api_tokens-0.0.45/api_tokens/ui}/components/useTokenActions.ts +0 -0
- {simple_module_api_tokens-0.0.43/api_tokens/pages → simple_module_api_tokens-0.0.45/api_tokens/ui}/types.ts +0 -0
- {simple_module_api_tokens-0.0.43/api_tokens → simple_module_api_tokens-0.0.45/api_tokens/web}/endpoints/__init__.py +0 -0
- {simple_module_api_tokens-0.0.43/tests → simple_module_api_tokens-0.0.45/tests/core/cleanup}/test_api_tokens_tenant_cleanup.py +0 -0
- {simple_module_api_tokens-0.0.43/tests → simple_module_api_tokens-0.0.45/tests/credentials/resolver}/test_api_tokens_identity.py +0 -0
- {simple_module_api_tokens-0.0.43/tests → simple_module_api_tokens-0.0.45/tests/web/endpoints}/test_api_tokens_endpoints.py +0 -0
- {simple_module_api_tokens-0.0.43/tests → simple_module_api_tokens-0.0.45/tests/web/endpoints}/test_api_tokens_route_guard.py +0 -0
- {simple_module_api_tokens-0.0.43 → simple_module_api_tokens-0.0.45}/tests-js/api_tokens_Admin.test.tsx +0 -0
- {simple_module_api_tokens-0.0.43 → simple_module_api_tokens-0.0.45}/tests-js/api_tokens_Index.test.tsx +0 -0
- {simple_module_api_tokens-0.0.43 → simple_module_api_tokens-0.0.45}/tsconfig.json +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: simple_module_api_tokens
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.45
|
|
4
4
|
Summary: Personal access tokens and service API keys for simple_module
|
|
5
5
|
Project-URL: Homepage, https://github.com/antosubash/simple_module_python
|
|
6
6
|
Project-URL: Repository, https://github.com/antosubash/simple_module_python
|
|
@@ -22,12 +22,12 @@ Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
|
|
|
22
22
|
Classifier: Typing :: Typed
|
|
23
23
|
Requires-Python: >=3.12
|
|
24
24
|
Requires-Dist: fastapi-users-db-sqlalchemy<8,>=7
|
|
25
|
-
Requires-Dist: simple-module-auth==0.0.
|
|
26
|
-
Requires-Dist: simple-module-core==0.0.
|
|
27
|
-
Requires-Dist: simple-module-db==0.0.
|
|
28
|
-
Requires-Dist: simple-module-hosting==0.0.
|
|
29
|
-
Requires-Dist: simple-module-inertia==0.0.
|
|
30
|
-
Requires-Dist: simple-module-settings==0.0.
|
|
25
|
+
Requires-Dist: simple-module-auth==0.0.45
|
|
26
|
+
Requires-Dist: simple-module-core==0.0.45
|
|
27
|
+
Requires-Dist: simple-module-db==0.0.45
|
|
28
|
+
Requires-Dist: simple-module-hosting==0.0.45
|
|
29
|
+
Requires-Dist: simple-module-inertia==0.0.45
|
|
30
|
+
Requires-Dist: simple-module-settings==0.0.45
|
|
31
31
|
Description-Content-Type: text/markdown
|
|
32
32
|
|
|
33
33
|
# simple_module_api_tokens
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"""Moved to :mod:`api_tokens.core.constants`; this alias goes in 0.0.46 (module layout)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import importlib
|
|
6
|
+
import sys
|
|
7
|
+
|
|
8
|
+
from simple_module_core.deprecation import deprecated_module
|
|
9
|
+
|
|
10
|
+
deprecated_module("api_tokens.constants", remove_in="0.0.46", use="api_tokens.core.constants")
|
|
11
|
+
sys.modules[__name__] = importlib.import_module("api_tokens.core.constants")
|
{simple_module_api_tokens-0.0.43 → simple_module_api_tokens-0.0.45}/api_tokens/contracts/schemas.py
RENAMED
|
@@ -8,7 +8,7 @@ from datetime import datetime
|
|
|
8
8
|
from pydantic import ConfigDict, field_validator
|
|
9
9
|
from sqlmodel import Field, SQLModel
|
|
10
10
|
|
|
11
|
-
from api_tokens.constants import MAX_SCOPES, NAME_MAX_LENGTH
|
|
11
|
+
from api_tokens.core.constants import MAX_SCOPES, NAME_MAX_LENGTH
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
class TokenView(SQLModel):
|
|
@@ -74,3 +74,8 @@ QP_TOKEN: Final = "token"
|
|
|
74
74
|
# Expiry presets offered by the pages, in days; the server accepts any whole
|
|
75
75
|
# number of days up to ``max_lifetime_days``.
|
|
76
76
|
EXPIRY_PRESETS_DAYS: Final = (7, 30, 90, 365)
|
|
77
|
+
|
|
78
|
+
# Durable handler names key undelivered outbox rows, so they keep the import
|
|
79
|
+
# path the handlers had before the module-layout move (renaming strands rows).
|
|
80
|
+
TENANT_CLEANUP_HANDLER: Final = "api_tokens.tenant_cleanup.purge_tenant_data"
|
|
81
|
+
USER_CLEANUP_HANDLER: Final = "api_tokens.user_cleanup.purge_user_tokens"
|
|
@@ -5,7 +5,7 @@ from simple_module_core.user_events import UserDeleted
|
|
|
5
5
|
from simple_module_db.tenancy import all_tenants
|
|
6
6
|
from sqlmodel import col, delete
|
|
7
7
|
|
|
8
|
-
from api_tokens.constants import TokenKind
|
|
8
|
+
from api_tokens.core.constants import TokenKind
|
|
9
9
|
from api_tokens.models import ApiToken
|
|
10
10
|
|
|
11
11
|
|
|
@@ -14,7 +14,7 @@ from simple_module_db import ALL_TENANTS_OPTION
|
|
|
14
14
|
from sqlalchemy import select
|
|
15
15
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
16
16
|
|
|
17
|
-
from api_tokens.constants import ADMIN_URL, AUDIT_LINK_LABEL, AUDIT_LINK_LABEL_KEY, QP_TOKEN
|
|
17
|
+
from api_tokens.core.constants import ADMIN_URL, AUDIT_LINK_LABEL, AUDIT_LINK_LABEL_KEY, QP_TOKEN
|
|
18
18
|
from api_tokens.models import ApiToken
|
|
19
19
|
|
|
20
20
|
|
|
@@ -27,15 +27,15 @@ from sqlalchemy import or_, select, update
|
|
|
27
27
|
from sqlmodel import col
|
|
28
28
|
from starlette.requests import Request
|
|
29
29
|
|
|
30
|
-
from api_tokens.constants import (
|
|
30
|
+
from api_tokens.core.constants import (
|
|
31
31
|
FORBIDDEN_SERVICE_ROLES,
|
|
32
32
|
LAST_USED_WRITE_INTERVAL_SECONDS,
|
|
33
33
|
PERM_USE,
|
|
34
34
|
TokenKind,
|
|
35
35
|
)
|
|
36
|
+
from api_tokens.credentials.format import hash_token, is_well_formed
|
|
37
|
+
from api_tokens.credentials.owner import usable_owner
|
|
36
38
|
from api_tokens.models import ApiToken
|
|
37
|
-
from api_tokens.owner import usable_owner
|
|
38
|
-
from api_tokens.tokens import hash_token, is_well_formed
|
|
39
39
|
|
|
40
40
|
logger = logging.getLogger(__name__)
|
|
41
41
|
|
|
@@ -16,8 +16,8 @@ from simple_module_core.permissions import WILDCARD
|
|
|
16
16
|
from simple_module_core.tenancy import is_tenant_role
|
|
17
17
|
from simple_module_hosting.permissions import ensure_resolved_permissions
|
|
18
18
|
|
|
19
|
-
from api_tokens.constants import FORBIDDEN_SERVICE_ROLES
|
|
20
|
-
from api_tokens.service import TokenError
|
|
19
|
+
from api_tokens.core.constants import FORBIDDEN_SERVICE_ROLES
|
|
20
|
+
from api_tokens.credentials.service import TokenError
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
def _registry(request: Request):
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"""Creating, listing and revoking API tokens.
|
|
2
2
|
|
|
3
3
|
Authorisation decisions — who may create what, which scopes a creator may
|
|
4
|
-
hand out — are made by the caller (``api_tokens.scopes`` and the endpoints);
|
|
4
|
+
hand out — are made by the caller (``api_tokens.credentials.scopes`` and the endpoints);
|
|
5
5
|
this layer enforces only the invariants every token must satisfy wherever it
|
|
6
6
|
came from: a non-empty scope list, no ``admin`` role on a service key, an
|
|
7
7
|
expiry within ``max_lifetime_days``.
|
|
@@ -20,11 +20,11 @@ from sqlalchemy import select
|
|
|
20
20
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
21
21
|
from sqlmodel import col
|
|
22
22
|
|
|
23
|
-
from api_tokens.constants import FORBIDDEN_SERVICE_ROLES, TokenKind
|
|
24
23
|
from api_tokens.contracts.schemas import TokenView
|
|
24
|
+
from api_tokens.core.constants import FORBIDDEN_SERVICE_ROLES, TokenKind
|
|
25
|
+
from api_tokens.credentials.format import generate
|
|
26
|
+
from api_tokens.credentials.owner import usable_owner
|
|
25
27
|
from api_tokens.models import ApiToken
|
|
26
|
-
from api_tokens.owner import usable_owner
|
|
27
|
-
from api_tokens.tokens import generate
|
|
28
28
|
|
|
29
29
|
|
|
30
30
|
class TokenError(Exception):
|
|
@@ -20,7 +20,7 @@ from simple_module_db.types import AwareDateTime
|
|
|
20
20
|
from sqlalchemy import Index
|
|
21
21
|
from sqlmodel import Field
|
|
22
22
|
|
|
23
|
-
from api_tokens.constants import IX_TOKEN_HASH, NAME_MAX_LENGTH, TABLE_TOKEN, TokenKind
|
|
23
|
+
from api_tokens.core.constants import IX_TOKEN_HASH, NAME_MAX_LENGTH, TABLE_TOKEN, TokenKind
|
|
24
24
|
|
|
25
25
|
Base = create_module_base("api_tokens")
|
|
26
26
|
|
|
@@ -12,7 +12,7 @@ from simple_module_core.module import ModuleBase, ModuleMeta
|
|
|
12
12
|
from simple_module_core.module_settings import register_module_settings
|
|
13
13
|
from simple_module_core.tenancy import TenantRole, tenant_role
|
|
14
14
|
|
|
15
|
-
from api_tokens import constants as c
|
|
15
|
+
from api_tokens.core import constants as c
|
|
16
16
|
|
|
17
17
|
if TYPE_CHECKING:
|
|
18
18
|
from fastapi import APIRouter, FastAPI
|
|
@@ -40,15 +40,15 @@ class ApiTokensModule(ModuleBase):
|
|
|
40
40
|
from simple_module_core.tenant_events import TenantDeleted
|
|
41
41
|
from simple_module_core.user_events import UserDeleted
|
|
42
42
|
|
|
43
|
-
from api_tokens.tenant_cleanup import purge_tenant_data
|
|
44
|
-
from api_tokens.user_cleanup import purge_user_tokens
|
|
43
|
+
from api_tokens.core.tenant_cleanup import purge_tenant_data
|
|
44
|
+
from api_tokens.core.user_cleanup import purge_user_tokens
|
|
45
45
|
|
|
46
|
-
bus.subscribe_durable(TenantDeleted, purge_tenant_data)
|
|
47
|
-
bus.subscribe_durable(UserDeleted, purge_user_tokens)
|
|
46
|
+
bus.subscribe_durable(TenantDeleted, purge_tenant_data, name=c.TENANT_CLEANUP_HANDLER)
|
|
47
|
+
bus.subscribe_durable(UserDeleted, purge_user_tokens, name=c.USER_CLEANUP_HANDLER)
|
|
48
48
|
|
|
49
49
|
def register_settings(self, app: FastAPI) -> None:
|
|
50
|
-
from api_tokens.services import ApiTokensServices
|
|
51
|
-
from api_tokens.settings import ApiTokensSettings
|
|
50
|
+
from api_tokens.core.services import ApiTokensServices
|
|
51
|
+
from api_tokens.core.settings import ApiTokensSettings
|
|
52
52
|
|
|
53
53
|
register_module_settings(
|
|
54
54
|
app,
|
|
@@ -58,16 +58,16 @@ class ApiTokensModule(ModuleBase):
|
|
|
58
58
|
)
|
|
59
59
|
|
|
60
60
|
def register_routes(self, api_router: APIRouter, view_router: APIRouter) -> None:
|
|
61
|
-
from api_tokens.endpoints.admin_api import router as admin_api
|
|
62
|
-
from api_tokens.endpoints.api import router as api
|
|
63
|
-
from api_tokens.endpoints.views import router as views
|
|
61
|
+
from api_tokens.web.endpoints.admin_api import router as admin_api
|
|
62
|
+
from api_tokens.web.endpoints.api import router as api
|
|
63
|
+
from api_tokens.web.endpoints.views import router as views
|
|
64
64
|
|
|
65
65
|
api_router.include_router(api)
|
|
66
66
|
api_router.include_router(admin_api)
|
|
67
67
|
view_router.include_router(views)
|
|
68
68
|
|
|
69
69
|
def register_admin_routes(self, admin_router: APIRouter) -> None:
|
|
70
|
-
from api_tokens.endpoints.views import admin_router as admin_views
|
|
70
|
+
from api_tokens.web.endpoints.views import admin_router as admin_views
|
|
71
71
|
|
|
72
72
|
admin_router.include_router(admin_views)
|
|
73
73
|
|
|
@@ -108,7 +108,7 @@ class ApiTokensModule(ModuleBase):
|
|
|
108
108
|
registry.map_role(tenant_role(role), [c.PERM_USE])
|
|
109
109
|
|
|
110
110
|
def register_audit_links(self, registry: AuditLinkRegistry) -> None:
|
|
111
|
-
from api_tokens.audit import build_token_audit_link
|
|
111
|
+
from api_tokens.credentials.audit import build_token_audit_link
|
|
112
112
|
|
|
113
113
|
registry.register(build_token_audit_link())
|
|
114
114
|
|
|
@@ -117,7 +117,7 @@ class ApiTokensModule(ModuleBase):
|
|
|
117
117
|
return {c.LOCALE_NAMESPACE: base}
|
|
118
118
|
|
|
119
119
|
async def on_startup(self, app: FastAPI) -> None:
|
|
120
|
-
from api_tokens.resolver import resolve_api_token
|
|
120
|
+
from api_tokens.credentials.resolver import resolve_api_token
|
|
121
121
|
|
|
122
122
|
resolvers = app.state.auth.principal_resolvers
|
|
123
123
|
if resolve_api_token not in resolvers:
|
{simple_module_api_tokens-0.0.43 → simple_module_api_tokens-0.0.45}/api_tokens/pages/Admin.tsx
RENAMED
|
@@ -7,14 +7,14 @@ import { AdminLayout } from '@simple-module-py/ui/layouts/AdminLayout';
|
|
|
7
7
|
import { apiResult } from '@simple-module-py/ui/lib/api';
|
|
8
8
|
import { Building2, Plus } from 'lucide-react';
|
|
9
9
|
import { useState } from 'react';
|
|
10
|
+
import { CreatedTokenDialog } from '../ui/components/CreatedTokenDialog';
|
|
11
|
+
import { CreateTokenDialog } from '../ui/components/CreateTokenDialog';
|
|
12
|
+
import { RevokeTokenDialog } from '../ui/components/RevokeTokenDialog';
|
|
13
|
+
import { TokenPagination } from '../ui/components/TokenPagination';
|
|
14
|
+
import { TokenTable } from '../ui/components/TokenTable';
|
|
15
|
+
import { useTokenActions } from '../ui/components/useTokenActions';
|
|
16
|
+
import type { CreatePayload, TokenFormProps } from '../ui/types';
|
|
10
17
|
import { api, csrfHeaders } from './api';
|
|
11
|
-
import { CreatedTokenDialog } from './components/CreatedTokenDialog';
|
|
12
|
-
import { CreateTokenDialog } from './components/CreateTokenDialog';
|
|
13
|
-
import { RevokeTokenDialog } from './components/RevokeTokenDialog';
|
|
14
|
-
import { TokenPagination } from './components/TokenPagination';
|
|
15
|
-
import { TokenTable } from './components/TokenTable';
|
|
16
|
-
import { useTokenActions } from './components/useTokenActions';
|
|
17
|
-
import type { CreatePayload, TokenFormProps } from './types';
|
|
18
18
|
|
|
19
19
|
interface Props extends TokenFormProps {
|
|
20
20
|
roles: string[];
|
{simple_module_api_tokens-0.0.43 → simple_module_api_tokens-0.0.45}/api_tokens/pages/Index.tsx
RENAMED
|
@@ -7,14 +7,14 @@ import { AuthenticatedLayout } from '@simple-module-py/ui/layouts/AuthenticatedL
|
|
|
7
7
|
import { apiResult } from '@simple-module-py/ui/lib/api';
|
|
8
8
|
import { Ban, Plus } from 'lucide-react';
|
|
9
9
|
import { useState } from 'react';
|
|
10
|
+
import { CreatedTokenDialog } from '../ui/components/CreatedTokenDialog';
|
|
11
|
+
import { CreateTokenDialog } from '../ui/components/CreateTokenDialog';
|
|
12
|
+
import { RevokeTokenDialog } from '../ui/components/RevokeTokenDialog';
|
|
13
|
+
import { TokenPagination } from '../ui/components/TokenPagination';
|
|
14
|
+
import { TokenTable } from '../ui/components/TokenTable';
|
|
15
|
+
import { useTokenActions } from '../ui/components/useTokenActions';
|
|
16
|
+
import { type CreatePayload, type TokenFormProps, tokenStatus } from '../ui/types';
|
|
10
17
|
import { api, csrfHeaders } from './api';
|
|
11
|
-
import { CreatedTokenDialog } from './components/CreatedTokenDialog';
|
|
12
|
-
import { CreateTokenDialog } from './components/CreateTokenDialog';
|
|
13
|
-
import { RevokeTokenDialog } from './components/RevokeTokenDialog';
|
|
14
|
-
import { TokenPagination } from './components/TokenPagination';
|
|
15
|
-
import { TokenTable } from './components/TokenTable';
|
|
16
|
-
import { useTokenActions } from './components/useTokenActions';
|
|
17
|
-
import { type CreatePayload, type TokenFormProps, tokenStatus } from './types';
|
|
18
18
|
|
|
19
19
|
/** Your own personal access tokens: list, create (secret shown once), revoke. */
|
|
20
20
|
function Index(props: TokenFormProps) {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"""Moved to :mod:`api_tokens.credentials.resolver`; this alias goes in 0.0.46 (module layout)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import importlib
|
|
6
|
+
import sys
|
|
7
|
+
|
|
8
|
+
from simple_module_core.deprecation import deprecated_module
|
|
9
|
+
|
|
10
|
+
deprecated_module("api_tokens.resolver", remove_in="0.0.46", use="api_tokens.credentials.resolver")
|
|
11
|
+
sys.modules[__name__] = importlib.import_module("api_tokens.credentials.resolver")
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"""Moved to :mod:`api_tokens.credentials.service`; this alias goes in 0.0.46 (module layout)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import importlib
|
|
6
|
+
import sys
|
|
7
|
+
|
|
8
|
+
from simple_module_core.deprecation import deprecated_module
|
|
9
|
+
|
|
10
|
+
deprecated_module("api_tokens.service", remove_in="0.0.46", use="api_tokens.credentials.service")
|
|
11
|
+
sys.modules[__name__] = importlib.import_module("api_tokens.credentials.service")
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"""Moved to :mod:`api_tokens.credentials.format`; this alias goes in 0.0.46 (module layout)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import importlib
|
|
6
|
+
import sys
|
|
7
|
+
|
|
8
|
+
from simple_module_core.deprecation import deprecated_module
|
|
9
|
+
|
|
10
|
+
deprecated_module("api_tokens.tokens", remove_in="0.0.46", use="api_tokens.credentials.format")
|
|
11
|
+
sys.modules[__name__] = importlib.import_module("api_tokens.credentials.format")
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""The HTTP side: request deps and the REST, admin and Inertia endpoints."""
|
|
@@ -13,8 +13,8 @@ from simple_module_db.deps import get_db
|
|
|
13
13
|
from simple_module_hosting.i18n_deps import TranslatorDep
|
|
14
14
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
15
15
|
|
|
16
|
-
from api_tokens.
|
|
17
|
-
from api_tokens.
|
|
16
|
+
from api_tokens.core.settings import ApiTokensSettings
|
|
17
|
+
from api_tokens.credentials.service import ApiTokenService, TokenError
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
async def get_api_token_service(
|
|
@@ -15,11 +15,16 @@ from simple_module_hosting.csrf import RequiresCsrf
|
|
|
15
15
|
from simple_module_hosting.i18n_deps import TranslatorDep
|
|
16
16
|
from simple_module_hosting.permissions import RequiresPermission
|
|
17
17
|
|
|
18
|
-
from api_tokens.constants import FORBIDDEN_SERVICE_ROLES, PERM_MANAGE, TokenKind
|
|
19
18
|
from api_tokens.contracts.schemas import CreatedToken, ServiceKeyCreate, TokenView
|
|
20
|
-
from api_tokens.
|
|
21
|
-
from api_tokens.scopes import assignable_roles, assignable_scopes, check_subset
|
|
22
|
-
from api_tokens.service import ApiTokenService, TokenError
|
|
19
|
+
from api_tokens.core.constants import FORBIDDEN_SERVICE_ROLES, PERM_MANAGE, TokenKind
|
|
20
|
+
from api_tokens.credentials.scopes import assignable_roles, assignable_scopes, check_subset
|
|
21
|
+
from api_tokens.credentials.service import ApiTokenService, TokenError
|
|
22
|
+
from api_tokens.web.deps import (
|
|
23
|
+
ApiTokenServiceDep,
|
|
24
|
+
SettingsDep,
|
|
25
|
+
http_error,
|
|
26
|
+
require_session_principal,
|
|
27
|
+
)
|
|
23
28
|
|
|
24
29
|
router = APIRouter(
|
|
25
30
|
prefix="/admin",
|
|
@@ -15,14 +15,16 @@ from simple_module_hosting.csrf import RequiresCsrf
|
|
|
15
15
|
from simple_module_hosting.i18n_deps import TranslatorDep
|
|
16
16
|
from simple_module_hosting.permissions import RequiresPermission
|
|
17
17
|
|
|
18
|
-
from api_tokens.constants import PERM_USE, TokenKind
|
|
19
18
|
from api_tokens.contracts.schemas import (
|
|
20
19
|
CreatedToken,
|
|
21
20
|
PersonalTokenCreate,
|
|
22
21
|
RevokedCount,
|
|
23
22
|
TokenView,
|
|
24
23
|
)
|
|
25
|
-
from api_tokens.
|
|
24
|
+
from api_tokens.core.constants import PERM_USE, TokenKind
|
|
25
|
+
from api_tokens.credentials.scopes import assignable_scopes, check_subset
|
|
26
|
+
from api_tokens.credentials.service import TokenError
|
|
27
|
+
from api_tokens.web.deps import (
|
|
26
28
|
ApiTokenServiceDep,
|
|
27
29
|
SessionPrincipal,
|
|
28
30
|
SettingsDep,
|
|
@@ -30,8 +32,6 @@ from api_tokens.deps import (
|
|
|
30
32
|
require_session_principal,
|
|
31
33
|
user_uuid,
|
|
32
34
|
)
|
|
33
|
-
from api_tokens.scopes import assignable_scopes, check_subset
|
|
34
|
-
from api_tokens.service import TokenError
|
|
35
35
|
|
|
36
36
|
router = APIRouter(
|
|
37
37
|
prefix="/tokens",
|
|
@@ -15,22 +15,22 @@ from simple_module_hosting.inertia_deps import InertiaDep
|
|
|
15
15
|
from simple_module_hosting.permissions import RequiresPermission
|
|
16
16
|
from simple_module_inertia import InertiaResponse
|
|
17
17
|
|
|
18
|
-
from api_tokens.constants import (
|
|
18
|
+
from api_tokens.core.constants import (
|
|
19
19
|
EXPIRY_PRESETS_DAYS,
|
|
20
20
|
PAGE_ADMIN,
|
|
21
21
|
PAGE_INDEX,
|
|
22
22
|
PERM_MANAGE,
|
|
23
23
|
PERM_USE,
|
|
24
24
|
)
|
|
25
|
-
from api_tokens.
|
|
25
|
+
from api_tokens.credentials.scopes import assignable_roles, assignable_scopes
|
|
26
|
+
from api_tokens.web.deps import (
|
|
26
27
|
ApiTokenServiceDep,
|
|
27
28
|
SessionPrincipal,
|
|
28
29
|
SettingsDep,
|
|
29
30
|
require_session_principal,
|
|
30
31
|
user_uuid,
|
|
31
32
|
)
|
|
32
|
-
from api_tokens.endpoints.admin_api import tenant_token_views
|
|
33
|
-
from api_tokens.scopes import assignable_roles, assignable_scopes
|
|
33
|
+
from api_tokens.web.endpoints.admin_api import tenant_token_views
|
|
34
34
|
|
|
35
35
|
router = APIRouter(
|
|
36
36
|
dependencies=[Depends(require_session_principal), Depends(RequiresPermission(PERM_USE))]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "simple_module_api_tokens"
|
|
3
|
-
version = "0.0.
|
|
3
|
+
version = "0.0.45"
|
|
4
4
|
description = "Personal access tokens and service API keys for simple_module"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
license = "MIT"
|
|
@@ -21,12 +21,12 @@ classifiers = [
|
|
|
21
21
|
"Typing :: Typed",
|
|
22
22
|
]
|
|
23
23
|
dependencies = [
|
|
24
|
-
"simple_module_core==0.0.
|
|
25
|
-
"simple_module_db==0.0.
|
|
26
|
-
"simple_module_hosting==0.0.
|
|
27
|
-
"simple_module_inertia==0.0.
|
|
28
|
-
"simple_module_auth==0.0.
|
|
29
|
-
"simple_module_settings==0.0.
|
|
24
|
+
"simple_module_core==0.0.45",
|
|
25
|
+
"simple_module_db==0.0.45",
|
|
26
|
+
"simple_module_hosting==0.0.45",
|
|
27
|
+
"simple_module_inertia==0.0.45",
|
|
28
|
+
"simple_module_auth==0.0.45",
|
|
29
|
+
"simple_module_settings==0.0.45",
|
|
30
30
|
# Owners are read through the app's user directory, so ``users`` is not
|
|
31
31
|
# required. ``GUID`` (the owner column's type, as ``users_user.id`` has it)
|
|
32
32
|
# comes from here.
|
{simple_module_api_tokens-0.0.43 → simple_module_api_tokens-0.0.45}/tests/_api_tokens_support.py
RENAMED
|
@@ -27,7 +27,7 @@ class Actor:
|
|
|
27
27
|
async def join_tenant(app: Any, user_id: str, email: str, tenant_id: str | None = None) -> str:
|
|
28
28
|
"""Make *user_id* an owner of a new tenant (or of *tenant_id*); return its id."""
|
|
29
29
|
from tenants.models import Membership, Tenant
|
|
30
|
-
from tenants.resolver import forget
|
|
30
|
+
from tenants.resolution.resolver import forget
|
|
31
31
|
|
|
32
32
|
async with app.state.sm.db.session_factory() as session:
|
|
33
33
|
if tenant_id is None:
|
|
@@ -44,7 +44,7 @@ async def join_tenant(app: Any, user_id: str, email: str, tenant_id: str | None
|
|
|
44
44
|
|
|
45
45
|
|
|
46
46
|
async def make_admin(app: Any, email: str) -> str:
|
|
47
|
-
from users.bootstrap import create_admin
|
|
47
|
+
from users.core.bootstrap import create_admin
|
|
48
48
|
|
|
49
49
|
async with app.state.sm.db.session_factory() as session:
|
|
50
50
|
result = await create_admin(session, email=email, password="pw-123456", full_name="Admin")
|
|
@@ -20,7 +20,7 @@ def actor(app) -> Callable[..., AbstractAsyncContextManager[Actor]]:
|
|
|
20
20
|
|
|
21
21
|
The session carries a known CSRF token (``CSRF``) so mutations can echo it.
|
|
22
22
|
"""
|
|
23
|
-
from tenants.constants import SESSION_ACTIVE_TENANT
|
|
23
|
+
from tenants.core.constants import SESSION_ACTIVE_TENANT
|
|
24
24
|
|
|
25
25
|
@asynccontextmanager
|
|
26
26
|
async def factory(
|
|
@@ -4,7 +4,7 @@ import uuid
|
|
|
4
4
|
from datetime import UTC, datetime, timedelta
|
|
5
5
|
|
|
6
6
|
import pytest
|
|
7
|
-
from api_tokens.constants import TokenKind
|
|
7
|
+
from api_tokens.core.constants import TokenKind
|
|
8
8
|
from api_tokens.models import ApiToken
|
|
9
9
|
from api_tokens.module import ApiTokensModule
|
|
10
10
|
from simple_module_core.events import EventBus
|
|
@@ -5,8 +5,14 @@ from __future__ import annotations
|
|
|
5
5
|
import hashlib
|
|
6
6
|
from types import SimpleNamespace
|
|
7
7
|
|
|
8
|
-
from api_tokens.constants import SECRET_LENGTH, TokenKind
|
|
9
|
-
from api_tokens.
|
|
8
|
+
from api_tokens.core.constants import SECRET_LENGTH, TokenKind
|
|
9
|
+
from api_tokens.credentials.format import (
|
|
10
|
+
base62,
|
|
11
|
+
display_prefix,
|
|
12
|
+
generate,
|
|
13
|
+
hash_token,
|
|
14
|
+
is_well_formed,
|
|
15
|
+
)
|
|
10
16
|
from auth.contracts.schemas import UserContext
|
|
11
17
|
from auth.contracts.tokens import is_api_token
|
|
12
18
|
from simple_module_core.permissions import is_admin_principal
|
|
@@ -32,7 +32,7 @@ MEMBERS_URL = "/api/tenants/current/members"
|
|
|
32
32
|
|
|
33
33
|
async def _member_ids(resp: httpx.Response) -> set[str]:
|
|
34
34
|
assert resp.status_code == 200, resp.text
|
|
35
|
-
return {str(m["user_id"]) for m in resp.json()}
|
|
35
|
+
return {str(m["user_id"]) for m in resp.json()["items"]}
|
|
36
36
|
|
|
37
37
|
|
|
38
38
|
async def test_pat_is_pinned_to_its_tenant_whatever_the_header_says(app, actor, bearer):
|
|
@@ -59,7 +59,7 @@ async def test_pat_is_pinned_to_its_tenant_whatever_the_header_says(app, actor,
|
|
|
59
59
|
async def _remove_membership(app: Any, user_id: str, tenant_id: str) -> None:
|
|
60
60
|
from sqlalchemy import delete
|
|
61
61
|
from tenants.models import Membership
|
|
62
|
-
from tenants.resolver import forget
|
|
62
|
+
from tenants.resolution.resolver import forget
|
|
63
63
|
|
|
64
64
|
async with app.state.sm.db.session_factory() as session:
|
|
65
65
|
await session.execute(
|
|
@@ -83,9 +83,9 @@ async def test_pat_stops_working_once_the_owner_leaves_its_tenant(app, actor, be
|
|
|
83
83
|
|
|
84
84
|
async def test_pat_stops_working_while_its_tenant_is_suspended(app, actor, bearer):
|
|
85
85
|
from sqlalchemy import update
|
|
86
|
-
from tenants.constants import TenantStatus
|
|
86
|
+
from tenants.core.constants import TenantStatus
|
|
87
87
|
from tenants.models import Tenant
|
|
88
|
-
from tenants.resolver import forget
|
|
88
|
+
from tenants.resolution.resolver import forget
|
|
89
89
|
|
|
90
90
|
async with actor(admin=True) as a:
|
|
91
91
|
token = (await create_pat(a.client, ["feature_flags.view"]))["token"]
|
|
@@ -149,9 +149,9 @@ async def test_session_with_an_authorization_header_cannot_mint(actor):
|
|
|
149
149
|
def test_service_key_drops_stored_tenant_and_admin_roles():
|
|
150
150
|
from datetime import UTC, datetime, timedelta
|
|
151
151
|
|
|
152
|
-
from api_tokens.constants import TokenKind
|
|
152
|
+
from api_tokens.core.constants import TokenKind
|
|
153
|
+
from api_tokens.credentials.resolver import _service
|
|
153
154
|
from api_tokens.models import ApiToken
|
|
154
|
-
from api_tokens.resolver import _service
|
|
155
155
|
|
|
156
156
|
row = ApiToken(
|
|
157
157
|
id=uuid.uuid4(),
|
|
@@ -168,7 +168,7 @@ def test_service_key_drops_stored_tenant_and_admin_roles():
|
|
|
168
168
|
|
|
169
169
|
|
|
170
170
|
async def test_no_pat_for_an_account_the_resolver_cannot_load(app, actor, monkeypatch):
|
|
171
|
-
from api_tokens.service import ApiTokenService
|
|
171
|
+
from api_tokens.credentials.service import ApiTokenService
|
|
172
172
|
|
|
173
173
|
async def missing(self, user_id) -> bool:
|
|
174
174
|
return False
|
|
@@ -185,7 +185,7 @@ async def test_no_pat_for_an_account_the_resolver_cannot_load(app, actor, monkey
|
|
|
185
185
|
|
|
186
186
|
|
|
187
187
|
async def test_has_usable_account(app):
|
|
188
|
-
from api_tokens.service import ApiTokenService
|
|
188
|
+
from api_tokens.credentials.service import ApiTokenService
|
|
189
189
|
from simple_module_core.user_directory import get_user_directory
|
|
190
190
|
|
|
191
191
|
user_id = await create_user(app, f"u-{uuid.uuid4().hex[:6]}@example.com")
|
|
@@ -7,8 +7,8 @@ from datetime import UTC, datetime, timedelta
|
|
|
7
7
|
|
|
8
8
|
import pytest
|
|
9
9
|
from _api_tokens_support import FLAGS_URL, create_pat, load_token, update_token
|
|
10
|
-
from api_tokens.constants import TokenKind
|
|
11
|
-
from api_tokens.
|
|
10
|
+
from api_tokens.core.constants import TokenKind
|
|
11
|
+
from api_tokens.credentials.format import generate
|
|
12
12
|
from starlette.requests import Request
|
|
13
13
|
|
|
14
14
|
|
|
@@ -90,7 +90,7 @@ async def test_disabled_owner_is_refused(app, actor, bearer):
|
|
|
90
90
|
|
|
91
91
|
async def test_token_survives_a_fresh_resolver_state(app, actor):
|
|
92
92
|
"""Nothing is cached in-process: a restart only needs the database row."""
|
|
93
|
-
from api_tokens.resolver import resolve_api_token
|
|
93
|
+
from api_tokens.credentials.resolver import resolve_api_token
|
|
94
94
|
|
|
95
95
|
async with actor(admin=True) as a:
|
|
96
96
|
token = (await create_pat(a.client, ["feature_flags.view"]))["token"]
|
|
@@ -127,8 +127,8 @@ async def test_last_used_is_written_at_most_once_per_window(app, actor, bearer):
|
|
|
127
127
|
|
|
128
128
|
async def test_users_provider_does_not_look_up_api_tokens(monkeypatch):
|
|
129
129
|
"""The provider steps aside for ``smpat_``/``smsk_`` without touching its store."""
|
|
130
|
-
import users.token_strategy
|
|
131
|
-
from users.provider import UsersAuthProvider
|
|
130
|
+
import users.accounts.token_strategy
|
|
131
|
+
from users.accounts.provider import UsersAuthProvider
|
|
132
132
|
|
|
133
133
|
calls: list[str] = []
|
|
134
134
|
|
|
@@ -136,7 +136,7 @@ async def test_users_provider_does_not_look_up_api_tokens(monkeypatch):
|
|
|
136
136
|
calls.append(token)
|
|
137
137
|
return
|
|
138
138
|
|
|
139
|
-
monkeypatch.setattr(users.token_strategy, "resolve_bearer", spy)
|
|
139
|
+
monkeypatch.setattr(users.accounts.token_strategy, "resolve_bearer", spy)
|
|
140
140
|
provider = UsersAuthProvider()
|
|
141
141
|
for credential in (
|
|
142
142
|
generate(TokenKind.PERSONAL).plaintext,
|
|
@@ -156,8 +156,8 @@ async def test_users_provider_does_not_look_up_api_tokens(monkeypatch):
|
|
|
156
156
|
|
|
157
157
|
async def test_personal_token_tenant_answer_varies_on_authorization(app, actor):
|
|
158
158
|
"""The tenant chosen for a PAT depended on its Authorization header, not a cookie."""
|
|
159
|
-
from api_tokens.resolver import resolve_api_token
|
|
160
|
-
from tenants.resolver import resolve_tenant
|
|
159
|
+
from api_tokens.credentials.resolver import resolve_api_token
|
|
160
|
+
from tenants.resolution.resolver import resolve_tenant
|
|
161
161
|
|
|
162
162
|
async with actor(admin=True) as a:
|
|
163
163
|
token = (await create_pat(a.client, ["feature_flags.view"]))["token"]
|
|
@@ -25,7 +25,7 @@ async def test_admin_token_is_capped_by_its_scopes(actor, bearer):
|
|
|
25
25
|
|
|
26
26
|
async def _set_roles(app, user_id: str, names: list[str]) -> None:
|
|
27
27
|
from sqlalchemy import delete, select
|
|
28
|
-
from users.bootstrap import ensure_user_role
|
|
28
|
+
from users.core.bootstrap import ensure_user_role
|
|
29
29
|
from users.models import Role, UserRole
|
|
30
30
|
|
|
31
31
|
async with app.state.sm.db.session_factory() as session:
|
|
@@ -104,9 +104,9 @@ async def test_lifetime_is_capped_by_the_setting(app, actor):
|
|
|
104
104
|
|
|
105
105
|
|
|
106
106
|
async def test_require_permission_admin_shortcut_skips_tokens():
|
|
107
|
-
"""``auth.deps.require_permission`` admits an admin session but not an admin token."""
|
|
107
|
+
"""``auth.web.deps.require_permission`` admits an admin session but not an admin token."""
|
|
108
108
|
from auth.contracts.schemas import UserContext
|
|
109
|
-
from auth.deps import require_permission
|
|
109
|
+
from auth.web.deps import require_permission
|
|
110
110
|
|
|
111
111
|
check = require_permission("x.write").dependency
|
|
112
112
|
translator = SimpleNamespace(t=lambda key, **_: key)
|
|
@@ -5,10 +5,10 @@ from __future__ import annotations
|
|
|
5
5
|
import uuid
|
|
6
6
|
from datetime import UTC, datetime, timedelta
|
|
7
7
|
|
|
8
|
-
from api_tokens.constants import PERM_USE, TokenKind
|
|
8
|
+
from api_tokens.core.constants import PERM_USE, TokenKind
|
|
9
|
+
from api_tokens.credentials.resolver import _personal
|
|
10
|
+
from api_tokens.credentials.service import ApiTokenService
|
|
9
11
|
from api_tokens.models import ApiToken
|
|
10
|
-
from api_tokens.resolver import _personal
|
|
11
|
-
from api_tokens.service import ApiTokenService
|
|
12
12
|
from auth.contracts.tokens import AUTH_KIND_PAT
|
|
13
13
|
from simple_module_core.user_directory import DirectoryUser, NullUserDirectory
|
|
14
14
|
|
|
@@ -56,8 +56,8 @@ async def test_only_managers_create_service_keys(actor):
|
|
|
56
56
|
|
|
57
57
|
|
|
58
58
|
async def test_service_principal_is_pinned_to_its_tenant(app, actor):
|
|
59
|
-
from api_tokens.resolver import resolve_api_token
|
|
60
|
-
from tenants.resolver import resolve_tenant
|
|
59
|
+
from api_tokens.credentials.resolver import resolve_api_token
|
|
60
|
+
from tenants.resolution.resolver import resolve_tenant
|
|
61
61
|
|
|
62
62
|
async with actor(admin=True) as a:
|
|
63
63
|
resp = await _create_key(a.client, roles=["user"], scopes=["feature_flags.view"])
|
|
@@ -24,7 +24,7 @@ EMAIL = "signup@example.com"
|
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
async def _register(app, client) -> str:
|
|
27
|
-
from users.bootstrap import ensure_user_role
|
|
27
|
+
from users.core.bootstrap import ensure_user_role
|
|
28
28
|
from users.models import User
|
|
29
29
|
|
|
30
30
|
# Test schemas come from ``create_all``: seed the role the migration would.
|
|
@@ -45,7 +45,7 @@ async def _register(app, client) -> str:
|
|
|
45
45
|
|
|
46
46
|
|
|
47
47
|
async def test_registration_attaches_the_user_role(app, client):
|
|
48
|
-
from users.constants import USER_ROLE_NAME
|
|
48
|
+
from users.core.constants import USER_ROLE_NAME
|
|
49
49
|
from users.models import Role, UserRole
|
|
50
50
|
|
|
51
51
|
user_id = await _register(app, client)
|
|
@@ -59,7 +59,7 @@ async def test_registration_attaches_the_user_role(app, client):
|
|
|
59
59
|
|
|
60
60
|
|
|
61
61
|
async def test_registered_user_can_open_the_tokens_page(app, client):
|
|
62
|
-
from api_tokens.constants import USER_URL
|
|
62
|
+
from api_tokens.core.constants import USER_URL
|
|
63
63
|
|
|
64
64
|
user_id = await _register(app, client)
|
|
65
65
|
async with session_client(app, {"user_id": user_id}) as c:
|
|
@@ -4,8 +4,8 @@ import uuid
|
|
|
4
4
|
|
|
5
5
|
import pytest
|
|
6
6
|
from _api_tokens_support import INERTIA_HEADERS, PAT_URL, create_pat
|
|
7
|
-
from api_tokens.constants import TokenKind
|
|
8
|
-
from api_tokens.service import ApiTokenService
|
|
7
|
+
from api_tokens.core.constants import TokenKind
|
|
8
|
+
from api_tokens.credentials.service import ApiTokenService
|
|
9
9
|
from simple_module_db.tenancy import tenant_context
|
|
10
10
|
|
|
11
11
|
|
|
@@ -4,7 +4,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
|
4
4
|
|
|
5
5
|
configureI18n({ locale: 'en', messages: {} });
|
|
6
6
|
|
|
7
|
-
import { CreatedTokenDialog } from '../api_tokens/
|
|
7
|
+
import { CreatedTokenDialog } from '../api_tokens/ui/components/CreatedTokenDialog';
|
|
8
8
|
|
|
9
9
|
const SECRET = 'smpy_pat_0123456789abcdef';
|
|
10
10
|
const c = keys.api_tokens.created;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{simple_module_api_tokens-0.0.43 → simple_module_api_tokens-0.0.45}/api_tokens/contracts/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{simple_module_api_tokens-0.0.43 → simple_module_api_tokens-0.0.45}/api_tokens/locales/de.json
RENAMED
|
File without changes
|
{simple_module_api_tokens-0.0.43 → simple_module_api_tokens-0.0.45}/api_tokens/locales/en.json
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|