Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion alembic.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# this is typically a path given in POSIX (e.g. forward slashes)
# format, relative to the token %(here)s which refers to the location of this
# ini file
script_location = src/app/infrastructure/persistence_sqla/alembic
script_location = src/app/outbound/persistence_sqla/alembic

# template used to generate migration file names; The default value is %%(rev)s_%%(slug)s
# Uncomment the line below if you want the files to be prepended with date and time
Expand Down
16 changes: 8 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,13 @@ type = "layers"
containers = ["app"]
layers = [
"(main)",
"presentation",
"infrastructure",
"inbound",
"outbound",
"core",
]
ignore_imports = [
"app.infrastructure.persistence_sqla.alembic.env -> app.main.config.loader",
"app.infrastructure.persistence_sqla.alembic.env -> app.main.config.settings",
"app.outbound.persistence_sqla.alembic.env -> app.main.config.loader",
"app.outbound.persistence_sqla.alembic.env -> app.main.config.settings",
]

[[tool.importlinter.contracts]]
Expand Down Expand Up @@ -137,8 +137,8 @@ forbidden_modules = ["app.core.commands"]
id = "auth-ctx"
name = "auth-ctx must use its own adapters"
type = "forbidden"
source_modules = ["app.infrastructure.auth_ctx"]
forbidden_modules = ["app.infrastructure.adapters"]
source_modules = ["app.outbound.auth_ctx"]
forbidden_modules = ["app.outbound.adapters"]

[tool.mypy]
mypy_path = ["src"]
Expand Down Expand Up @@ -247,7 +247,7 @@ split-on-trailing-comma = true

