(oidc) Fix update_user when User.sub is nullable #31
+25
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
En utilisant le module OIDC sur un autre projet, je me suis rendu compte que le update_user_if_needed ne gère pas correctement le cas d'un projet avec User.sub nullable (ex: un projet qui a commencé avec un autre moyen d'authentification et qui migre sur OIDC, ou un projet qui a plusieurs moyens d'authentification actif).
Reproduction du bug
sub is NULL
, comme il y a une unicité sur la colonne, la requête échoueProposal
Modifier la requête de mise à jour pour cibler uniquement l'utilisateur trouvé.
Note
La requête actuelle échoue également si on utilise un champs sub custom via settings.OIDC_USER_SUB_FIELD