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

Make Keycloak's ID_KEY configurable #815

Merged
merged 1 commit into from
Jul 24, 2023

Conversation

derlin
Copy link
Contributor

@derlin derlin commented Jul 21, 2023

Proposed changes

As explained in:

Currently, it is not possible to change the ID_KEY of the keycloak provider, even though this feature was meant to be present (according to the docstring). The ID_KEY is basically the claim used to map a user.

With this change, it is now possible to set the ID_KEY to any field present either in details or in the returned token:

SOCIAL_AUTH_KEYCLOAK_ID_KEY = "email" # use the keycloak user email (from details)
SOCIAL_AUTH_KEYCLOAK_ID_KEY = "sub" # use the keycloak user id (from token)

Types of changes

Please check the type of change your PR introduces:

  • Release (new release request)
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Code style update (PEP8, lint, formatting, renaming, etc)
  • Refactoring (no functional changes, no api changes)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Build related changes (build process, tests runner, etc)
  • Other (please describe):

Checklist

Put an x in the boxes that apply. You can also fill these out after creating
the PR. If you're unsure about any of them, don't hesitate to ask. We're here to
help! This is simply a reminder of what we are going to look for before merging
your code.

  • Lint and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works

Other information

I haven't added tests since such configurations don't seem to be tested on other backends. The default will stay exactly the same, thus not breaking the current behaviour.

Closes #813

@codecov
Copy link

codecov bot commented Jul 21, 2023

Codecov Report

Merging #815 (d35b176) into master (8ac4051) will decrease coverage by 0.02%.
The diff coverage is 66.66%.

@@            Coverage Diff             @@
##           master     #815      +/-   ##
==========================================
- Coverage   77.81%   77.80%   -0.02%     
==========================================
  Files         330      330              
  Lines       10093    10097       +4     
  Branches     1194     1195       +1     
==========================================
+ Hits         7854     7856       +2     
- Misses       2086     2087       +1     
- Partials      153      154       +1     
Flag Coverage Δ
unittests 77.80% <66.66%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
social_core/backends/keycloak.py 92.59% <66.66%> (-7.41%) ⬇️

@nijel nijel merged commit 70d7713 into python-social-auth:master Jul 24, 2023
@nijel
Copy link
Member

nijel commented Jul 24, 2023

Merged, thanks for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Keycloak ID_KEY should be read from settings
2 participants