[Feature Request] Allow passing a post-authentication callable to OIDCAuth
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 135
- Forks
- 67
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
The OIDCAuth class and group-based features added in 2.3.0 are great!
It would be useful for the OIDCAuth class to take a callable that is executed at the end of the OIDCAuth.callback method just before the redirect. This function would take the access token as single positional argument and have access to the session global, e.g.:
from dash import Dash
from dash_auth import OIDCAuth
from flask import session
def add_scopes_to_user(token):
if scope := token.get("scope"):
session["user"]["scopes"] = scope.split()
app = Dash(__name__)
auth = OIDCAuth(
app,
secret_key="aStaticSecretKey!",
post_auth_callback=add_scopes_to_user, # defaults to None
)
This feature would provide a lot of flexibility to app developers for different use cases:
- storage of additional fields from the token in the session (example above),
- add a user to the DB if not already existing,
- custom logging,
- etc.
I can submit a PR if this is a feature the maintainers would consider merging.
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit dem in der Anfrage beschriebenen OIDCAuth-Konstruktor und dem OIDCAuth.callback-Einstiegspunkt und untersuche das bestehende Verhalten von OIDCAuth rund um die abschließende Weiterleitung. Lege das Token-Argument, den Sitzungszugriff und den Ausführungszeitpunkt des optionalen Callables fest und füge Tests hinzu, die zeigen, dass es vor der Weiterleitung ausgeführt wird und übersprungen wird, wenn es nicht gesetzt ist.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- authentication
- Issue-Typ
- Feature
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Klar beschrieben
- Anfängerfreundlichkeit
- 45/100