[tool.ruff.lint.per-file-ignores]
"scripts/dishka/plot_dependencies_data.py" = ["T201"] # print
"src/app/infrastructure/persistence_sqla/alembic/**" = ["ALL"]
"src/app/outbound/persistence_sqla/alembic/**" = ["ALL"]
"tests/**" = [
"ARG002", # unused-method-argument
"PLC2801", # unnecessary-dunder-call
Expand All @@ -263,7 +263,7 @@ split-on-trailing-comma = true
[tool.slotscheck]
strict-imports = true
exclude-modules = '''
^app\.infrastructure\.persistence_sqla\.alembic
^app\.outbound\.persistence_sqla\.alembic
'''

[tool.typos.files]
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@

from app.core.common.authorization.exceptions import AuthorizationError
from app.core.common.exceptions import BusinessTypeError
from app.infrastructure.adapters.exceptions import PasswordHasherBusyError
from app.infrastructure.auth_ctx.exceptions import AuthenticationChangeError, AuthenticationError, ReAuthenticationError
from app.infrastructure.auth_ctx.handlers.change_password import ChangePassword, ChangePasswordRequest
from app.infrastructure.exceptions import StorageError
from app.presentation.http.errors.callbacks import log_info
from app.presentation.http.errors.rules import HTTP_503_SERVICE_UNAVAILABLE_RULE
from app.inbound.http.errors.callbacks import log_info
from app.inbound.http.errors.rules import HTTP_503_SERVICE_UNAVAILABLE_RULE
from app.outbound.adapters.exceptions import PasswordHasherBusyError
from app.outbound.auth_ctx.exceptions import AuthenticationChangeError, AuthenticationError, ReAuthenticationError
from app.outbound.auth_ctx.handlers.change_password import ChangePassword, ChangePasswordRequest
from app.outbound.exceptions import StorageError


class ChangePasswordRequestSchema(BaseModel):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@

from app.core.common.authorization.exceptions import AuthorizationError
from app.core.common.exceptions import BusinessTypeError
from app.infrastructure.adapters.exceptions import PasswordHasherBusyError
from app.infrastructure.auth_ctx.exceptions import AlreadyAuthenticatedError, AuthenticationError
from app.infrastructure.auth_ctx.handlers.log_in import LogIn, LogInRequest
from app.infrastructure.exceptions import StorageError
from app.presentation.http.errors.callbacks import log_info
from app.presentation.http.errors.rules import HTTP_503_SERVICE_UNAVAILABLE_RULE
from app.inbound.http.errors.callbacks import log_info
from app.inbound.http.errors.rules import HTTP_503_SERVICE_UNAVAILABLE_RULE
from app.outbound.adapters.exceptions import PasswordHasherBusyError
from app.outbound.auth_ctx.exceptions import AlreadyAuthenticatedError, AuthenticationError
from app.outbound.auth_ctx.handlers.log_in import LogIn, LogInRequest
from app.outbound.exceptions import StorageError


def make_log_in_router() -> APIRouter:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
from fastapi_error_map import ErrorAwareRouter

from app.core.common.authorization.exceptions import AuthorizationError
from app.infrastructure.auth_ctx.exceptions import AuthenticationError
from app.infrastructure.auth_ctx.handlers.log_out import LogOut
from app.infrastructure.exceptions import StorageError
from app.presentation.http.errors.callbacks import log_info
from app.presentation.http.errors.rules import HTTP_503_SERVICE_UNAVAILABLE_RULE
from app.inbound.http.errors.callbacks import log_info
from app.inbound.http.errors.rules import HTTP_503_SERVICE_UNAVAILABLE_RULE
from app.outbound.auth_ctx.exceptions import AuthenticationError
from app.outbound.auth_ctx.handlers.log_out import LogOut
from app.outbound.exceptions import StorageError


def make_log_out_router(*, cookie_name: str) -> APIRouter:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from fastapi import APIRouter

from app.presentation.http.account.change_password import make_change_password_router
from app.presentation.http.account.log_in import make_log_in_router
from app.presentation.http.account.log_out import make_log_out_router
from app.presentation.http.account.sign_up import make_sign_up_router
from app.inbound.http.account.change_password import make_change_password_router
from app.inbound.http.account.log_in import make_log_in_router
from app.inbound.http.account.log_out import make_log_out_router
from app.inbound.http.account.sign_up import make_sign_up_router


def make_account_router(*, cookie_name: str) -> APIRouter:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
from app.core.commands.exceptions import UsernameAlreadyExistsError
from app.core.common.authorization.exceptions import AuthorizationError
from app.core.common.exceptions import BusinessTypeError
from app.infrastructure.adapters.exceptions import PasswordHasherBusyError
from app.infrastructure.auth_ctx.exceptions import AlreadyAuthenticatedError
from app.infrastructure.auth_ctx.handlers.sign_up import SignUp, SignUpRequest
from app.infrastructure.exceptions import StorageError
from app.presentation.http.errors.callbacks import log_info
from app.presentation.http.errors.rules import HTTP_503_SERVICE_UNAVAILABLE_RULE
from app.inbound.http.errors.callbacks import log_info
from app.inbound.http.errors.rules import HTTP_503_SERVICE_UNAVAILABLE_RULE
from app.outbound.adapters.exceptions import PasswordHasherBusyError
from app.outbound.auth_ctx.exceptions import AlreadyAuthenticatedError
from app.outbound.auth_ctx.handlers.sign_up import SignUp, SignUpRequest
from app.outbound.exceptions import StorageError


def make_sign_up_router() -> APIRouter:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from fastapi import APIRouter

from app.presentation.http.account.router import make_account_router
from app.presentation.http.users.router import make_users_router
from app.inbound.http.account.router import make_account_router
from app.inbound.http.users.router import make_users_router


def make_v1_router(*, cookie_name: str) -> APIRouter:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from starlette.responses import Response
from starlette.types import ASGIApp

from app.infrastructure.auth_ctx.cookie_manager import STAGED_COOKIE
from app.outbound.auth_ctx.cookie_manager import STAGED_COOKIE


class AuthCookieMiddleware(BaseHTTPMiddleware):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from fastapi_error_map.rules import Rule, rule
from starlette import status

from app.presentation.http.errors.translators import ServiceUnavailableTranslator
from app.inbound.http.errors.translators import ServiceUnavailableTranslator

HTTP_503_SERVICE_UNAVAILABLE_RULE: Final[Rule] = rule(
status=status.HTTP_503_SERVICE_UNAVAILABLE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from fastapi import APIRouter
from sqlalchemy.ext.asyncio import AsyncSession

from app.presentation.http.health.checks import db_check
from app.inbound.http.health.checks import db_check


class InternalServerError(Exception):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from fastapi import APIRouter
from starlette.responses import RedirectResponse

from app.presentation.http.api_v1_router import make_v1_router
from app.presentation.http.health.router import make_health_router
from app.inbound.http.api_v1_router import make_v1_router
from app.inbound.http.health.router import make_health_router


def make_fastapi_root_router(*, debug_mode: bool, cookie_name: str) -> APIRouter:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
from app.core.commands.activate_user import ActivateUser, ActivateUserRequest
from app.core.commands.exceptions import UserNotFoundError
from app.core.common.authorization.exceptions import AuthorizationError
from app.infrastructure.auth_ctx.exceptions import AuthenticationError
from app.infrastructure.exceptions import StorageError
from app.presentation.http.errors.callbacks import log_info
from app.presentation.http.errors.rules import HTTP_503_SERVICE_UNAVAILABLE_RULE
from app.inbound.http.errors.callbacks import log_info
from app.inbound.http.errors.rules import HTTP_503_SERVICE_UNAVAILABLE_RULE
from app.outbound.auth_ctx.exceptions import AuthenticationError
from app.outbound.exceptions import StorageError


def make_activate_user_router() -> APIRouter:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
)
from app.core.common.authorization.exceptions import AuthorizationError
from app.core.common.exceptions import BusinessTypeError
from app.infrastructure.adapters.exceptions import PasswordHasherBusyError
from app.infrastructure.auth_ctx.exceptions import AuthenticationError
from app.infrastructure.exceptions import StorageError
from app.presentation.http.errors.callbacks import log_info
from app.presentation.http.errors.rules import HTTP_503_SERVICE_UNAVAILABLE_RULE
from app.inbound.http.errors.callbacks import log_info
from app.inbound.http.errors.rules import HTTP_503_SERVICE_UNAVAILABLE_RULE
from app.outbound.adapters.exceptions import PasswordHasherBusyError
from app.outbound.auth_ctx.exceptions import AuthenticationError
from app.outbound.exceptions import StorageError


def make_create_user_router() -> APIRouter:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
from app.core.commands.deactivate_user import DeactivateUser, DeactivateUserRequest
from app.core.commands.exceptions import UserNotFoundError
from app.core.common.authorization.exceptions import AuthorizationError
from app.infrastructure.auth_ctx.exceptions import AuthenticationError
from app.infrastructure.exceptions import StorageError
from app.presentation.http.errors.callbacks import log_info
from app.presentation.http.errors.rules import HTTP_503_SERVICE_UNAVAILABLE_RULE
from app.inbound.http.errors.callbacks import log_info
from app.inbound.http.errors.rules import HTTP_503_SERVICE_UNAVAILABLE_RULE
from app.outbound.auth_ctx.exceptions import AuthenticationError
from app.outbound.exceptions import StorageError


def make_deactivate_user_router() -> APIRouter:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
from app.core.commands.exceptions import UserNotFoundError
from app.core.commands.grant_admin import GrantAdmin, GrantAdminRequest
from app.core.common.authorization.exceptions import AuthorizationError
from app.infrastructure.auth_ctx.exceptions import AuthenticationError
from app.infrastructure.exceptions import StorageError
from app.presentation.http.errors.callbacks import log_info
from app.presentation.http.errors.rules import HTTP_503_SERVICE_UNAVAILABLE_RULE
from app.inbound.http.errors.callbacks import log_info
from app.inbound.http.errors.rules import HTTP_503_SERVICE_UNAVAILABLE_RULE
from app.outbound.auth_ctx.exceptions import AuthenticationError
from app.outbound.exceptions import StorageError


def make_grant_admin_router() -> APIRouter:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
from app.core.queries.query_support.exceptions import PaginationError
from app.core.queries.query_support.offset_pagination import OffsetPaginationParams
from app.core.queries.query_support.sorting import SortingOrder
from app.infrastructure.auth_ctx.exceptions import AuthenticationError
from app.infrastructure.exceptions import ReaderError, StorageError
from app.presentation.http.errors.callbacks import log_info
from app.presentation.http.errors.rules import HTTP_503_SERVICE_UNAVAILABLE_RULE
from app.inbound.http.errors.callbacks import log_info
from app.inbound.http.errors.rules import HTTP_503_SERVICE_UNAVAILABLE_RULE
from app.outbound.auth_ctx.exceptions import AuthenticationError
from app.outbound.exceptions import ReaderError, StorageError


class ListUsersRequestSchema(BaseModel):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
from app.core.commands.exceptions import UserNotFoundError
from app.core.commands.revoke_admin import RevokeAdmin, RevokeAdminRequest
from app.core.common.authorization.exceptions import AuthorizationError
from app.infrastructure.auth_ctx.exceptions import AuthenticationError
from app.infrastructure.exceptions import StorageError
from app.presentation.http.errors.callbacks import log_info
from app.presentation.http.errors.rules import HTTP_503_SERVICE_UNAVAILABLE_RULE
from app.inbound.http.errors.callbacks import log_info
from app.inbound.http.errors.rules import HTTP_503_SERVICE_UNAVAILABLE_RULE
from app.outbound.auth_ctx.exceptions import AuthenticationError
from app.outbound.exceptions import StorageError


def make_revoke_admin_router() -> APIRouter:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from fastapi import APIRouter, Depends
from fastapi.security import APIKeyCookie

from app.presentation.http.users.activate_user import make_activate_user_router
from app.presentation.http.users.create_user import make_create_user_router
from app.presentation.http.users.deactivate_user import make_deactivate_user_router
from app.presentation.http.users.grant_admin import make_grant_admin_router
from app.presentation.http.users.list_users import make_list_users_router
from app.presentation.http.users.revoke_admin import make_revoke_admin_router
from app.presentation.http.users.set_user_password import make_set_user_password_router
from app.inbound.http.users.activate_user import make_activate_user_router
from app.inbound.http.users.create_user import make_create_user_router
from app.inbound.http.users.deactivate_user import make_deactivate_user_router
from app.inbound.http.users.grant_admin import make_grant_admin_router
from app.inbound.http.users.list_users import make_list_users_router
from app.inbound.http.users.revoke_admin import make_revoke_admin_router
from app.inbound.http.users.set_user_password import make_set_user_password_router


def make_users_router(*, cookie_name: str) -> APIRouter:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
from app.core.commands.set_user_password import SetUserPassword, SetUserPasswordRequest
from app.core.common.authorization.exceptions import AuthorizationError
from app.core.common.exceptions import BusinessTypeError
from app.infrastructure.adapters.exceptions import PasswordHasherBusyError
from app.infrastructure.auth_ctx.exceptions import AuthenticationError
from app.infrastructure.exceptions import StorageError
from app.presentation.http.errors.callbacks import log_info
from app.presentation.http.errors.rules import HTTP_503_SERVICE_UNAVAILABLE_RULE
from app.inbound.http.errors.callbacks import log_info
from app.inbound.http.errors.rules import HTTP_503_SERVICE_UNAVAILABLE_RULE
from app.outbound.adapters.exceptions import PasswordHasherBusyError
from app.outbound.auth_ctx.exceptions import AuthenticationError
from app.outbound.exceptions import StorageError


class SetUserPasswordRequestSchema(BaseModel):
Expand Down
2 changes: 1 addition & 1 deletion src/app/main/config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

from pydantic import BaseModel, Field, PostgresDsn

from app.infrastructure.auth_ctx.jwt_types import JwtAlgorithm
from app.main.config.logging_ import LoggingLevel
from app.outbound.auth_ctx.jwt_types import JwtAlgorithm


class AppSettings(BaseModel):
Expand Down
18 changes: 9 additions & 9 deletions src/app/main/ioc/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@
from app.core.common.services.user import UserService
from app.core.queries.list_users import ListUsers
from app.core.queries.ports.user_reader import UserReader
from app.infrastructure.adapters.auth_session_access_revoker import AuthSessionAccessRevoker
from app.infrastructure.adapters.auth_session_identity_provider import AuthSessionIdentityProvider
from app.infrastructure.adapters.bcrypt_password_hasher import (
from app.main.config.settings import PasswordHasherSettings
from app.outbound.adapters.auth_session_access_revoker import AuthSessionAccessRevoker
from app.outbound.adapters.auth_session_identity_provider import AuthSessionIdentityProvider
from app.outbound.adapters.bcrypt_password_hasher import (
BcryptPasswordHasher,
HasherSemaphore,
HasherThreadPoolExecutor,
)
from app.infrastructure.adapters.sqla_flusher import SqlaFlusher
from app.infrastructure.adapters.sqla_transaction_manager import SqlaTransactionManager
from app.infrastructure.adapters.sqla_user_reader import SqlaUserReader
from app.infrastructure.adapters.sqla_user_tx_storage import SqlaUserTxStorage
from app.infrastructure.adapters.system_utc_timer import SystemUtcTimer
from app.main.config.settings import PasswordHasherSettings
from app.outbound.adapters.sqla_flusher import SqlaFlusher
from app.outbound.adapters.sqla_transaction_manager import SqlaTransactionManager
from app.outbound.adapters.sqla_user_reader import SqlaUserReader
from app.outbound.adapters.sqla_user_tx_storage import SqlaUserTxStorage
from app.outbound.adapters.system_utc_timer import SystemUtcTimer


class CoreProvider(Provider):
Expand Down
Loading