Merge pull request #10 from YunoHost-Apps/testing

master <- testing
This commit is contained in:
Jens Diemer 2021-01-08 11:08:54 +01:00 committed by GitHub
commit 2c93f71ef0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 19 additions and 7 deletions

View file

@ -121,8 +121,10 @@ Notes:
## 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
* [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)
* set "DEBUG = True" in local_test (so static files are served and auth works)
* Bugfixes and cleanups

View file

@ -1 +1 @@
__version__ = '0.1.3'
__version__ = '0.1.4'

View file

@ -3,6 +3,8 @@ import logging
from axes.exceptions import AxesBackendPermissionDenied
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_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__)
UserModel = get_user_model()
class SSOwatRemoteUserMiddleware(RemoteUserMiddleware):
"""
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 ;)
try:
auth = request.META['HTTP_AUTHORIZATION']
authorization = request.META['HTTP_AUTHORIZATION']
except KeyError:
logger.error('HTTP_AUTHORIZATION missing!')
raise AxesBackendPermissionDenied('No HTTP_AUTHORIZATION')
scheme, creds = auth.split(' ', 1)
scheme, creds = authorization.split(' ', 1)
if scheme.lower() != 'basic':
logger.error('HTTP_AUTHORIZATION with %r not supported', scheme)
raise AxesBackendPermissionDenied('HTTP_AUTHORIZATION scheme not supported')
@ -84,3 +89,8 @@ class SSOwatRemoteUserMiddleware(RemoteUserMiddleware):
user = update_user_profile(request, user)
user = call_setup_user(user=user)
assert isinstance(user, UserModel)
# persist user in the session
request.user = user
auth.login(request, user)

View file

@ -5,7 +5,7 @@
"description": {
"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",
"license": "GPL-3.0",
"maintainer": {

View file

@ -1,6 +1,6 @@
[tool.poetry]
name = "django_ynh"
version = "0.1.3"
version = "0.1.4"
description = "Glue code to package django projects as yunohost apps."
authors = ["JensDiemer <git@jensdiemer.de>"]
license = "GPL"

View file

@ -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"
# 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