social account admin group support

This commit is contained in:
Boris Rybalkin
2024-09-04 09:33:33 +01:00
parent a03c7701a5
commit 79abbf0850
2 changed files with 8 additions and 2 deletions

View File

@@ -85,5 +85,9 @@ class CustomSocialAccountAdapter(DefaultSocialAccountAdapter):
Populate the user with data from the social account. Stub is kept in case
global default permissions are implemented in the future.
"""
# TODO: If default global permissions are implemented, should also be here
return super().populate_user(request, sociallogin, data) # pragma: no cover
user = super().populate_user(request, sociallogin, data)
groups = sociallogin.account.extra_data.get(settings.SOCIALACCOUNT_ADMIN_GROUP_SCOPE)
if groups:
if settings.SOCIALACCOUNT_ADMIN_GROUP in groups:
user.is_superuser = True
return user # pragma: no cover

View File

@@ -459,6 +459,8 @@ SOCIALACCOUNT_AUTO_SIGNUP = __get_boolean("PAPERLESS_SOCIAL_AUTO_SIGNUP")
SOCIALACCOUNT_PROVIDERS = json.loads(
os.getenv("PAPERLESS_SOCIALACCOUNT_PROVIDERS", "{}"),
)
SOCIALACCOUNT_ADMIN_GROUP = os.getenv("PAPERLESS_SOCIALACCOUNT_ADMIN_GROUP", "admin")
SOCIALACCOUNT_ADMIN_GROUP_SCOPE = os.getenv("SOCIALACCOUNT_ADMIN_GROUP_SCOPE", "groups")
ACCOUNT_EMAIL_SUBJECT_PREFIX = "[Paperless-ngx] "