open-api-framework 0.8.0__tar.gz → 0.9.0__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.
- {open_api_framework-0.8.0 → open_api_framework-0.9.0}/CHANGELOG.rst +24 -0
- {open_api_framework-0.8.0/open_api_framework.egg-info → open_api_framework-0.9.0}/PKG-INFO +5 -3
- {open_api_framework-0.8.0 → open_api_framework-0.9.0}/README.rst +1 -1
- open_api_framework-0.9.0/open_api_framework/admin.py +40 -0
- {open_api_framework-0.8.0 → open_api_framework-0.9.0}/open_api_framework/conf/base.py +36 -23
- open_api_framework-0.9.0/open_api_framework/utils.py +8 -0
- {open_api_framework-0.8.0 → open_api_framework-0.9.0/open_api_framework.egg-info}/PKG-INFO +5 -3
- {open_api_framework-0.8.0 → open_api_framework-0.9.0}/open_api_framework.egg-info/SOURCES.txt +3 -0
- {open_api_framework-0.8.0 → open_api_framework-0.9.0}/open_api_framework.egg-info/requires.txt +3 -1
- {open_api_framework-0.8.0 → open_api_framework-0.9.0}/pyproject.toml +5 -3
- open_api_framework-0.9.0/tests/test_admin.py +197 -0
- {open_api_framework-0.8.0 → open_api_framework-0.9.0}/LICENSE +0 -0
- {open_api_framework-0.8.0 → open_api_framework-0.9.0}/MANIFEST.in +0 -0
- {open_api_framework-0.8.0 → open_api_framework-0.9.0}/open_api_framework/__init__.py +0 -0
- {open_api_framework-0.8.0 → open_api_framework-0.9.0}/open_api_framework/apps.py +0 -0
- {open_api_framework-0.8.0 → open_api_framework-0.9.0}/open_api_framework/conf/__init__.py +0 -0
- {open_api_framework-0.8.0 → open_api_framework-0.9.0}/open_api_framework/conf/utils.py +0 -0
- {open_api_framework-0.8.0 → open_api_framework-0.9.0}/open_api_framework/context_processors.py +0 -0
- {open_api_framework-0.8.0 → open_api_framework-0.9.0}/open_api_framework/management/__init__.py +0 -0
- {open_api_framework-0.8.0 → open_api_framework-0.9.0}/open_api_framework/management/commands/__init__.py +0 -0
- {open_api_framework-0.8.0 → open_api_framework-0.9.0}/open_api_framework/management/commands/generate_envvar_docs.py +0 -0
- {open_api_framework-0.8.0 → open_api_framework-0.9.0}/open_api_framework/py.typed +0 -0
- {open_api_framework-0.8.0 → open_api_framework-0.9.0}/open_api_framework/static/open_api_framework/css/admin.css +0 -0
- {open_api_framework-0.8.0 → open_api_framework-0.9.0}/open_api_framework/templates/open_api_framework/admin/base_site.html +0 -0
- {open_api_framework-0.8.0 → open_api_framework-0.9.0}/open_api_framework/templates/open_api_framework/components/environment.html +0 -0
- {open_api_framework-0.8.0 → open_api_framework-0.9.0}/open_api_framework/templates/open_api_framework/components/version.html +0 -0
- {open_api_framework-0.8.0 → open_api_framework-0.9.0}/open_api_framework/templates/open_api_framework/env_config.rst +0 -0
- {open_api_framework-0.8.0 → open_api_framework-0.9.0}/open_api_framework/templatetags/__init__.py +0 -0
- {open_api_framework-0.8.0 → open_api_framework-0.9.0}/open_api_framework/templatetags/doc_tags.py +0 -0
- {open_api_framework-0.8.0 → open_api_framework-0.9.0}/open_api_framework/templatetags/open_api_framework.py +0 -0
- {open_api_framework-0.8.0 → open_api_framework-0.9.0}/open_api_framework.egg-info/dependency_links.txt +0 -0
- {open_api_framework-0.8.0 → open_api_framework-0.9.0}/open_api_framework.egg-info/top_level.txt +0 -0
- {open_api_framework-0.8.0 → open_api_framework-0.9.0}/setup.cfg +0 -0
- {open_api_framework-0.8.0 → open_api_framework-0.9.0}/tests/test_config_helpers.py +0 -0
- {open_api_framework-0.8.0 → open_api_framework-0.9.0}/tests/test_generate_envvar_docs.py +0 -0
|
@@ -1,6 +1,30 @@
|
|
|
1
1
|
Changelog
|
|
2
2
|
=========
|
|
3
3
|
|
|
4
|
+
0.9.0 (2024-11-11)
|
|
5
|
+
------------------
|
|
6
|
+
**New Features**
|
|
7
|
+
|
|
8
|
+
* Add ``SESSION_COOKIE_AGE`` configurable setting
|
|
9
|
+
* Add user session management admin
|
|
10
|
+
|
|
11
|
+
.. note::
|
|
12
|
+
|
|
13
|
+
SessionProfile admin should be added to admin index and its fixture.
|
|
14
|
+
|
|
15
|
+
**Bugfixes/QOL**
|
|
16
|
+
|
|
17
|
+
* fix runtime configuration for django-log-outgoing-requests
|
|
18
|
+
|
|
19
|
+
0.8.1 (2024-09-26)
|
|
20
|
+
------------------
|
|
21
|
+
|
|
22
|
+
**Bugfixes/QOL**
|
|
23
|
+
|
|
24
|
+
* Change SESSION_COOKIE_SAMESITE to "Lax" to fix OIDC (#72)
|
|
25
|
+
* Remove url from SECRET_KEY help text (#76)
|
|
26
|
+
* Change CSP headers to support API schema page
|
|
27
|
+
|
|
4
28
|
0.8.0 (2024-08-22)
|
|
5
29
|
------------------
|
|
6
30
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: open_api_framework
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.9.0
|
|
4
4
|
Summary: A metapackage for registration components, that bundles the dependencies shared between these components and provides generic settings
|
|
5
5
|
Author-email: Maykin Media <support@maykinmedia.nl>
|
|
6
6
|
License: Copyright © Maykin 2024
|
|
@@ -41,7 +41,7 @@ Requires-Dist: django-redis>=5.4.0
|
|
|
41
41
|
Requires-Dist: djangorestframework>=3.15.2
|
|
42
42
|
Requires-Dist: djangorestframework-gis>=1.0
|
|
43
43
|
Requires-Dist: django-filter>=24.2
|
|
44
|
-
Requires-Dist: drf-spectacular>=0.27.2
|
|
44
|
+
Requires-Dist: drf-spectacular[sidecar]>=0.27.2
|
|
45
45
|
Requires-Dist: django-csp>=3.8
|
|
46
46
|
Requires-Dist: djangorestframework-inclusions>=1.2.0
|
|
47
47
|
Requires-Dist: commonground-api-common>=1.12.1
|
|
@@ -59,6 +59,7 @@ Requires-Dist: celery>=5.4.0
|
|
|
59
59
|
Requires-Dist: flower>=2.0.1
|
|
60
60
|
Requires-Dist: maykin-2fa>=1.0.1
|
|
61
61
|
Requires-Dist: django-setup-configuration>=0.1.0
|
|
62
|
+
Requires-Dist: django-sessionprofile>=3.0.0
|
|
62
63
|
Provides-Extra: tests
|
|
63
64
|
Requires-Dist: pytest; extra == "tests"
|
|
64
65
|
Requires-Dist: pytest-django; extra == "tests"
|
|
@@ -66,6 +67,7 @@ Requires-Dist: tox; extra == "tests"
|
|
|
66
67
|
Requires-Dist: isort; extra == "tests"
|
|
67
68
|
Requires-Dist: black; extra == "tests"
|
|
68
69
|
Requires-Dist: flake8; extra == "tests"
|
|
70
|
+
Requires-Dist: factory-boy; extra == "tests"
|
|
69
71
|
Provides-Extra: coverage
|
|
70
72
|
Requires-Dist: pytest-cov; extra == "coverage"
|
|
71
73
|
Provides-Extra: docs
|
|
@@ -78,7 +80,7 @@ Requires-Dist: twine; extra == "release"
|
|
|
78
80
|
Open API Framework
|
|
79
81
|
==================
|
|
80
82
|
|
|
81
|
-
:Version: 0.
|
|
83
|
+
:Version: 0.9.0
|
|
82
84
|
:Source: https://github.com/maykinmedia/open-api-framework
|
|
83
85
|
:Keywords: metapackage, dependencies
|
|
84
86
|
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
from django.contrib import admin
|
|
2
|
+
|
|
3
|
+
from sessionprofile.models import SessionProfile
|
|
4
|
+
|
|
5
|
+
from open_api_framework.utils import get_session_store
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@admin.register(SessionProfile)
|
|
9
|
+
class SessionProfileAdmin(admin.ModelAdmin):
|
|
10
|
+
list_display = ["session_key", "user", "exists"]
|
|
11
|
+
|
|
12
|
+
@property
|
|
13
|
+
def SessionStore(self):
|
|
14
|
+
|
|
15
|
+
return get_session_store()
|
|
16
|
+
|
|
17
|
+
def get_queryset(self, request):
|
|
18
|
+
qs = super().get_queryset(request)
|
|
19
|
+
return qs.filter(user=request.user)
|
|
20
|
+
|
|
21
|
+
def has_add_permission(self, request, obj=None):
|
|
22
|
+
return False
|
|
23
|
+
|
|
24
|
+
def has_change_permission(self, request, obj=None):
|
|
25
|
+
return False
|
|
26
|
+
|
|
27
|
+
@admin.display(boolean=True)
|
|
28
|
+
def exists(self, obj):
|
|
29
|
+
return self.SessionStore().exists(obj.session_key)
|
|
30
|
+
|
|
31
|
+
def delete_model(self, request, obj):
|
|
32
|
+
self.SessionStore(obj.session_key).flush()
|
|
33
|
+
super().delete_model(request, obj)
|
|
34
|
+
|
|
35
|
+
def delete_queryset(self, request, queryset):
|
|
36
|
+
|
|
37
|
+
for session_profile in queryset.iterator():
|
|
38
|
+
self.SessionStore(session_profile.session_key).flush()
|
|
39
|
+
|
|
40
|
+
super().delete_queryset(request, queryset)
|
|
@@ -39,10 +39,7 @@ SITE_ID = config(
|
|
|
39
39
|
# SECURITY WARNING: keep the secret key used in production secret!
|
|
40
40
|
SECRET_KEY = config(
|
|
41
41
|
"SECRET_KEY",
|
|
42
|
-
help_text=
|
|
43
|
-
"Secret key that's used for certain cryptographic utilities. "
|
|
44
|
-
"You should generate one via `miniwebtool <https://www.miniwebtool.com/django-secret-key-generator>`_"
|
|
45
|
-
),
|
|
42
|
+
help_text="Secret key that's used for certain cryptographic utilities. ",
|
|
46
43
|
)
|
|
47
44
|
|
|
48
45
|
# NEVER run with DEBUG=True in production-like environments
|
|
@@ -213,6 +210,7 @@ INSTALLED_APPS = [
|
|
|
213
210
|
"vng_api_common",
|
|
214
211
|
"notifications_api_common",
|
|
215
212
|
"drf_spectacular",
|
|
213
|
+
"drf_spectacular_sidecar",
|
|
216
214
|
"rest_framework",
|
|
217
215
|
"django_markup",
|
|
218
216
|
"solo",
|
|
@@ -231,19 +229,20 @@ INSTALLED_APPS = [
|
|
|
231
229
|
"mozilla_django_oidc_db",
|
|
232
230
|
"log_outgoing_requests",
|
|
233
231
|
"django_setup_configuration",
|
|
232
|
+
"sessionprofile",
|
|
234
233
|
"open_api_framework",
|
|
235
234
|
PROJECT_DIRNAME,
|
|
236
235
|
]
|
|
237
236
|
|
|
238
237
|
MIDDLEWARE = [
|
|
239
238
|
"django.middleware.security.SecurityMiddleware",
|
|
239
|
+
"sessionprofile.middleware.SessionProfileMiddleware",
|
|
240
240
|
"django.contrib.sessions.middleware.SessionMiddleware",
|
|
241
241
|
"corsheaders.middleware.CorsMiddleware",
|
|
242
242
|
"django.middleware.common.CommonMiddleware",
|
|
243
243
|
"django.middleware.csrf.CsrfViewMiddleware",
|
|
244
244
|
"django.contrib.auth.middleware.AuthenticationMiddleware",
|
|
245
245
|
"maykin_2fa.middleware.OTPMiddleware",
|
|
246
|
-
"mozilla_django_oidc_db.middleware.SessionRefresh",
|
|
247
246
|
"django.contrib.messages.middleware.MessageMiddleware",
|
|
248
247
|
"django.middleware.clickjacking.XFrameOptionsMiddleware",
|
|
249
248
|
"axes.middleware.AxesMiddleware",
|
|
@@ -503,7 +502,7 @@ LOGGING = {
|
|
|
503
502
|
"handlers": (
|
|
504
503
|
["log_outgoing_requests", "save_outgoing_requests"]
|
|
505
504
|
if LOG_REQUESTS
|
|
506
|
-
else []
|
|
505
|
+
else ["save_outgoing_requests"]
|
|
507
506
|
),
|
|
508
507
|
"level": "DEBUG",
|
|
509
508
|
"propagate": True,
|
|
@@ -537,6 +536,12 @@ AUTHENTICATION_BACKENDS = [
|
|
|
537
536
|
|
|
538
537
|
SESSION_COOKIE_NAME = f"{PROJECT_DIRNAME}_sessionid"
|
|
539
538
|
SESSION_ENGINE = "django.contrib.sessions.backends.cache"
|
|
539
|
+
SESSION_COOKIE_AGE = config(
|
|
540
|
+
"SESSION_COOKIE_AGE",
|
|
541
|
+
default=1209600,
|
|
542
|
+
help_text="For how long, in seconds, the session cookie will be valid.",
|
|
543
|
+
)
|
|
544
|
+
|
|
540
545
|
|
|
541
546
|
LOGIN_URL = reverse_lazy("admin:login")
|
|
542
547
|
LOGIN_REDIRECT_URL = reverse_lazy("admin:index")
|
|
@@ -549,11 +554,12 @@ SESSION_COOKIE_SECURE = IS_HTTPS
|
|
|
549
554
|
SESSION_COOKIE_HTTPONLY = True
|
|
550
555
|
SESSION_COOKIE_SAMESITE = config(
|
|
551
556
|
"SESSION_COOKIE_SAMESITE",
|
|
552
|
-
"
|
|
557
|
+
"Lax",
|
|
553
558
|
help_text=(
|
|
554
559
|
"The value of the SameSite flag on the session cookie. This flag prevents the "
|
|
555
560
|
"cookie from being sent in cross-site requests thus preventing CSRF attacks and "
|
|
556
561
|
"making some methods of stealing session cookie impossible."
|
|
562
|
+
"Currently interferes with OIDC. Keep the value set at Lax if used."
|
|
557
563
|
),
|
|
558
564
|
)
|
|
559
565
|
|
|
@@ -955,9 +961,7 @@ LOG_OUTGOING_REQUESTS_MAX_AGE = config(
|
|
|
955
961
|
# NOTE: make sure values are a tuple or list, and to quote special values like 'self'
|
|
956
962
|
|
|
957
963
|
# ideally we'd use BASE_URI but it'd have to be lazy or cause issues
|
|
958
|
-
CSP_DEFAULT_SRC = [
|
|
959
|
-
"'self'",
|
|
960
|
-
] + config(
|
|
964
|
+
CSP_DEFAULT_SRC = ["'self'"] + config(
|
|
961
965
|
"CSP_EXTRA_DEFAULT_SRC",
|
|
962
966
|
default=[],
|
|
963
967
|
split=True,
|
|
@@ -998,12 +1002,16 @@ CSP_FORM_ACTION = (
|
|
|
998
1002
|
+ CORS_ALLOWED_ORIGINS
|
|
999
1003
|
)
|
|
1000
1004
|
|
|
1001
|
-
CSP_IMG_SRC =
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1005
|
+
CSP_IMG_SRC = (
|
|
1006
|
+
CSP_DEFAULT_SRC
|
|
1007
|
+
+ ["data:", "cdn.redoc.ly"] # used by DRF spectacular
|
|
1008
|
+
+ config(
|
|
1009
|
+
"CSP_EXTRA_IMG_SRC",
|
|
1010
|
+
default=[],
|
|
1011
|
+
split=True,
|
|
1012
|
+
group="Content Security Policy",
|
|
1013
|
+
help_text="Extra ``img-src`` sources for CSP other than ``CSP_DEFAULT_SRC``.",
|
|
1014
|
+
)
|
|
1007
1015
|
)
|
|
1008
1016
|
|
|
1009
1017
|
# affects <object> and <embed> tags, block everything by default but allow deploy-time
|
|
@@ -1018,8 +1026,13 @@ CSP_OBJECT_SRC = config(
|
|
|
1018
1026
|
|
|
1019
1027
|
# we must include this explicitly, otherwise the style-src only includes the nonce because
|
|
1020
1028
|
# of CSP_INCLUDE_NONCE_IN
|
|
1021
|
-
CSP_STYLE_SRC = CSP_DEFAULT_SRC
|
|
1022
|
-
|
|
1029
|
+
CSP_STYLE_SRC = CSP_DEFAULT_SRC + [
|
|
1030
|
+
"'unsafe-inline'",
|
|
1031
|
+
"fonts.googleapis.com",
|
|
1032
|
+
] # used by DRF spectacular
|
|
1033
|
+
CSP_SCRIPT_SRC = CSP_DEFAULT_SRC + ["'unsafe-inline'"]
|
|
1034
|
+
CSP_FONT_SRC = ("'self'", "fonts.gstatic.com")
|
|
1035
|
+
CSP_WORKER_SRC = ("'self'", "blob:")
|
|
1023
1036
|
|
|
1024
1037
|
# firefox does not get the nonce from default-src, see
|
|
1025
1038
|
# https://stackoverflow.com/a/63376012
|
|
@@ -1036,8 +1049,8 @@ CSP_FRAME_SRC = ["'self'"]
|
|
|
1036
1049
|
|
|
1037
1050
|
CSP_UPGRADE_INSECURE_REQUESTS = False # TODO enable on production?
|
|
1038
1051
|
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1052
|
+
|
|
1053
|
+
#
|
|
1054
|
+
# Django Solo
|
|
1055
|
+
#
|
|
1056
|
+
SOLO_CACHE = "default"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: open_api_framework
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.9.0
|
|
4
4
|
Summary: A metapackage for registration components, that bundles the dependencies shared between these components and provides generic settings
|
|
5
5
|
Author-email: Maykin Media <support@maykinmedia.nl>
|
|
6
6
|
License: Copyright © Maykin 2024
|
|
@@ -41,7 +41,7 @@ Requires-Dist: django-redis>=5.4.0
|
|
|
41
41
|
Requires-Dist: djangorestframework>=3.15.2
|
|
42
42
|
Requires-Dist: djangorestframework-gis>=1.0
|
|
43
43
|
Requires-Dist: django-filter>=24.2
|
|
44
|
-
Requires-Dist: drf-spectacular>=0.27.2
|
|
44
|
+
Requires-Dist: drf-spectacular[sidecar]>=0.27.2
|
|
45
45
|
Requires-Dist: django-csp>=3.8
|
|
46
46
|
Requires-Dist: djangorestframework-inclusions>=1.2.0
|
|
47
47
|
Requires-Dist: commonground-api-common>=1.12.1
|
|
@@ -59,6 +59,7 @@ Requires-Dist: celery>=5.4.0
|
|
|
59
59
|
Requires-Dist: flower>=2.0.1
|
|
60
60
|
Requires-Dist: maykin-2fa>=1.0.1
|
|
61
61
|
Requires-Dist: django-setup-configuration>=0.1.0
|
|
62
|
+
Requires-Dist: django-sessionprofile>=3.0.0
|
|
62
63
|
Provides-Extra: tests
|
|
63
64
|
Requires-Dist: pytest; extra == "tests"
|
|
64
65
|
Requires-Dist: pytest-django; extra == "tests"
|
|
@@ -66,6 +67,7 @@ Requires-Dist: tox; extra == "tests"
|
|
|
66
67
|
Requires-Dist: isort; extra == "tests"
|
|
67
68
|
Requires-Dist: black; extra == "tests"
|
|
68
69
|
Requires-Dist: flake8; extra == "tests"
|
|
70
|
+
Requires-Dist: factory-boy; extra == "tests"
|
|
69
71
|
Provides-Extra: coverage
|
|
70
72
|
Requires-Dist: pytest-cov; extra == "coverage"
|
|
71
73
|
Provides-Extra: docs
|
|
@@ -78,7 +80,7 @@ Requires-Dist: twine; extra == "release"
|
|
|
78
80
|
Open API Framework
|
|
79
81
|
==================
|
|
80
82
|
|
|
81
|
-
:Version: 0.
|
|
83
|
+
:Version: 0.9.0
|
|
82
84
|
:Source: https://github.com/maykinmedia/open-api-framework
|
|
83
85
|
:Keywords: metapackage, dependencies
|
|
84
86
|
|
{open_api_framework-0.8.0 → open_api_framework-0.9.0}/open_api_framework.egg-info/SOURCES.txt
RENAMED
|
@@ -5,9 +5,11 @@ README.rst
|
|
|
5
5
|
pyproject.toml
|
|
6
6
|
setup.cfg
|
|
7
7
|
open_api_framework/__init__.py
|
|
8
|
+
open_api_framework/admin.py
|
|
8
9
|
open_api_framework/apps.py
|
|
9
10
|
open_api_framework/context_processors.py
|
|
10
11
|
open_api_framework/py.typed
|
|
12
|
+
open_api_framework/utils.py
|
|
11
13
|
open_api_framework.egg-info/PKG-INFO
|
|
12
14
|
open_api_framework.egg-info/SOURCES.txt
|
|
13
15
|
open_api_framework.egg-info/dependency_links.txt
|
|
@@ -27,5 +29,6 @@ open_api_framework/templates/open_api_framework/components/version.html
|
|
|
27
29
|
open_api_framework/templatetags/__init__.py
|
|
28
30
|
open_api_framework/templatetags/doc_tags.py
|
|
29
31
|
open_api_framework/templatetags/open_api_framework.py
|
|
32
|
+
tests/test_admin.py
|
|
30
33
|
tests/test_config_helpers.py
|
|
31
34
|
tests/test_generate_envvar_docs.py
|
{open_api_framework-0.8.0 → open_api_framework-0.9.0}/open_api_framework.egg-info/requires.txt
RENAMED
|
@@ -9,7 +9,7 @@ django-redis>=5.4.0
|
|
|
9
9
|
djangorestframework>=3.15.2
|
|
10
10
|
djangorestframework-gis>=1.0
|
|
11
11
|
django-filter>=24.2
|
|
12
|
-
drf-spectacular>=0.27.2
|
|
12
|
+
drf-spectacular[sidecar]>=0.27.2
|
|
13
13
|
django-csp>=3.8
|
|
14
14
|
djangorestframework-inclusions>=1.2.0
|
|
15
15
|
commonground-api-common>=1.12.1
|
|
@@ -27,6 +27,7 @@ celery>=5.4.0
|
|
|
27
27
|
flower>=2.0.1
|
|
28
28
|
maykin-2fa>=1.0.1
|
|
29
29
|
django-setup-configuration>=0.1.0
|
|
30
|
+
django-sessionprofile>=3.0.0
|
|
30
31
|
|
|
31
32
|
[coverage]
|
|
32
33
|
pytest-cov
|
|
@@ -46,3 +47,4 @@ tox
|
|
|
46
47
|
isort
|
|
47
48
|
black
|
|
48
49
|
flake8
|
|
50
|
+
factory-boy
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "open_api_framework"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.9.0"
|
|
8
8
|
description = "A metapackage for registration components, that bundles the dependencies shared between these components and provides generic settings"
|
|
9
9
|
authors = [
|
|
10
10
|
{name = "Maykin Media", email = "support@maykinmedia.nl"}
|
|
@@ -38,7 +38,7 @@ dependencies = [
|
|
|
38
38
|
"djangorestframework>=3.15.2",
|
|
39
39
|
"djangorestframework-gis>=1.0",
|
|
40
40
|
"django-filter>=24.2",
|
|
41
|
-
"drf-spectacular>=0.27.2",
|
|
41
|
+
"drf-spectacular[sidecar]>=0.27.2",
|
|
42
42
|
"django-csp>=3.8",
|
|
43
43
|
"djangorestframework-inclusions>=1.2.0",
|
|
44
44
|
"commonground-api-common>=1.12.1",
|
|
@@ -56,6 +56,7 @@ dependencies = [
|
|
|
56
56
|
"flower>=2.0.1",
|
|
57
57
|
"maykin-2fa>=1.0.1",
|
|
58
58
|
"django-setup-configuration>=0.1.0",
|
|
59
|
+
"django-sessionprofile>=3.0.0",
|
|
59
60
|
]
|
|
60
61
|
|
|
61
62
|
[project.urls]
|
|
@@ -72,6 +73,7 @@ tests = [
|
|
|
72
73
|
"isort",
|
|
73
74
|
"black",
|
|
74
75
|
"flake8",
|
|
76
|
+
"factory-boy",
|
|
75
77
|
]
|
|
76
78
|
coverage = [
|
|
77
79
|
"pytest-cov",
|
|
@@ -101,7 +103,7 @@ testpaths = ["tests"]
|
|
|
101
103
|
DJANGO_SETTINGS_MODULE = "testapp.settings"
|
|
102
104
|
|
|
103
105
|
[tool.bumpversion]
|
|
104
|
-
current_version = "0.
|
|
106
|
+
current_version = "0.9.0"
|
|
105
107
|
files = [
|
|
106
108
|
{filename = "pyproject.toml"},
|
|
107
109
|
{filename = "README.rst"},
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
from django.contrib.sessions.backends.cache import SessionStore as CachedSessionStore
|
|
2
|
+
from django.contrib.sessions.backends.db import SessionStore as DBSessionStore
|
|
3
|
+
from django.contrib.sessions.models import Session
|
|
4
|
+
from django.test import override_settings
|
|
5
|
+
from django.urls import reverse
|
|
6
|
+
|
|
7
|
+
import pytest
|
|
8
|
+
from sessionprofile.models import SessionProfile
|
|
9
|
+
|
|
10
|
+
from open_api_framework.utils import get_session_store
|
|
11
|
+
|
|
12
|
+
from .factories import SessionProfileFactory
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@pytest.fixture
|
|
16
|
+
def session_changelist_url():
|
|
17
|
+
return reverse("admin:sessionprofile_sessionprofile_changelist")
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def test_session_profile_sanity(client, admin_user, session_changelist_url):
|
|
21
|
+
|
|
22
|
+
client.force_login(admin_user)
|
|
23
|
+
response = client.get(session_changelist_url)
|
|
24
|
+
assert response.status_code == 200
|
|
25
|
+
|
|
26
|
+
assert SessionProfile.objects.count() == 1
|
|
27
|
+
|
|
28
|
+
session = SessionProfile.objects.get()
|
|
29
|
+
assert client.session.session_key == session.session_key
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def test_only_session_profile_of_user_shown(
|
|
33
|
+
client, admin_user, django_user_model, session_changelist_url
|
|
34
|
+
):
|
|
35
|
+
|
|
36
|
+
other_admin = django_user_model.objects.create_superuser("garry")
|
|
37
|
+
|
|
38
|
+
client.force_login(other_admin)
|
|
39
|
+
response = client.get(session_changelist_url)
|
|
40
|
+
assert response.status_code == 200
|
|
41
|
+
|
|
42
|
+
client.force_login(admin_user)
|
|
43
|
+
response = client.get(session_changelist_url)
|
|
44
|
+
assert response.status_code == 200
|
|
45
|
+
|
|
46
|
+
# two sessions, one for each user
|
|
47
|
+
assert SessionProfile.objects.count() == 2
|
|
48
|
+
|
|
49
|
+
# Session created after response, needs to be called again
|
|
50
|
+
response = client.get(session_changelist_url)
|
|
51
|
+
|
|
52
|
+
admin_user_session = SessionProfile.objects.get(user=admin_user)
|
|
53
|
+
assert admin_user_session.session_key in response.content.decode()
|
|
54
|
+
|
|
55
|
+
other_user_session = SessionProfile.objects.get(user=other_admin)
|
|
56
|
+
assert other_user_session.session_key not in response.content.decode()
|
|
57
|
+
|
|
58
|
+
# should only be able to access own page
|
|
59
|
+
change_url = reverse(
|
|
60
|
+
"admin:sessionprofile_sessionprofile_change",
|
|
61
|
+
args=[admin_user_session.session_key],
|
|
62
|
+
)
|
|
63
|
+
response = client.get(change_url)
|
|
64
|
+
assert response.status_code == 200
|
|
65
|
+
|
|
66
|
+
change_url = reverse(
|
|
67
|
+
"admin:sessionprofile_sessionprofile_change",
|
|
68
|
+
args=[other_user_session.session_key],
|
|
69
|
+
)
|
|
70
|
+
response = client.get(change_url)
|
|
71
|
+
assert response.status_code == 302
|
|
72
|
+
assert response.url == reverse("admin:index")
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def test_cant_delete_other_users_session(client, admin_user, django_user_model):
|
|
76
|
+
client.force_login(admin_user)
|
|
77
|
+
|
|
78
|
+
other_admin = django_user_model.objects.create_superuser("garry")
|
|
79
|
+
|
|
80
|
+
other_user_session = SessionProfileFactory(user=other_admin)
|
|
81
|
+
|
|
82
|
+
delete_url = reverse(
|
|
83
|
+
"admin:sessionprofile_sessionprofile_delete",
|
|
84
|
+
args=[other_user_session.session_key],
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
response = client.post(delete_url, {"post": "yes"})
|
|
88
|
+
assert response.status_code == 302
|
|
89
|
+
|
|
90
|
+
SessionStore = get_session_store()
|
|
91
|
+
|
|
92
|
+
assert SessionStore().exists(other_user_session.session_key)
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def test_delete_with_session_db_backend(client, admin_user, session_changelist_url):
|
|
96
|
+
client.force_login(admin_user)
|
|
97
|
+
|
|
98
|
+
session = SessionProfileFactory(user=admin_user)
|
|
99
|
+
|
|
100
|
+
assert SessionProfile.objects.count() == 1
|
|
101
|
+
# sesison created by login
|
|
102
|
+
assert Session.objects.count() == 2
|
|
103
|
+
assert DBSessionStore().exists(session.session_key)
|
|
104
|
+
|
|
105
|
+
url = reverse("admin:sessionprofile_sessionprofile_delete", args=[session.pk])
|
|
106
|
+
|
|
107
|
+
response = client.post(url, {"post": "yes"})
|
|
108
|
+
assert response.status_code == 302
|
|
109
|
+
|
|
110
|
+
# new session saved upon request
|
|
111
|
+
assert SessionProfile.objects.count() == 1
|
|
112
|
+
assert SessionProfile.objects.count() != session
|
|
113
|
+
assert Session.objects.count() == 1
|
|
114
|
+
assert not DBSessionStore().exists(session.session_key)
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
@override_settings(SESSION_ENGINE="django.contrib.sessions.backends.cache")
|
|
118
|
+
def test_delete_with_session_cache_backend(client, admin_user, session_changelist_url):
|
|
119
|
+
client.force_login(admin_user)
|
|
120
|
+
|
|
121
|
+
session = SessionProfileFactory(user=admin_user)
|
|
122
|
+
|
|
123
|
+
assert SessionProfile.objects.count() == 1
|
|
124
|
+
assert Session.objects.count() == 0
|
|
125
|
+
assert CachedSessionStore().exists(session.session_key)
|
|
126
|
+
|
|
127
|
+
url = reverse("admin:sessionprofile_sessionprofile_delete", args=[session.pk])
|
|
128
|
+
|
|
129
|
+
response = client.post(url, {"post": "yes"})
|
|
130
|
+
assert response.status_code == 302
|
|
131
|
+
|
|
132
|
+
# new session saved upon request
|
|
133
|
+
assert SessionProfile.objects.count() == 1
|
|
134
|
+
assert SessionProfile.objects.count() != session
|
|
135
|
+
assert Session.objects.count() == 0
|
|
136
|
+
assert not CachedSessionStore().exists(session.session_key)
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
def test_delete_action_with_session_db_backend(
|
|
140
|
+
client, admin_user, session_changelist_url
|
|
141
|
+
):
|
|
142
|
+
client.force_login(admin_user)
|
|
143
|
+
sessions = SessionProfileFactory.create_batch(5, user=admin_user)
|
|
144
|
+
|
|
145
|
+
# one created from user login
|
|
146
|
+
assert Session.objects.count() == 6
|
|
147
|
+
assert SessionProfile.objects.count() == 5
|
|
148
|
+
|
|
149
|
+
session_keys = [session.session_key for session in sessions]
|
|
150
|
+
for session_key in session_keys:
|
|
151
|
+
assert DBSessionStore().exists(session_key)
|
|
152
|
+
|
|
153
|
+
response = client.post(
|
|
154
|
+
session_changelist_url,
|
|
155
|
+
{"action": "delete_selected", "_selected_action": session_keys, "post": "yes"},
|
|
156
|
+
)
|
|
157
|
+
assert response.status_code == 302
|
|
158
|
+
|
|
159
|
+
# one is created as the post request is sent
|
|
160
|
+
assert SessionProfile.objects.count() == 1
|
|
161
|
+
assert Session.objects.count() == 1
|
|
162
|
+
|
|
163
|
+
for session_key in session_keys:
|
|
164
|
+
assert not DBSessionStore().exists(session_key)
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
@override_settings(SESSION_ENGINE="django.contrib.sessions.backends.cache")
|
|
168
|
+
def test_delete_action_with_session_cache_backend(
|
|
169
|
+
client, admin_user, session_changelist_url
|
|
170
|
+
):
|
|
171
|
+
|
|
172
|
+
client.force_login(admin_user)
|
|
173
|
+
sessions = SessionProfileFactory.create_batch(5, user=admin_user)
|
|
174
|
+
|
|
175
|
+
# no db sessions are created
|
|
176
|
+
assert Session.objects.count() == 0
|
|
177
|
+
assert SessionProfile.objects.count() == 5
|
|
178
|
+
|
|
179
|
+
session_keys = [session.session_key for session in sessions]
|
|
180
|
+
|
|
181
|
+
# sessions are created
|
|
182
|
+
for session_key in session_keys:
|
|
183
|
+
assert CachedSessionStore().exists(session_key)
|
|
184
|
+
|
|
185
|
+
response = client.post(
|
|
186
|
+
session_changelist_url,
|
|
187
|
+
{"action": "delete_selected", "_selected_action": session_keys, "post": "yes"},
|
|
188
|
+
)
|
|
189
|
+
assert response.status_code == 302
|
|
190
|
+
|
|
191
|
+
# one is created as the post request is sent
|
|
192
|
+
assert SessionProfile.objects.count() == 1
|
|
193
|
+
assert Session.objects.count() == 0
|
|
194
|
+
|
|
195
|
+
# sessions should be deleted
|
|
196
|
+
for session_key in session_keys:
|
|
197
|
+
assert not CachedSessionStore().exists(session_key)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{open_api_framework-0.8.0 → open_api_framework-0.9.0}/open_api_framework/context_processors.py
RENAMED
|
File without changes
|
{open_api_framework-0.8.0 → open_api_framework-0.9.0}/open_api_framework/management/__init__.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
|
{open_api_framework-0.8.0 → open_api_framework-0.9.0}/open_api_framework/templatetags/__init__.py
RENAMED
|
File without changes
|
{open_api_framework-0.8.0 → open_api_framework-0.9.0}/open_api_framework/templatetags/doc_tags.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{open_api_framework-0.8.0 → open_api_framework-0.9.0}/open_api_framework.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|