From 0925304a9e437f8b729862687d3a808c7fb88a95 Mon Sep 17 00:00:00 2001 From: Rob Percival Date: Wed, 15 Nov 2023 16:26:14 +0000 Subject: [PATCH] Revert "Make Keycloak's ID_KEY configurable" This reverts commit 70d7713ba8bd61a0fa711f062b73da707efb8ef0. --- CHANGELOG.md | 1 - social_core/backends/keycloak.py | 14 +++----------- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6330d9c9..c438d9ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,7 +24,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Changed - Fixed Azure AD Tenant authentication with custom signing keys - Added CAS OIDC backend -- Made Keycloak `ID_KEY` configurable ## [4.4.1](https://github.com/python-social-auth/social-core/releases/tag/4.4.1) - 2023-03-30 diff --git a/social_core/backends/keycloak.py b/social_core/backends/keycloak.py index d5d2751f..494ddabd 100644 --- a/social_core/backends/keycloak.py +++ b/social_core/backends/keycloak.py @@ -96,6 +96,7 @@ class KeycloakOAuth2(BaseOAuth2): # pylint: disable=abstract-method """ name = "keycloak" + ID_KEY = "username" ACCESS_TOKEN_METHOD = "POST" REDIRECT_STATE = False @@ -120,9 +121,6 @@ def public_key(self): ] ) - def id_key(self): - return self.setting("ID_KEY", default="username") - def user_data( self, access_token, *args, **kwargs ): # pylint: disable=unused-argument @@ -151,11 +149,5 @@ def get_user_details(self, response): } def get_user_id(self, details, response): - """Get and associate Django User by the field indicated by ID_KEY - - The ID_KEY can be any field in the user details or the access token. - """ - id_key = self.id_key() - if id_key in details: - return details[id_key] - return response.get(id_key) + """Get and associate Django User by the field indicated by ID_KEY""" + return details.get(self.ID_KEY)