Skip to content

Commit

Permalink
Add OPENID_ADMIN_GROUPS
Browse files Browse the repository at this point in the history
  • Loading branch information
timonegk committed Jan 12, 2024
1 parent aabe76e commit fcaf36d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions bitpoll/base/openid.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ def automap_user_attrs(self, user, user_data):
group = Group.objects.get_or_create(name=group_name)[0]
group.user_set.add(user)
group.save()
if settings.OPENID_ADMIN_GROUPS.fullmatch(group.name) is not None:
user.is_superuser = True
user.is_staff = True


def refresh_group_users(group: Group):
Expand Down
3 changes: 2 additions & 1 deletion bitpoll/settings_local.sample.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# customize to your needs

import re
# You must insert your own random value here
# SECURITY WARNING: keep the secret key used in production secret!
# see <https://docs.djangoproject.com/en/dev/howto/deployment/checklist/#secret-key>
Expand Down Expand Up @@ -35,6 +35,7 @@
#OPENID_BASE_URI = "..."
#OPENID_SCOPE = "openid profile email"
#OPENID_USER_MAPPER = 'bitpoll.base.openid.BitpollUserMapper'
#OPENID_ADMIN_GROUPS = re.compile('admins|superusers')
#LOGIN_URL = "simple_openid_connect_django:login"
#LOGOUT_REDIRECT_URL = "index"

Expand Down

0 comments on commit fcaf36d

Please sign in to comment.