Skip to content

OpenID Connect login as second method#798

Open
Crasher508 wants to merge 9 commits intodevelopfrom
oidc_login
Open

OpenID Connect login as second method#798
Crasher508 wants to merge 9 commits intodevelopfrom
oidc_login

Conversation

@Crasher508
Copy link
Copy Markdown
Member

This PR adds the ability to login using OpenID connect
Bildschirmfoto vom 2026-04-01 18-14-34

new dependency: https://pypi.org/project/flask-oidc/

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 1, 2026

Codecov Report

❌ Patch coverage is 97.77778% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 88.10%. Comparing base (57c723f) to head (7204dc3).
⚠️ Report is 4 commits behind head on develop.

Files with missing lines Patch % Lines
web/blueprints/login/__init__.py 92.30% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #798      +/-   ##
===========================================
+ Coverage    87.90%   88.10%   +0.19%     
===========================================
  Files          280      281       +1     
  Lines        17424    17423       -1     
===========================================
+ Hits         15317    15350      +33     
+ Misses        2107     2073      -34     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Crasher508 Crasher508 requested a review from lukasjuhrich April 9, 2026 10:34
Comment thread web/blueprints/login/__init__.py Outdated
flash("Benutzername und/oder Passwort falsch", "error")
if oidc.user_loggedin:
info = flask_session["oidc_auth_profile"]
username = info.get("preferred_username")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately I have no idea what the shape of oidc_auth_profile is.
Our current mappings in keycloak are like this:

Image

I am not sure if preferred_username is some special thing always provided by keycloak or flask-oidc.

In any case, the intended functionality is:

  1. if pycroft_login is set, use that. If the corresponding user does not exist, abort with an error and do not attempt to fall back.
  2. if not set, use the username.

username = info.get("preferred_username")
user = User.get(username)
if info is not None and username is not None and user is not None:
login_user(user)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, you need to verify the condition that the user has the Mitgliederverwalter role set: Not all users of the internal realm (i.e., all active members) are allowed to log in to pycroft.
this is mapped in keycloak, but I do not know how it is exposed in the user profile.

Comment thread pycroft/model/user.py Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants