cardo-python-utils 0.5.dev14__tar.gz → 0.5.dev15__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.
- {cardo_python_utils-0.5.dev14/cardo_python_utils.egg-info → cardo_python_utils-0.5.dev15}/PKG-INFO +1 -1
- {cardo_python_utils-0.5.dev14 → cardo_python_utils-0.5.dev15/cardo_python_utils.egg-info}/PKG-INFO +1 -1
- {cardo_python_utils-0.5.dev14 → cardo_python_utils-0.5.dev15}/pyproject.toml +1 -1
- {cardo_python_utils-0.5.dev14 → cardo_python_utils-0.5.dev15}/python_utils/django/keycloak/api/drf.py +15 -1
- {cardo_python_utils-0.5.dev14 → cardo_python_utils-0.5.dev15}/LICENSE +0 -0
- {cardo_python_utils-0.5.dev14 → cardo_python_utils-0.5.dev15}/MANIFEST.in +0 -0
- {cardo_python_utils-0.5.dev14 → cardo_python_utils-0.5.dev15}/README.rst +0 -0
- {cardo_python_utils-0.5.dev14 → cardo_python_utils-0.5.dev15}/cardo_python_utils.egg-info/SOURCES.txt +0 -0
- {cardo_python_utils-0.5.dev14 → cardo_python_utils-0.5.dev15}/cardo_python_utils.egg-info/dependency_links.txt +0 -0
- {cardo_python_utils-0.5.dev14 → cardo_python_utils-0.5.dev15}/cardo_python_utils.egg-info/requires.txt +0 -0
- {cardo_python_utils-0.5.dev14 → cardo_python_utils-0.5.dev15}/cardo_python_utils.egg-info/top_level.txt +0 -0
- {cardo_python_utils-0.5.dev14 → cardo_python_utils-0.5.dev15}/python_utils/__init__.py +0 -0
- {cardo_python_utils-0.5.dev14 → cardo_python_utils-0.5.dev15}/python_utils/choices.py +0 -0
- {cardo_python_utils-0.5.dev14 → cardo_python_utils-0.5.dev15}/python_utils/data_structures.py +0 -0
- {cardo_python_utils-0.5.dev14 → cardo_python_utils-0.5.dev15}/python_utils/db.py +0 -0
- {cardo_python_utils-0.5.dev14 → cardo_python_utils-0.5.dev15}/python_utils/django/keycloak/__init__.py +0 -0
- {cardo_python_utils-0.5.dev14 → cardo_python_utils-0.5.dev15}/python_utils/django/keycloak/admin/__init__.py +0 -0
- {cardo_python_utils-0.5.dev14 → cardo_python_utils-0.5.dev15}/python_utils/django/keycloak/admin/auth.py +0 -0
- {cardo_python_utils-0.5.dev14 → cardo_python_utils-0.5.dev15}/python_utils/django/keycloak/admin/user_group.py +0 -0
- {cardo_python_utils-0.5.dev14 → cardo_python_utils-0.5.dev15}/python_utils/django/keycloak/admin/user_groups_changelist.html +0 -0
- {cardo_python_utils-0.5.dev14 → cardo_python_utils-0.5.dev15}/python_utils/django/keycloak/api/__init__.py +0 -0
- {cardo_python_utils-0.5.dev14 → cardo_python_utils-0.5.dev15}/python_utils/django/keycloak/api/ninja.py +0 -0
- {cardo_python_utils-0.5.dev14 → cardo_python_utils-0.5.dev15}/python_utils/django/keycloak/api/utils.py +0 -0
- {cardo_python_utils-0.5.dev14 → cardo_python_utils-0.5.dev15}/python_utils/django/keycloak/models/__init__.py +0 -0
- {cardo_python_utils-0.5.dev14 → cardo_python_utils-0.5.dev15}/python_utils/django/keycloak/models/user_group.py +0 -0
- {cardo_python_utils-0.5.dev14 → cardo_python_utils-0.5.dev15}/python_utils/django/keycloak/service.py +0 -0
- {cardo_python_utils-0.5.dev14 → cardo_python_utils-0.5.dev15}/python_utils/django/utils.py +0 -0
- {cardo_python_utils-0.5.dev14 → cardo_python_utils-0.5.dev15}/python_utils/esma_choices.py +0 -0
- {cardo_python_utils-0.5.dev14 → cardo_python_utils-0.5.dev15}/python_utils/exceptions.py +0 -0
- {cardo_python_utils-0.5.dev14 → cardo_python_utils-0.5.dev15}/python_utils/imports.py +0 -0
- {cardo_python_utils-0.5.dev14 → cardo_python_utils-0.5.dev15}/python_utils/math.py +0 -0
- {cardo_python_utils-0.5.dev14 → cardo_python_utils-0.5.dev15}/python_utils/text.py +0 -0
- {cardo_python_utils-0.5.dev14 → cardo_python_utils-0.5.dev15}/python_utils/time.py +0 -0
- {cardo_python_utils-0.5.dev14 → cardo_python_utils-0.5.dev15}/python_utils/types_hinting.py +0 -0
- {cardo_python_utils-0.5.dev14 → cardo_python_utils-0.5.dev15}/setup.cfg +0 -0
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "cardo-python-utils"
|
|
7
|
-
version = "0.5.
|
|
7
|
+
version = "0.5.dev15"
|
|
8
8
|
description = "Python library enhanced with a wide range of functions for different scenarios."
|
|
9
9
|
readme = "README.rst"
|
|
10
10
|
requires-python = ">=3.8"
|
|
@@ -42,18 +42,32 @@ class HasScope(BasePermission):
|
|
|
42
42
|
allowed_scopes = ["jobs"]
|
|
43
43
|
...
|
|
44
44
|
|
|
45
|
+
It is possible to define different scopes per HTTP method
|
|
46
|
+
by setting `allowed_scopes` as a dict:
|
|
47
|
+
|
|
48
|
+
class MyApiView(APIView):
|
|
49
|
+
permission_classes = [IsAuthenticated, HasScope]
|
|
50
|
+
allowed_scopes = {
|
|
51
|
+
"get": ["jobs"],
|
|
52
|
+
"post": ["jobs_admin"],
|
|
53
|
+
}
|
|
54
|
+
...
|
|
55
|
+
|
|
45
56
|
If no particular scope is required, you can set `allowed_scopes = "*"`
|
|
46
57
|
to allow access without scope checks.
|
|
47
58
|
"""
|
|
48
59
|
|
|
49
60
|
def has_permission(self, request, view):
|
|
50
|
-
allowed_scopes = getattr(view, "allowed_scopes",
|
|
61
|
+
allowed_scopes = getattr(view, "allowed_scopes", None)
|
|
51
62
|
|
|
52
63
|
if not allowed_scopes:
|
|
53
64
|
raise Exception(
|
|
54
65
|
f"No allowed_scopes defined on the view '{view.__class__.__name__}'. "
|
|
55
66
|
"Define allowed_scopes or set it to '*' to allow any scope."
|
|
56
67
|
)
|
|
68
|
+
|
|
69
|
+
if isinstance(allowed_scopes, dict):
|
|
70
|
+
allowed_scopes = allowed_scopes.get(request.method.lower(), [])
|
|
57
71
|
|
|
58
72
|
if allowed_scopes == "*":
|
|
59
73
|
return True
|
|
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
|
{cardo_python_utils-0.5.dev14 → cardo_python_utils-0.5.dev15}/python_utils/data_structures.py
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|