Skip to content

Commit 5def694

Browse files
committed
refactor: move auth.py into legacy and auth directories for soft merging
1 parent 00a8e4c commit 5def694

File tree

5 files changed

+1233
-5
lines changed

5 files changed

+1233
-5
lines changed

changes/8353.enhance.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
On perpose of soft merging for manager's auth apis, defining DTO's and actions, moving auth into seperated directory.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
"""
2+
Auth API package.
3+
4+
Re-exports from auth.auth (legacy function-based handlers) for backward compatibility.
5+
"""
6+
7+
from .auth import ( # noqa: F401
8+
_extract_auth_params,
9+
admin_required,
10+
admin_required_for_method,
11+
auth_middleware,
12+
auth_required,
13+
auth_required_for_method,
14+
authorize,
15+
check_date,
16+
create_app,
17+
generate_ssh_keypair,
18+
get_role,
19+
get_ssh_keypair,
20+
sign_request,
21+
signout,
22+
signup,
23+
superadmin_required,
24+
superadmin_required_for_method,
25+
test,
26+
update_full_name,
27+
update_password,
28+
update_password_no_auth,
29+
upload_ssh_keypair,
30+
validate_ip,
31+
whois_timezone_info,
32+
)
Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
"""
2+
Legacy auth handlers (function-based).
3+
4+
DEPRECATED: This module is preserved for regression testing only.
5+
Use ai.backend.manager.api.auth (class-based handlers) for production.
6+
"""
7+
18
from __future__ import annotations
29

310
import functools
@@ -23,7 +30,7 @@
2330
from ai.backend.common import validators as tx
2431
from ai.backend.common.contexts.user import with_user
2532
from ai.backend.common.data.user.types import UserData, UserRole
26-
from ai.backend.common.dto.manager.auth.field import (
33+
from ai.backend.common.dto.manager.auth.types import (
2734
AuthResponseType,
2835
AuthSuccessResponse,
2936
AuthTokenType,
@@ -34,6 +41,8 @@
3441
from ai.backend.common.types import ReadableCIDR
3542
from ai.backend.logging import BraceStyleAdapter
3643
from ai.backend.logging.utils import with_log_context_fields
44+
from ai.backend.manager.api.types import CORSOptions, WebMiddleware
45+
from ai.backend.manager.api.utils import check_api_params, get_handler_attr, set_handler_attr
3746
from ai.backend.manager.errors.auth import (
3847
AuthorizationFailed,
3948
InvalidAuthParameters,
@@ -60,11 +69,8 @@
6069
)
6170
from ai.backend.manager.services.auth.actions.upload_ssh_keypair import UploadSSHKeypairAction
6271

63-
from .types import CORSOptions, WebMiddleware
64-
from .utils import check_api_params, get_handler_attr, set_handler_attr
65-
6672
if TYPE_CHECKING:
67-
from .context import RootContext
73+
from ai.backend.manager.api.context import RootContext
6874

6975
log: Final = BraceStyleAdapter(logging.getLogger(__spec__.name)) # type: ignore[name-defined]
7076

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
"""
2+
Legacy API handlers.
3+
4+
This module contains old function-based handlers preserved for regression testing.
5+
These handlers should NOT be used in production - use the new class-based handlers instead.
6+
7+
Contents:
8+
- auth: Legacy auth handlers (replaced by api/auth/ package)
9+
"""
10+
11+
from __future__ import annotations
12+
13+
from . import auth
14+
15+
__all__ = ("auth",)

0 commit comments

Comments
 (0)