fractal-server 2.3.11__py3-none-any.whl → 2.4.0a1__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.
- fractal_server/__init__.py +1 -1
- fractal_server/__main__.py +25 -2
- fractal_server/app/models/__init__.py +11 -5
- fractal_server/app/models/linkusergroup.py +11 -0
- fractal_server/app/models/security.py +24 -3
- fractal_server/app/models/v1/project.py +1 -1
- fractal_server/app/models/v2/project.py +3 -3
- fractal_server/app/routes/admin/v1.py +14 -14
- fractal_server/app/routes/admin/v2.py +12 -12
- fractal_server/app/routes/api/__init__.py +2 -2
- fractal_server/app/routes/api/v1/_aux_functions.py +2 -2
- fractal_server/app/routes/api/v1/dataset.py +17 -15
- fractal_server/app/routes/api/v1/job.py +11 -9
- fractal_server/app/routes/api/v1/project.py +9 -9
- fractal_server/app/routes/api/v1/task.py +8 -8
- fractal_server/app/routes/api/v1/task_collection.py +5 -5
- fractal_server/app/routes/api/v1/workflow.py +13 -11
- fractal_server/app/routes/api/v1/workflowtask.py +6 -6
- fractal_server/app/routes/api/v2/_aux_functions.py +2 -2
- fractal_server/app/routes/api/v2/dataset.py +11 -11
- fractal_server/app/routes/api/v2/images.py +6 -6
- fractal_server/app/routes/api/v2/job.py +9 -9
- fractal_server/app/routes/api/v2/project.py +7 -7
- fractal_server/app/routes/api/v2/status.py +3 -3
- fractal_server/app/routes/api/v2/submit.py +3 -3
- fractal_server/app/routes/api/v2/task.py +8 -8
- fractal_server/app/routes/api/v2/task_collection.py +5 -5
- fractal_server/app/routes/api/v2/task_collection_custom.py +3 -3
- fractal_server/app/routes/api/v2/task_legacy.py +9 -9
- fractal_server/app/routes/api/v2/workflow.py +11 -11
- fractal_server/app/routes/api/v2/workflowtask.py +6 -6
- fractal_server/app/routes/auth/__init__.py +55 -0
- fractal_server/app/routes/auth/_aux_auth.py +107 -0
- fractal_server/app/routes/auth/current_user.py +60 -0
- fractal_server/app/routes/auth/group.py +159 -0
- fractal_server/app/routes/auth/group_names.py +34 -0
- fractal_server/app/routes/auth/login.py +25 -0
- fractal_server/app/routes/auth/oauth.py +63 -0
- fractal_server/app/routes/auth/register.py +23 -0
- fractal_server/app/routes/auth/router.py +19 -0
- fractal_server/app/routes/auth/users.py +173 -0
- fractal_server/app/schemas/user.py +7 -0
- fractal_server/app/schemas/user_group.py +57 -0
- fractal_server/app/security/__init__.py +72 -75
- fractal_server/data_migrations/2_4_0.py +61 -0
- fractal_server/main.py +1 -9
- fractal_server/migrations/versions/091b01f51f88_add_usergroup_and_linkusergroup_table.py +53 -0
- {fractal_server-2.3.11.dist-info → fractal_server-2.4.0a1.dist-info}/METADATA +1 -1
- {fractal_server-2.3.11.dist-info → fractal_server-2.4.0a1.dist-info}/RECORD +52 -39
- fractal_server/app/routes/auth.py +0 -165
- {fractal_server-2.3.11.dist-info → fractal_server-2.4.0a1.dist-info}/LICENSE +0 -0
- {fractal_server-2.3.11.dist-info → fractal_server-2.4.0a1.dist-info}/WHEEL +0 -0
- {fractal_server-2.3.11.dist-info → fractal_server-2.4.0a1.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,61 @@
|
|
1
|
+
import logging
|
2
|
+
|
3
|
+
from packaging.version import parse
|
4
|
+
from sqlalchemy import select
|
5
|
+
|
6
|
+
import fractal_server
|
7
|
+
from fractal_server.app.db import get_sync_db
|
8
|
+
from fractal_server.app.models import LinkUserGroup
|
9
|
+
from fractal_server.app.models import UserGroup
|
10
|
+
from fractal_server.app.models import UserOAuth
|
11
|
+
from fractal_server.app.security import FRACTAL_DEFAULT_GROUP_NAME
|
12
|
+
|
13
|
+
|
14
|
+
def _check_current_version(*, expected_version: str):
|
15
|
+
# Check that this module matches with the current version
|
16
|
+
module_version = parse(expected_version)
|
17
|
+
current_version = parse(fractal_server.__VERSION__)
|
18
|
+
if (
|
19
|
+
current_version.major != module_version.major
|
20
|
+
or current_version.minor != module_version.minor
|
21
|
+
or current_version.micro != module_version.micro
|
22
|
+
):
|
23
|
+
raise RuntimeError(
|
24
|
+
f"{fractal_server.__VERSION__=} not matching with {__file__=}"
|
25
|
+
)
|
26
|
+
|
27
|
+
|
28
|
+
def fix_db():
|
29
|
+
logger = logging.getLogger("fix_db")
|
30
|
+
logger.warning("START execution of fix_db function")
|
31
|
+
_check_current_version(expected_version="2.4.0")
|
32
|
+
|
33
|
+
with next(get_sync_db()) as db:
|
34
|
+
# Find default group
|
35
|
+
stm = select(UserGroup).where(
|
36
|
+
UserGroup.name == FRACTAL_DEFAULT_GROUP_NAME
|
37
|
+
)
|
38
|
+
res = db.execute(stm)
|
39
|
+
default_group = res.scalar_one_or_none()
|
40
|
+
if default_group is None:
|
41
|
+
raise RuntimeError("Default group not found, exit.")
|
42
|
+
logger.warning(
|
43
|
+
"Default user group exists: "
|
44
|
+
f"{default_group.id=}, {default_group.name=}."
|
45
|
+
)
|
46
|
+
|
47
|
+
# Find
|
48
|
+
stm = select(UserOAuth)
|
49
|
+
users = db.execute(stm).scalars().unique().all()
|
50
|
+
for user in sorted(users, key=lambda x: x.id):
|
51
|
+
logger.warning(
|
52
|
+
f"START adding {user.id=} ({user.email=}) to default group."
|
53
|
+
)
|
54
|
+
link = LinkUserGroup(user_id=user.id, group_id=default_group.id)
|
55
|
+
db.add(link)
|
56
|
+
db.commit()
|
57
|
+
logger.warning(
|
58
|
+
f"END adding {user.id=} ({user.email=}) to default group."
|
59
|
+
)
|
60
|
+
|
61
|
+
logger.warning("END of execution of fix_db function")
|
fractal_server/main.py
CHANGED
@@ -22,7 +22,6 @@ from fastapi import FastAPI
|
|
22
22
|
|
23
23
|
from .app.routes.aux._runner import _backend_supports_shutdown # FIXME: change
|
24
24
|
from .app.runner.shutdown import cleanup_after_shutdown
|
25
|
-
from .app.security import _create_first_user
|
26
25
|
from .config import get_settings
|
27
26
|
from .logger import config_uvicorn_loggers
|
28
27
|
from .logger import get_logger
|
@@ -44,7 +43,7 @@ def collect_routers(app: FastAPI) -> None:
|
|
44
43
|
from .app.routes.api.v2 import router_api_v2
|
45
44
|
from .app.routes.admin.v1 import router_admin_v1
|
46
45
|
from .app.routes.admin.v2 import router_admin_v2
|
47
|
-
from .app.routes.auth import router_auth
|
46
|
+
from .app.routes.auth.router import router_auth
|
48
47
|
|
49
48
|
settings = Inject(get_settings)
|
50
49
|
|
@@ -91,13 +90,6 @@ async def lifespan(app: FastAPI):
|
|
91
90
|
logger.info("Start application startup")
|
92
91
|
check_settings()
|
93
92
|
settings = Inject(get_settings)
|
94
|
-
await _create_first_user(
|
95
|
-
email=settings.FRACTAL_DEFAULT_ADMIN_EMAIL,
|
96
|
-
password=settings.FRACTAL_DEFAULT_ADMIN_PASSWORD,
|
97
|
-
username=settings.FRACTAL_DEFAULT_ADMIN_USERNAME,
|
98
|
-
is_superuser=True,
|
99
|
-
is_verified=True,
|
100
|
-
)
|
101
93
|
|
102
94
|
if settings.FRACTAL_RUNNER_BACKEND == "slurm_ssh":
|
103
95
|
from fractal_server.ssh._fabric import get_ssh_connection
|
@@ -0,0 +1,53 @@
|
|
1
|
+
"""“Add_usergroup_and_linkusergroup_table”
|
2
|
+
|
3
|
+
Revision ID: 091b01f51f88
|
4
|
+
Revises: 5bf02391cfef
|
5
|
+
Create Date: 2024-09-09 13:17:51.008231
|
6
|
+
|
7
|
+
"""
|
8
|
+
import sqlalchemy as sa
|
9
|
+
import sqlmodel
|
10
|
+
from alembic import op
|
11
|
+
|
12
|
+
|
13
|
+
# revision identifiers, used by Alembic.
|
14
|
+
revision = "091b01f51f88"
|
15
|
+
down_revision = "5bf02391cfef"
|
16
|
+
branch_labels = None
|
17
|
+
depends_on = None
|
18
|
+
|
19
|
+
|
20
|
+
def upgrade() -> None:
|
21
|
+
# ### commands auto generated by Alembic - please adjust! ###
|
22
|
+
op.create_table(
|
23
|
+
"usergroup",
|
24
|
+
sa.Column("id", sa.Integer(), nullable=False),
|
25
|
+
sa.Column("name", sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
26
|
+
sa.Column(
|
27
|
+
"timestamp_created", sa.DateTime(timezone=True), nullable=False
|
28
|
+
),
|
29
|
+
sa.PrimaryKeyConstraint("id"),
|
30
|
+
sa.UniqueConstraint("name"),
|
31
|
+
)
|
32
|
+
op.create_table(
|
33
|
+
"linkusergroup",
|
34
|
+
sa.Column("group_id", sa.Integer(), nullable=False),
|
35
|
+
sa.Column("user_id", sa.Integer(), nullable=False),
|
36
|
+
sa.ForeignKeyConstraint(
|
37
|
+
["group_id"],
|
38
|
+
["usergroup.id"],
|
39
|
+
),
|
40
|
+
sa.ForeignKeyConstraint(
|
41
|
+
["user_id"],
|
42
|
+
["user_oauth.id"],
|
43
|
+
),
|
44
|
+
sa.PrimaryKeyConstraint("group_id", "user_id"),
|
45
|
+
)
|
46
|
+
# ### end Alembic commands ###
|
47
|
+
|
48
|
+
|
49
|
+
def downgrade() -> None:
|
50
|
+
# ### commands auto generated by Alembic - please adjust! ###
|
51
|
+
op.drop_table("linkusergroup")
|
52
|
+
op.drop_table("usergroup")
|
53
|
+
# ### end Alembic commands ###
|
@@ -1,15 +1,16 @@
|
|
1
|
-
fractal_server/__init__.py,sha256=
|
2
|
-
fractal_server/__main__.py,sha256=
|
1
|
+
fractal_server/__init__.py,sha256=82UdKyiu21w5Ad9EyPoIbpiHLVC1oA6id-sFK4o1cnc,24
|
2
|
+
fractal_server/__main__.py,sha256=I9hF_SYc-GTZWDZZhihwyUBK7BMU5GAecbPLTjkpW4U,5830
|
3
3
|
fractal_server/alembic.ini,sha256=MWwi7GzjzawI9cCAK1LW7NxIBQDUqD12-ptJoq5JpP0,3153
|
4
4
|
fractal_server/app/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
5
5
|
fractal_server/app/db/__init__.py,sha256=KpS_mfmRfew0kieFDlwkSrDFvpzxftcvPALBBZ0LxsY,4048
|
6
|
-
fractal_server/app/models/__init__.py,sha256=
|
6
|
+
fractal_server/app/models/__init__.py,sha256=zt0Tiv91DWLg0daT8bkENz-LusihOJJX1h09UfHlAns,452
|
7
|
+
fractal_server/app/models/linkusergroup.py,sha256=ufthlbLFAWMU_dJmsVZzVlQa_D9C9SmgydxypQ2Xq1U,309
|
7
8
|
fractal_server/app/models/linkuserproject.py,sha256=eQaourbGRshvlMVlKzLYJKHEjfsW1CbWws9yW4eHXhA,567
|
8
|
-
fractal_server/app/models/security.py,sha256=
|
9
|
+
fractal_server/app/models/security.py,sha256=JGC3NNakIbJWhwksSIgJq0Jawo7m_fhsWX9L-uKpWJc,3551
|
9
10
|
fractal_server/app/models/v1/__init__.py,sha256=hUI7dEbPaiZGN0IbHW4RSmSicyvtn_xeuevoX7zvUwI,466
|
10
11
|
fractal_server/app/models/v1/dataset.py,sha256=99GDgt7njx8yYQApkImqp_7bHA5HH3ElvbR6Oyj9kVI,2017
|
11
12
|
fractal_server/app/models/v1/job.py,sha256=QLGXcWdVRHaUHQNDapYYlLpEfw4K7QyD8TmcwhrWw2o,3304
|
12
|
-
fractal_server/app/models/v1/project.py,sha256=
|
13
|
+
fractal_server/app/models/v1/project.py,sha256=JG7b5J9CzVNxua4MaMYpfB57xt2qjbXr5SnR7_oKQ70,819
|
13
14
|
fractal_server/app/models/v1/state.py,sha256=m9gMZqqnm3oDpJNJp-Lht4kM7oO7pcEI7sL1g7LFvWU,1043
|
14
15
|
fractal_server/app/models/v1/task.py,sha256=3xZqNeFYUqslh8ddMSXF2nO4nIiOD8T5Ij37wY20kss,2782
|
15
16
|
fractal_server/app/models/v1/workflow.py,sha256=dnY5eMaOe3oZv8arn00RNX9qVkBtTLG-vYdWXcQuyo4,3950
|
@@ -17,39 +18,48 @@ fractal_server/app/models/v2/__init__.py,sha256=uLzdInqATSwi0bS_V4vKB-TqFrOFaXux
|
|
17
18
|
fractal_server/app/models/v2/collection_state.py,sha256=nxb042i8tt8rCpmgbFJoBCYWU-34m0HdUfO9YurTp8k,588
|
18
19
|
fractal_server/app/models/v2/dataset.py,sha256=-7sxHEw4IIAvF_uSan7tA3o8hvoakBkQ0SRvqS2iOQU,1455
|
19
20
|
fractal_server/app/models/v2/job.py,sha256=ypJmN-qspkKBGhBG7Mt-HypSQqcQ2EmB4Bzzb2-y550,1535
|
20
|
-
fractal_server/app/models/v2/project.py,sha256=
|
21
|
+
fractal_server/app/models/v2/project.py,sha256=rAHoh5KfYwIaW7rTX0_O0jvWmxEvfo1BafvmcXuSSRk,786
|
21
22
|
fractal_server/app/models/v2/task.py,sha256=Esf2j9c-0pGYjdbb__Ptpdx7NCAKVxqbQMoza524miU,1286
|
22
23
|
fractal_server/app/models/v2/workflow.py,sha256=YBgFGCziUgU0aJ5EM3Svu9W2c46AewZO9VBlFCHiSps,1069
|
23
24
|
fractal_server/app/models/v2/workflowtask.py,sha256=3jEkObsSnlI05Pur_dSsXYdJxRqPL60Z7tK5-EJLOks,1532
|
24
25
|
fractal_server/app/routes/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
25
26
|
fractal_server/app/routes/admin/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
26
|
-
fractal_server/app/routes/admin/v1.py,sha256=
|
27
|
-
fractal_server/app/routes/admin/v2.py,sha256=
|
28
|
-
fractal_server/app/routes/api/__init__.py,sha256=
|
27
|
+
fractal_server/app/routes/admin/v1.py,sha256=GIpZlwAwwwLGDWkBqywhtmp9TGsKLhGmZAdj1TDKJvE,13976
|
28
|
+
fractal_server/app/routes/admin/v2.py,sha256=P6ndmwNYfXDW5Xh971hMcmlVyVrGF8ubYS074r4bzok,13727
|
29
|
+
fractal_server/app/routes/api/__init__.py,sha256=2IDheFi0OFdsUg7nbUiyahqybvpgXqeHUXIL2QtWrQQ,641
|
29
30
|
fractal_server/app/routes/api/v1/__init__.py,sha256=Y2HQdG197J0a7DyQEE2jn53IfxD0EHGhzK1I2JZuEck,958
|
30
|
-
fractal_server/app/routes/api/v1/_aux_functions.py,sha256=
|
31
|
-
fractal_server/app/routes/api/v1/dataset.py,sha256=
|
32
|
-
fractal_server/app/routes/api/v1/job.py,sha256=
|
33
|
-
fractal_server/app/routes/api/v1/project.py,sha256=
|
34
|
-
fractal_server/app/routes/api/v1/task.py,sha256
|
35
|
-
fractal_server/app/routes/api/v1/task_collection.py,sha256=
|
36
|
-
fractal_server/app/routes/api/v1/workflow.py,sha256=
|
37
|
-
fractal_server/app/routes/api/v1/workflowtask.py,sha256=
|
31
|
+
fractal_server/app/routes/api/v1/_aux_functions.py,sha256=1YZdLch-Q1c44hQ_1ZEiijgWhLW6H3QEL5y5SHw5Ijk,13023
|
32
|
+
fractal_server/app/routes/api/v1/dataset.py,sha256=KVfKdp-bT8eB14kCjTSmpji4a2IPIHxGID8L10h3Wac,17282
|
33
|
+
fractal_server/app/routes/api/v1/job.py,sha256=0jGxvu0xNQnWuov2qnoo9yE7Oat37XbcVn4Ute-UsiE,5370
|
34
|
+
fractal_server/app/routes/api/v1/project.py,sha256=mFDqhkd_zR3wqxW5zadCCrxIX-jgL3lYF3CtfbV4pPs,16373
|
35
|
+
fractal_server/app/routes/api/v1/task.py,sha256=OLASM6M4yfHvQgHQOuR5810jR2s0_W1HQAmhGQkg0so,6356
|
36
|
+
fractal_server/app/routes/api/v1/task_collection.py,sha256=VYxhtd_idBppgJM7-FCHikI2OKMAIz05fhV_TsJpWI8,9060
|
37
|
+
fractal_server/app/routes/api/v1/workflow.py,sha256=2T93DuEnSshaDCue-JPmjuvGCtbk6lt9pFMuPt783t8,11217
|
38
|
+
fractal_server/app/routes/api/v1/workflowtask.py,sha256=OYYConwJbmNULDw5I3T-UbSJKrbbBiAHbbBeVcpoFKQ,5785
|
38
39
|
fractal_server/app/routes/api/v2/__init__.py,sha256=JrPWfKIJy9btRCP-zw2nZwLpSdBxEKY5emuCuJbqG0s,1813
|
39
|
-
fractal_server/app/routes/api/v2/_aux_functions.py,sha256=
|
40
|
-
fractal_server/app/routes/api/v2/dataset.py,sha256=
|
41
|
-
fractal_server/app/routes/api/v2/images.py,sha256=
|
42
|
-
fractal_server/app/routes/api/v2/job.py,sha256=
|
43
|
-
fractal_server/app/routes/api/v2/project.py,sha256=
|
44
|
-
fractal_server/app/routes/api/v2/status.py,sha256=
|
45
|
-
fractal_server/app/routes/api/v2/submit.py,sha256=
|
46
|
-
fractal_server/app/routes/api/v2/task.py,sha256=
|
47
|
-
fractal_server/app/routes/api/v2/task_collection.py,sha256=
|
48
|
-
fractal_server/app/routes/api/v2/task_collection_custom.py,sha256=
|
49
|
-
fractal_server/app/routes/api/v2/task_legacy.py,sha256=
|
50
|
-
fractal_server/app/routes/api/v2/workflow.py,sha256=
|
51
|
-
fractal_server/app/routes/api/v2/workflowtask.py,sha256=
|
52
|
-
fractal_server/app/routes/auth.py,sha256=
|
40
|
+
fractal_server/app/routes/api/v2/_aux_functions.py,sha256=sm__AJvEQfRYlh47uYMJ7PjSrmwz5LjjZMTcJdvhuVE,14924
|
41
|
+
fractal_server/app/routes/api/v2/dataset.py,sha256=Eilf_BAGjicIhqUiVwI86jlW45ineA5sVzxXW4b2GoQ,8329
|
42
|
+
fractal_server/app/routes/api/v2/images.py,sha256=JR1rR6qEs81nacjriOXAOBQjAbCXF4Ew7M7mkWdxBU0,7920
|
43
|
+
fractal_server/app/routes/api/v2/job.py,sha256=Bga2Kz1OjvDIdxZObWaaXVhNIhC_5JKhKRjEH2_ayEE,5157
|
44
|
+
fractal_server/app/routes/api/v2/project.py,sha256=eWYFJ7F2ZYQcpi-_n-rhPF-Q4gJhzYBsVGYFhHZZXAE,6653
|
45
|
+
fractal_server/app/routes/api/v2/status.py,sha256=6N9DSZ4iFqbZImorWfEAPoyoFUgEruo4Hweqo0x0xXU,6435
|
46
|
+
fractal_server/app/routes/api/v2/submit.py,sha256=iTGCYbxiZNszHQa8r3gmAR4QcF6QhVrb8ktzste2Ovc,8775
|
47
|
+
fractal_server/app/routes/api/v2/task.py,sha256=XgRnGBvSoI9VNJHtWZQ2Ide99f6elo7a2FN3GQkf0dU,8376
|
48
|
+
fractal_server/app/routes/api/v2/task_collection.py,sha256=wEwP8VfsxhKPZ6K3v1Bnput_Zw0Cjhlaal0-e50feIQ,12337
|
49
|
+
fractal_server/app/routes/api/v2/task_collection_custom.py,sha256=6MW-l7xTCTbWKDSYDw8e_hnm5jFCJpgFL3UdvrHAaBk,6029
|
50
|
+
fractal_server/app/routes/api/v2/task_legacy.py,sha256=GjW0lpX51b64-LCg2EtCO3Ik6Yx4eTqgbtspXh-K_4k,1744
|
51
|
+
fractal_server/app/routes/api/v2/workflow.py,sha256=8rir-alW5KjS6_HIkYFPkJcm3BouAFsKboKqGu8HSqo,11944
|
52
|
+
fractal_server/app/routes/api/v2/workflowtask.py,sha256=HoHFnVRDa0Cw1oqTea1Of6A5ZhjGJeSTDTdI-SKP7Co,8063
|
53
|
+
fractal_server/app/routes/auth/__init__.py,sha256=fao6CS0WiAjHDTvBzgBVV_bSXFpEAeDBF6Z6q7rRkPc,1658
|
54
|
+
fractal_server/app/routes/auth/_aux_auth.py,sha256=Kpgiw5q1eiCYLFkfhTT7XJGBu1d08YM71CEHhNtfJ5g,3126
|
55
|
+
fractal_server/app/routes/auth/current_user.py,sha256=LK0Z13NgaXYQ3FaQ3MNec0p2RRiKxKN31XIt2g9mcGk,2003
|
56
|
+
fractal_server/app/routes/auth/group.py,sha256=e0rVJQlocJ5RB8AEfQ5sufF4lJBmCFrGWQHvHqlpbIU,4817
|
57
|
+
fractal_server/app/routes/auth/group_names.py,sha256=zvYDfhxKlDmbSr-oLXYy6WUVkPPTvzH6ZJtuoNdGZbE,960
|
58
|
+
fractal_server/app/routes/auth/login.py,sha256=tSu6OBLOieoBtMZB4JkBAdEgH2Y8KqPGSbwy7NIypIo,566
|
59
|
+
fractal_server/app/routes/auth/oauth.py,sha256=AnFHbjqL2AgBX3eksI931xD6RTtmbciHBEuGf9YJLjU,1895
|
60
|
+
fractal_server/app/routes/auth/register.py,sha256=DlHq79iOvGd_gt2v9uwtsqIKeO6i_GKaW59VIkllPqY,587
|
61
|
+
fractal_server/app/routes/auth/router.py,sha256=zWoZWiO69U48QFQf5tLRYQDWu8PUCj7GacnaFeW1n_I,618
|
62
|
+
fractal_server/app/routes/auth/users.py,sha256=bUhoAyEgcJL5FNSn7pYYycAbmzMUiWl7NfmKaYG7mxs,6048
|
53
63
|
fractal_server/app/routes/aux/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
54
64
|
fractal_server/app/routes/aux/_job.py,sha256=q-RCiW17yXnZKAC_0La52RLvhqhxuvbgQJ2MlGXOj8A,702
|
55
65
|
fractal_server/app/routes/aux/_runner.py,sha256=FdCVla5DxGAZ__aB7Z8dEJzD_RIeh5tftjrPyqkr8N8,895
|
@@ -116,7 +126,8 @@ fractal_server/app/runner/v2/v1_compat.py,sha256=t0ficzAHUFaaeI56nqTb4YEKxfARF7L
|
|
116
126
|
fractal_server/app/runner/versions.py,sha256=dSaPRWqmFPHjg20kTCHmi_dmGNcCETflDtDLronNanU,852
|
117
127
|
fractal_server/app/schemas/__init__.py,sha256=jiIf54owztXupv3PO6Ilh0qcrkh2RUzKq4bcEFqEfc4,40
|
118
128
|
fractal_server/app/schemas/_validators.py,sha256=1dTOYr1IZykrxuQSV2-zuEMZbKe_nGwrfS7iUrsh-sE,3461
|
119
|
-
fractal_server/app/schemas/user.py,sha256=
|
129
|
+
fractal_server/app/schemas/user.py,sha256=__WVnUyQiWJ64JzlzyKowe2w2sBlF4S95RqdaUdA21c,3325
|
130
|
+
fractal_server/app/schemas/user_group.py,sha256=CgW38Ett-DuRvN4tFEjG1jfX1csCFJIhVu5mjVlGEyI,1262
|
120
131
|
fractal_server/app/schemas/v1/__init__.py,sha256=CrBGgBhoemCvmZ70ZUchM-jfVAICnoa7AjZBAtL2UB0,1852
|
121
132
|
fractal_server/app/schemas/v1/applyworkflow.py,sha256=uuIh7fHlHEL4yLqL-dePI6-nfCsqgBYATmht7w_KITw,4302
|
122
133
|
fractal_server/app/schemas/v1/dataset.py,sha256=n71lNUO3JLy2K3IM9BZM2Fk1EnKQOTU7pm2s2rJ1FGY,3444
|
@@ -138,18 +149,20 @@ fractal_server/app/schemas/v2/task.py,sha256=7IfxiZkaVqlARy7WYE_H8m7j_IEcuQaZORU
|
|
138
149
|
fractal_server/app/schemas/v2/task_collection.py,sha256=8PG1bOqkfQqORMN0brWf6mHDmijt0bBW-mZsF7cSxUs,6129
|
139
150
|
fractal_server/app/schemas/v2/workflow.py,sha256=Zzx3e-qgkH8le0FUmAx9UrV5PWd7bj14PPXUh_zgZXM,1827
|
140
151
|
fractal_server/app/schemas/v2/workflowtask.py,sha256=atVuVN4aXsVEOmSd-vyg-8_8OnPmqx-gT75rXcn_AlQ,6552
|
141
|
-
fractal_server/app/security/__init__.py,sha256=
|
152
|
+
fractal_server/app/security/__init__.py,sha256=FBxdrMvn2s3Gdmp1orqOpYji87JojLBzr9TMfblj1SI,11441
|
142
153
|
fractal_server/config.py,sha256=R0VezSe2PEDjQjHEX2V29A1jMdoomdyECBjWNY15v_0,25049
|
154
|
+
fractal_server/data_migrations/2_4_0.py,sha256=T1HRRWp9ZuXeVfBY6NRGxQ8aNIHVSftOMnB-CMrfvi8,2117
|
143
155
|
fractal_server/data_migrations/README.md,sha256=_3AEFvDg9YkybDqCLlFPdDmGJvr6Tw7HRI14aZ3LOIw,398
|
144
156
|
fractal_server/gunicorn_fractal.py,sha256=u6U01TLGlXgq1v8QmEpLih3QnsInZD7CqphgJ_GrGzc,1230
|
145
157
|
fractal_server/images/__init__.py,sha256=xO6jTLE4EZKO6cTDdJsBmK9cdeh9hFTaSbSuWgQg7y4,196
|
146
158
|
fractal_server/images/models.py,sha256=9ipU5h4N6ogBChoB-2vHoqtL0TXOHCv6kRR-fER3mkM,4167
|
147
159
|
fractal_server/images/tools.py,sha256=gxeniYy4Z-cp_ToK2LHPJUTVVUUrdpogYdcBUvBuLiY,2209
|
148
160
|
fractal_server/logger.py,sha256=56wfka6fHaa3Rx5qO009nEs_y8gx5wZ2NUNZZ1I-uvc,5130
|
149
|
-
fractal_server/main.py,sha256=
|
161
|
+
fractal_server/main.py,sha256=NUvMd8C8kosulAcQ8pCFLnOGdLw7j-6RzcHxoNvSB7k,5003
|
150
162
|
fractal_server/migrations/README,sha256=4rQvyDfqodGhpJw74VYijRmgFP49ji5chyEemWGHsuw,59
|
151
163
|
fractal_server/migrations/env.py,sha256=Bvg-FJzRJZIH_wqS_ZyZNXANIaathjo22_IY7c3fCjo,2636
|
152
164
|
fractal_server/migrations/script.py.mako,sha256=oMXw9LC3zRbinWWPPDgeZ4z9FJrV2zhRWiYdS5YgNbI,526
|
165
|
+
fractal_server/migrations/versions/091b01f51f88_add_usergroup_and_linkusergroup_table.py,sha256=BtcSkXsY7ZHNmwV93bSTiDw-wuxpfL7xpbZ5zH-nLnA,1456
|
153
166
|
fractal_server/migrations/versions/4c308bcaea2b_add_task_args_schema_and_task_args_.py,sha256=-wHe-fOffmYeAm0JXVl_lxZ7hhDkaEVqxgxpHkb_uL8,954
|
154
167
|
fractal_server/migrations/versions/4cedeb448a53_workflowtask_foreign_keys_not_nullables.py,sha256=Mob8McGYAcmgvrseyyYOa54E6Gsgr-4SiGdC-r9O4_A,1157
|
155
168
|
fractal_server/migrations/versions/50a13d6138fd_initial_schema.py,sha256=zwXegXs9J40eyCWi3w0c_iIBVJjXNn4VdVnQaT3KxDg,8770
|
@@ -194,8 +207,8 @@ fractal_server/tasks/v2/utils.py,sha256=JOyCacb6MNvrwfLNTyLwcz8y79J29YuJeJ2MK5kq
|
|
194
207
|
fractal_server/urls.py,sha256=5o_qq7PzKKbwq12NHSQZDmDitn5RAOeQ4xufu-2v9Zk,448
|
195
208
|
fractal_server/utils.py,sha256=b7WwFdcFZ8unyT65mloFToYuEDXpQoHRcmRNqrhd_dQ,2115
|
196
209
|
fractal_server/zip_tools.py,sha256=xYpzBshysD2nmxkD5WLYqMzPYUcCRM3kYy-7n9bJL-U,4426
|
197
|
-
fractal_server-2.
|
198
|
-
fractal_server-2.
|
199
|
-
fractal_server-2.
|
200
|
-
fractal_server-2.
|
201
|
-
fractal_server-2.
|
210
|
+
fractal_server-2.4.0a1.dist-info/LICENSE,sha256=QKAharUuhxL58kSoLizKJeZE3mTCBnX6ucmz8W0lxlk,1576
|
211
|
+
fractal_server-2.4.0a1.dist-info/METADATA,sha256=npvr_yl8n-KwghMVxD6kUx3yHf2wB_xTnFUFrtf7w7Q,4630
|
212
|
+
fractal_server-2.4.0a1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
213
|
+
fractal_server-2.4.0a1.dist-info/entry_points.txt,sha256=8tV2kynvFkjnhbtDnxAqImL6HMVKsopgGfew0DOp5UY,58
|
214
|
+
fractal_server-2.4.0a1.dist-info/RECORD,,
|
@@ -1,165 +0,0 @@
|
|
1
|
-
"""
|
2
|
-
Definition of `/auth` routes.
|
3
|
-
"""
|
4
|
-
from fastapi import APIRouter
|
5
|
-
from fastapi import Depends
|
6
|
-
from fastapi import HTTPException
|
7
|
-
from fastapi import status
|
8
|
-
from fastapi_users import exceptions
|
9
|
-
from fastapi_users import schemas
|
10
|
-
from fastapi_users.router.common import ErrorCode
|
11
|
-
from sqlalchemy.ext.asyncio import AsyncSession
|
12
|
-
from sqlmodel import select
|
13
|
-
|
14
|
-
from ...config import get_settings
|
15
|
-
from ...syringe import Inject
|
16
|
-
from ..db import get_async_db
|
17
|
-
from ..models.security import UserOAuth as User
|
18
|
-
from ..schemas.user import UserCreate
|
19
|
-
from ..schemas.user import UserRead
|
20
|
-
from ..schemas.user import UserUpdate
|
21
|
-
from ..schemas.user import UserUpdateStrict
|
22
|
-
from ..security import cookie_backend
|
23
|
-
from ..security import current_active_superuser
|
24
|
-
from ..security import current_active_user
|
25
|
-
from ..security import fastapi_users
|
26
|
-
from ..security import get_user_manager
|
27
|
-
from ..security import token_backend
|
28
|
-
from ..security import UserManager
|
29
|
-
|
30
|
-
router_auth = APIRouter()
|
31
|
-
|
32
|
-
router_auth.include_router(
|
33
|
-
fastapi_users.get_auth_router(token_backend),
|
34
|
-
prefix="/token",
|
35
|
-
)
|
36
|
-
router_auth.include_router(
|
37
|
-
fastapi_users.get_auth_router(cookie_backend),
|
38
|
-
)
|
39
|
-
router_auth.include_router(
|
40
|
-
fastapi_users.get_register_router(UserRead, UserCreate),
|
41
|
-
dependencies=[Depends(current_active_superuser)],
|
42
|
-
)
|
43
|
-
|
44
|
-
users_router = fastapi_users.get_users_router(UserRead, UserUpdate)
|
45
|
-
|
46
|
-
# We remove `/auth/users/me` endpoints to implement our own
|
47
|
-
# at `/auth/current-user/`.
|
48
|
-
# We also remove `DELETE /auth/users/{user_id}`
|
49
|
-
# (ref https://github.com/fastapi-users/fastapi-users/discussions/606)
|
50
|
-
users_router.routes = [
|
51
|
-
route
|
52
|
-
for route in users_router.routes
|
53
|
-
if route.name
|
54
|
-
not in [
|
55
|
-
"users:current_user",
|
56
|
-
"users:delete_user",
|
57
|
-
"users:patch_current_user",
|
58
|
-
]
|
59
|
-
]
|
60
|
-
router_auth.include_router(
|
61
|
-
users_router,
|
62
|
-
prefix="/users",
|
63
|
-
dependencies=[Depends(current_active_superuser)],
|
64
|
-
)
|
65
|
-
|
66
|
-
|
67
|
-
@router_auth.patch("/current-user/", response_model=UserRead)
|
68
|
-
async def patch_current_user(
|
69
|
-
user_update: UserUpdateStrict,
|
70
|
-
current_user: User = Depends(current_active_user),
|
71
|
-
user_manager: UserManager = Depends(get_user_manager),
|
72
|
-
):
|
73
|
-
|
74
|
-
update = UserUpdate(**user_update.dict(exclude_unset=True))
|
75
|
-
|
76
|
-
try:
|
77
|
-
user = await user_manager.update(update, current_user, safe=True)
|
78
|
-
except exceptions.InvalidPasswordException as e:
|
79
|
-
raise HTTPException(
|
80
|
-
status_code=status.HTTP_400_BAD_REQUEST,
|
81
|
-
detail={
|
82
|
-
"code": ErrorCode.UPDATE_USER_INVALID_PASSWORD,
|
83
|
-
"reason": e.reason,
|
84
|
-
},
|
85
|
-
)
|
86
|
-
return schemas.model_validate(User, user)
|
87
|
-
|
88
|
-
|
89
|
-
@router_auth.get("/current-user/", response_model=UserRead)
|
90
|
-
async def get_current_user(user: User = Depends(current_active_user)):
|
91
|
-
"""
|
92
|
-
Return current user
|
93
|
-
"""
|
94
|
-
return user
|
95
|
-
|
96
|
-
|
97
|
-
@router_auth.get("/users/", response_model=list[UserRead])
|
98
|
-
async def list_users(
|
99
|
-
user: User = Depends(current_active_superuser),
|
100
|
-
db: AsyncSession = Depends(get_async_db),
|
101
|
-
):
|
102
|
-
"""
|
103
|
-
Return list of all users
|
104
|
-
"""
|
105
|
-
stm = select(User)
|
106
|
-
res = await db.execute(stm)
|
107
|
-
user_list = res.scalars().unique().all()
|
108
|
-
await db.close()
|
109
|
-
return user_list
|
110
|
-
|
111
|
-
|
112
|
-
# OAUTH CLIENTS
|
113
|
-
|
114
|
-
# NOTE: settings.OAUTH_CLIENTS are collected by
|
115
|
-
# Settings.collect_oauth_clients(). If no specific client is specified in the
|
116
|
-
# environment variables (e.g. by setting OAUTH_FOO_CLIENT_ID and
|
117
|
-
# OAUTH_FOO_CLIENT_SECRET), this list is empty
|
118
|
-
|
119
|
-
# FIXME:Dependency injection should be wrapped within a function call to make
|
120
|
-
# it truly lazy. This function could then be called on startup of the FastAPI
|
121
|
-
# app (cf. fractal_server.main)
|
122
|
-
settings = Inject(get_settings)
|
123
|
-
|
124
|
-
for client_config in settings.OAUTH_CLIENTS_CONFIG:
|
125
|
-
|
126
|
-
client_name = client_config.CLIENT_NAME.lower()
|
127
|
-
|
128
|
-
if client_name == "google":
|
129
|
-
from httpx_oauth.clients.google import GoogleOAuth2
|
130
|
-
|
131
|
-
client = GoogleOAuth2(
|
132
|
-
client_config.CLIENT_ID, client_config.CLIENT_SECRET
|
133
|
-
)
|
134
|
-
elif client_name == "github":
|
135
|
-
from httpx_oauth.clients.github import GitHubOAuth2
|
136
|
-
|
137
|
-
client = GitHubOAuth2(
|
138
|
-
client_config.CLIENT_ID, client_config.CLIENT_SECRET
|
139
|
-
)
|
140
|
-
else:
|
141
|
-
from httpx_oauth.clients.openid import OpenID
|
142
|
-
|
143
|
-
client = OpenID(
|
144
|
-
client_config.CLIENT_ID,
|
145
|
-
client_config.CLIENT_SECRET,
|
146
|
-
client_config.OIDC_CONFIGURATION_ENDPOINT,
|
147
|
-
)
|
148
|
-
|
149
|
-
router_auth.include_router(
|
150
|
-
fastapi_users.get_oauth_router(
|
151
|
-
client,
|
152
|
-
cookie_backend,
|
153
|
-
settings.JWT_SECRET_KEY,
|
154
|
-
is_verified_by_default=False,
|
155
|
-
associate_by_email=True,
|
156
|
-
redirect_url=client_config.REDIRECT_URL,
|
157
|
-
),
|
158
|
-
prefix=f"/{client_name}",
|
159
|
-
)
|
160
|
-
|
161
|
-
|
162
|
-
# Add trailing slash to all routes' paths
|
163
|
-
for route in router_auth.routes:
|
164
|
-
if not route.path.endswith("/"):
|
165
|
-
route.path = f"{route.path}/"
|
File without changes
|
File without changes
|
File without changes
|