Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass the current http.request to the _update_user backend hook #351

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions djangosaml2/backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
from django.apps import apps
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured, MultipleObjectsReturned

from django.contrib import auth
from django.contrib.auth.backends import ModelBackend
from django.http.request import HttpRequest

logger = logging.getLogger("djangosaml2")

Expand Down Expand Up @@ -166,14 +166,14 @@ def authenticate(
# Update user with new attributes from incoming request
if user is not None:
user = self._update_user(
user, attributes, attribute_mapping, force_save=created
user, attributes, attribute_mapping, force_save=created, request=request
)

if self.user_can_authenticate(user):
return user

def _update_user(
self, user, attributes: dict, attribute_mapping: dict, force_save: bool = False
self, user, attributes: dict, attribute_mapping: dict, force_save: bool = False, request: HttpRequest = None
):
"""Update a user with a set of attributes and returns the updated user.

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def read(*rnames):

setup(
name="djangosaml2",
version="1.5.3",
version="1.5.4",
description="pysaml2 integration for Django",
long_description=read("README.md"),
long_description_content_type="text/markdown",
Expand Down