Page MenuHomeSoftware Heritage

django/models: Map keycloak groups to django ones in OIDCUser model
ClosedPublic

Authored by anlambert on May 20 2022, 12:04 PM.

Details

Summary

Add support for mapping Keycloak groups to Django ones in OIDCUser
model by overriding the groups member of Django base User model.

It enables to manipulate user groups declared in Keycloak using
Django standard User model API.

Finally found a solution to map Keycloak groups to Django ones.
It will enable to take advantage of user group membership in Software
Heritage web services based on Django.

Diff Detail

Repository
rDAUTH Common authentication libraries
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

Build is green

Patch application report for D7867 (id=28408)

Rebasing onto f9717f3e7e...

Current branch diff-target is up to date.
Changes applied before test
commit 9dcb735cfcc831353d6f2d70ee9b1d2ae0c1a6af
Author: Antoine Lambert <anlambert@softwareheritage.org>
Date:   Fri May 20 11:52:27 2022 +0200

    django/models: Map keycloak groups to django ones in OIDCUser model
    
    Add support for mapping Keycloak groups to Django ones in OIDCUser
    model by overriding the groups member of Django base User model.
    
    It enables to manipulate user groups declared in Keycloak using
    Django standard User model API.

See https://jenkins.softwareheritage.org/job/DAUTH/job/tests-on-diff/91/ for more details.

ardumont added a subscriber: ardumont.
ardumont added inline comments.
swh/auth/tests/django/test_backends.py
20

does that replace the decorators you removed below?

This revision is now accepted and ready to land.May 20 2022, 1:14 PM
swh/auth/tests/django/test_backends.py
20

Yes, it enables to save a few lines when all tests need django db access.