Skip to content

Commit aa30309

Browse files
committed
[feature] Added OPENWISP_USERS_SOCIALACCOUNT_ADMIN_NEEDED #501
Closes #501
1 parent a894090 commit aa30309

2 files changed

Lines changed: 34 additions & 8 deletions

File tree

docs/user/settings.rst

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,31 @@ items is enabled or not.
2727

2828
Refer to :ref:`organization_owners` for more information.
2929

30+
``OPENWISP_USERS_SOCIALACCOUNT_ADMIN_NEEDED``
31+
---------------------------------------------
32+
33+
============ =========================================
34+
**type**: ``boolean``
35+
**default**: auto-detected based on ``INSTALLED_APPS``
36+
============ =========================================
37+
38+
Controls whether the social account admin (used to manage OAuth/SAML
39+
application credentials such as client IDs and secrets) is shown in the
40+
Django admin.
41+
42+
By default, this is set to ``True`` automatically when any app whose name
43+
starts with ``allauth.socialaccount.providers.`` is found in
44+
``INSTALLED_APPS``.
45+
46+
Set this to ``True`` explicitly when using custom or third-party allauth
47+
provider apps that do not follow the ``allauth.socialaccount.providers.*``
48+
namespace convention, so that their ``SocialApp`` credentials can be
49+
managed in the Django admin.
50+
51+
.. code-block:: python
52+
53+
OPENWISP_USERS_SOCIALACCOUNT_ADMIN_NEEDED = True
54+
3055
.. _openwisp_users_auth_api:
3156

3257
``OPENWISP_USERS_AUTH_API``

openwisp_users/settings.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,12 @@
5050
),
5151
)
5252

53-
# if OAuth/SAML is enabled, allow manging keys/secrets
54-
if any(
55-
app.startswith("allauth.socialaccount.providers") for app in settings.INSTALLED_APPS
56-
): # pragma: no cover
57-
SOCIALACCOUNT_ADMIN_NEEDED = True
58-
# otherwise hide the socialaccount admin (not needed)
59-
else:
60-
SOCIALACCOUNT_ADMIN_NEEDED = False
53+
# if any OAuth/SAML provider is enabled, allow managing keys/secrets
54+
SOCIALACCOUNT_ADMIN_NEEDED = getattr(
55+
settings,
56+
"OPENWISP_USERS_SOCIALACCOUNT_ADMIN_NEEDED",
57+
any(
58+
app.startswith("allauth.socialaccount.providers.")
59+
for app in settings.INSTALLED_APPS
60+
),
61+
)

0 commit comments

Comments
 (0)