python3-commons 0.7.2__py3-none-any.whl → 0.7.3__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.
- python3_commons/permissions.py +20 -1
- {python3_commons-0.7.2.dist-info → python3_commons-0.7.3.dist-info}/METADATA +1 -1
- {python3_commons-0.7.2.dist-info → python3_commons-0.7.3.dist-info}/RECORD +7 -7
- {python3_commons-0.7.2.dist-info → python3_commons-0.7.3.dist-info}/AUTHORS.rst +0 -0
- {python3_commons-0.7.2.dist-info → python3_commons-0.7.3.dist-info}/LICENSE +0 -0
- {python3_commons-0.7.2.dist-info → python3_commons-0.7.3.dist-info}/WHEEL +0 -0
- {python3_commons-0.7.2.dist-info → python3_commons-0.7.3.dist-info}/top_level.txt +0 -0
python3_commons/permissions.py
CHANGED
@@ -5,7 +5,7 @@ import sqlalchemy as sa
|
|
5
5
|
from sqlalchemy import func, exists, and_
|
6
6
|
from sqlalchemy.ext.asyncio import AsyncSession
|
7
7
|
|
8
|
-
from python3_commons.db.models import RBACPermission, RBACApiKeyRole, RBACRolePermission
|
8
|
+
from python3_commons.db.models import RBACPermission, RBACApiKeyRole, RBACRolePermission, RBACUserRole
|
9
9
|
|
10
10
|
logger = logging.getLogger(__name__)
|
11
11
|
|
@@ -27,3 +27,22 @@ async def has_api_key_permission(session: AsyncSession, api_key_uid: UUID, permi
|
|
27
27
|
result = cursor.scalar()
|
28
28
|
|
29
29
|
return result
|
30
|
+
|
31
|
+
|
32
|
+
async def has_user_permission(session: AsyncSession, user_id: UUID, permission: str) -> bool:
|
33
|
+
query = sa.select(
|
34
|
+
exists().where(
|
35
|
+
and_(
|
36
|
+
RBACUserRole.user_id == user_id,
|
37
|
+
(RBACUserRole.expires_at.is_(None) | (RBACUserRole.expires_at > func.now())),
|
38
|
+
RBACUserRole.role_uid == RBACRolePermission.role_uid,
|
39
|
+
RBACRolePermission.permission_uid == RBACPermission.uid,
|
40
|
+
RBACPermission.name == permission
|
41
|
+
)
|
42
|
+
)
|
43
|
+
)
|
44
|
+
|
45
|
+
cursor = await session.execute(query)
|
46
|
+
result = cursor.scalar()
|
47
|
+
|
48
|
+
return result
|
@@ -5,7 +5,7 @@ python3_commons/conf.py,sha256=GAcjlFlloLriZXa9JmNGMtTPzvtHUActYDiE4C1DacU,749
|
|
5
5
|
python3_commons/fs.py,sha256=wfLjybXndwLqNlOxTpm_HRJnuTcC4wbrHEOaEeCo9Wc,337
|
6
6
|
python3_commons/helpers.py,sha256=OmuCF7UeJ6oe-rH1Y4ZYVW_uPQ973lCLsikj01wmNqs,3101
|
7
7
|
python3_commons/object_storage.py,sha256=Bte49twIJ4l6VAzIqK6tLx7DFYwijErUmmhWkrZpSJE,4074
|
8
|
-
python3_commons/permissions.py,sha256=
|
8
|
+
python3_commons/permissions.py,sha256=V6kT7gBQ0fZRDQwreM9es90BvvpB3gUofuqnFvx2g-o,1553
|
9
9
|
python3_commons/db/__init__.py,sha256=pZk0Fv-Le2sFC-KaVDdJjDDsHtmv-IJz_aFP5o2PGHA,1682
|
10
10
|
python3_commons/db/helpers.py,sha256=6xYgDgMhWUpVbtD3FctYtHVBRNahCkkpVIxx0matt-c,1644
|
11
11
|
python3_commons/db/models/__init__.py,sha256=AeeTLUqdqQrhCTi14ACWO0ccyVyWFppZVtCeWShSvR0,193
|
@@ -19,9 +19,9 @@ python3_commons/serializers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMp
|
|
19
19
|
python3_commons/serializers/json.py,sha256=P288wWz9ic38QWEMrpp_uwKPYkQiOgvE1cI4WZn6ZCg,808
|
20
20
|
python3_commons/serializers/msgpack.py,sha256=tzIGGyDL3UpZnnouCtnxuYDx6InKM_C3PP1N4PN8wd4,1269
|
21
21
|
python3_commons/serializers/msgspec.py,sha256=FuZVqOLJb0-lEKrs7dtjhwEbHIpfMUk5yu1hD64zRdc,2038
|
22
|
-
python3_commons-0.7.
|
23
|
-
python3_commons-0.7.
|
24
|
-
python3_commons-0.7.
|
25
|
-
python3_commons-0.7.
|
26
|
-
python3_commons-0.7.
|
27
|
-
python3_commons-0.7.
|
22
|
+
python3_commons-0.7.3.dist-info/AUTHORS.rst,sha256=3R9JnfjfjH5RoPWOeqKFJgxVShSSfzQPIrEr1nxIo9Q,90
|
23
|
+
python3_commons-0.7.3.dist-info/LICENSE,sha256=xxILuojHm4fKQOrMHPSslbyy6WuKAN2RiG74HbrYfzM,34575
|
24
|
+
python3_commons-0.7.3.dist-info/METADATA,sha256=BHkOJZ0EOpbr70t8FHam9oYGIqR95y33SMpbvl_xygU,1127
|
25
|
+
python3_commons-0.7.3.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
|
26
|
+
python3_commons-0.7.3.dist-info/top_level.txt,sha256=lJI6sCBf68eUHzupCnn2dzG10lH3jJKTWM_hrN1cQ7M,16
|
27
|
+
python3_commons-0.7.3.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|