-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement synchronization of mafiasi admin status via oidc
- Loading branch information
Showing
3 changed files
with
25 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from django.conf import settings | ||
from simple_openid_connect.integrations.django.user_mapping import ( | ||
FederatedUserData, | ||
UserMapper, | ||
) | ||
|
||
from mafiasi_link_shortener.links import models | ||
|
||
|
||
class MafiasiUserMapper(UserMapper): | ||
def automap_user_attrs( | ||
self, user: models.MafiasiUser, user_data: FederatedUserData | ||
) -> None: | ||
super().automap_user_attrs(user, user_data) | ||
|
||
if hasattr(user_data, "groups"): | ||
for group in user_data.groups: | ||
if settings.OPENID_ADMIN_GROUPS.fullmatch(group) is not None: | ||
user.is_superuser = True | ||
user.is_staff = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters