mirror of
https://github.com/YunoHost-Apps/django_example_ynh.git
synced 2024-09-03 18:26:21 +02:00
commit
2c93f71ef0
6 changed files with 19 additions and 7 deletions
|
@ -121,8 +121,10 @@ Notes:
|
||||||
|
|
||||||
## history
|
## history
|
||||||
|
|
||||||
* [compare v0.1.3...master](https://github.com/YunoHost-Apps/django_ynh/compare/v0.1.3...master) **dev**
|
* [compare v0.1.4...master](https://github.com/YunoHost-Apps/django_ynh/compare/v0.1.4...master) **dev**
|
||||||
* tbc
|
* tbc
|
||||||
|
* [v0.1.4 - 08.01.2021](https://github.com/YunoHost-Apps/django_ynh/compare/v0.1.3...v0.1.4)
|
||||||
|
* Bugfix [CSRF verification failed on POST requests #7](https://github.com/YunoHost-Apps/django_ynh/issues/7)
|
||||||
* [v0.1.3 - 08.01.2021](https://github.com/YunoHost-Apps/django_ynh/compare/v0.1.2...v0.1.3)
|
* [v0.1.3 - 08.01.2021](https://github.com/YunoHost-Apps/django_ynh/compare/v0.1.2...v0.1.3)
|
||||||
* set "DEBUG = True" in local_test (so static files are served and auth works)
|
* set "DEBUG = True" in local_test (so static files are served and auth works)
|
||||||
* Bugfixes and cleanups
|
* Bugfixes and cleanups
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
__version__ = '0.1.3'
|
__version__ = '0.1.4'
|
||||||
|
|
|
@ -3,6 +3,8 @@ import logging
|
||||||
|
|
||||||
from axes.exceptions import AxesBackendPermissionDenied
|
from axes.exceptions import AxesBackendPermissionDenied
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
from django.contrib import auth
|
||||||
|
from django.contrib.auth import get_user_model
|
||||||
from django.contrib.auth.middleware import RemoteUserMiddleware
|
from django.contrib.auth.middleware import RemoteUserMiddleware
|
||||||
|
|
||||||
from django_ynh.sso_auth.user_profile import call_setup_user, update_user_profile
|
from django_ynh.sso_auth.user_profile import call_setup_user, update_user_profile
|
||||||
|
@ -11,6 +13,9 @@ from django_ynh.sso_auth.user_profile import call_setup_user, update_user_profil
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
UserModel = get_user_model()
|
||||||
|
|
||||||
|
|
||||||
class SSOwatRemoteUserMiddleware(RemoteUserMiddleware):
|
class SSOwatRemoteUserMiddleware(RemoteUserMiddleware):
|
||||||
"""
|
"""
|
||||||
Middleware to login a user via HTTP_REMOTE_USER header.
|
Middleware to login a user via HTTP_REMOTE_USER header.
|
||||||
|
@ -63,12 +68,12 @@ class SSOwatRemoteUserMiddleware(RemoteUserMiddleware):
|
||||||
|
|
||||||
# Also check 'HTTP_AUTHORIZATION', but only the username ;)
|
# Also check 'HTTP_AUTHORIZATION', but only the username ;)
|
||||||
try:
|
try:
|
||||||
auth = request.META['HTTP_AUTHORIZATION']
|
authorization = request.META['HTTP_AUTHORIZATION']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
logger.error('HTTP_AUTHORIZATION missing!')
|
logger.error('HTTP_AUTHORIZATION missing!')
|
||||||
raise AxesBackendPermissionDenied('No HTTP_AUTHORIZATION')
|
raise AxesBackendPermissionDenied('No HTTP_AUTHORIZATION')
|
||||||
|
|
||||||
scheme, creds = auth.split(' ', 1)
|
scheme, creds = authorization.split(' ', 1)
|
||||||
if scheme.lower() != 'basic':
|
if scheme.lower() != 'basic':
|
||||||
logger.error('HTTP_AUTHORIZATION with %r not supported', scheme)
|
logger.error('HTTP_AUTHORIZATION with %r not supported', scheme)
|
||||||
raise AxesBackendPermissionDenied('HTTP_AUTHORIZATION scheme not supported')
|
raise AxesBackendPermissionDenied('HTTP_AUTHORIZATION scheme not supported')
|
||||||
|
@ -84,3 +89,8 @@ class SSOwatRemoteUserMiddleware(RemoteUserMiddleware):
|
||||||
user = update_user_profile(request, user)
|
user = update_user_profile(request, user)
|
||||||
|
|
||||||
user = call_setup_user(user=user)
|
user = call_setup_user(user=user)
|
||||||
|
assert isinstance(user, UserModel)
|
||||||
|
|
||||||
|
# persist user in the session
|
||||||
|
request.user = user
|
||||||
|
auth.login(request, user)
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
"description": {
|
"description": {
|
||||||
"en": "Glue code to package django projects as yunohost apps."
|
"en": "Glue code to package django projects as yunohost apps."
|
||||||
},
|
},
|
||||||
"version": "0.1.3~ynh1",
|
"version": "0.1.4~ynh1",
|
||||||
"url": "https://github.com/jedie/django_ynh",
|
"url": "https://github.com/jedie/django_ynh",
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
"maintainer": {
|
"maintainer": {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "django_ynh"
|
name = "django_ynh"
|
||||||
version = "0.1.3"
|
version = "0.1.4"
|
||||||
description = "Glue code to package django projects as yunohost apps."
|
description = "Glue code to package django projects as yunohost apps."
|
||||||
authors = ["JensDiemer <git@jensdiemer.de>"]
|
authors = ["JensDiemer <git@jensdiemer.de>"]
|
||||||
license = "GPL"
|
license = "GPL"
|
||||||
|
|
|
@ -28,7 +28,7 @@ log_file="${log_path}/django_ynh.log"
|
||||||
pkg_dependencies="build-essential python3-dev python3-pip python3-venv git postgresql postgresql-contrib"
|
pkg_dependencies="build-essential python3-dev python3-pip python3-venv git postgresql postgresql-contrib"
|
||||||
|
|
||||||
# To install/upgrade this project via pip:
|
# To install/upgrade this project via pip:
|
||||||
pip_install_string="django_ynh==0.1.3"
|
pip_install_string="django_ynh==0.1.4"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# Redis HELPERS
|
# Redis HELPERS
|
||||||
|
|
Loading…
Add table
Reference in a new issue