Skip to content

Commit

Permalink
Django uses raw redirect_uri. Fixes #26
Browse files Browse the repository at this point in the history
  • Loading branch information
rayluo committed May 26, 2024
1 parent aadbf49 commit 82ac09f
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions identity/django.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ class Auth(WebFrameworkAuth):

def __init__(self, *args, **kwargs):
super(Auth, self).__init__(*args, **kwargs)
route, self._redirect_view = _parse_redirect_uri(self._redirect_uri)
route, redirect_view = _parse_redirect_uri(self._redirect_uri)
self.urlpattern = path(route, include([
# Note: path(..., view, ...) does not accept classmethod
path('login', self.login),
path('logout', self.logout, name=f"identity.logout"),
path(
self._redirect_view or 'auth_response', # The latter is used by device code flow
redirect_view or 'auth_response', # The latter is used by device code flow
self.auth_response,
),
]))
Expand All @@ -63,15 +63,9 @@ def login(
if config_error:
return self._render_auth_error(
request, error="configuration_error", error_description=config_error)
redirect_uri = request.build_absolute_uri(
self._redirect_view) if self._redirect_view else None
if redirect_uri != self._redirect_uri:
logger.warning(
"redirect_uri mismatch: configured = %s, calculated = %s",
self._redirect_uri, redirect_uri)
log_in_result = self._build_auth(request.session).log_in(
scopes=scopes, # Have user consent to scopes (if any) during log-in
redirect_uri=redirect_uri, # Optional. If present, this absolute URL must match your app's redirect_uri registered in Azure Portal
redirect_uri=self._redirect_uri, # Optional. If present, this absolute URL must match your app's redirect_uri registered in Azure Portal
prompt="select_account", # Optional. More values defined in https://openid.net/specs/openid-connect-core-1_0.html#AuthRequest
next_link=next_link,
)
Expand Down

0 comments on commit 82ac09f

Please sign in to comment.