Skip to content

Commit

Permalink
Configure Social Login Buttons to work with SAML
Browse files Browse the repository at this point in the history
  • Loading branch information
sdc50 committed Mar 21, 2024
1 parent 85f8e74 commit 4bb9d03
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions scripts/mkaliases.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ echo "alias tso=tethys_server_own" >> "${ACTIVATE_SCRIPT}"
echo "alias cs='tuo; tethys manage collectstatic; tso;'" >> "${ACTIVATE_SCRIPT}"
echo "alias tsr='tso; sudo systemctl restart supervisord'" >> "${ACTIVATE_SCRIPT}"
# Add lines that remove the aliases to the deactivate Script
echo "unset TETHYS_HOME" > "${DEACTIVATE_SCRIPT}"
echo "unalias vipc" > "${DEACTIVATE_SCRIPT}"
echo "unalias tethys_user_own" > "${DEACTIVATE_SCRIPT}"
echo "unalias tuo" >> "${DEACTIVATE_SCRIPT}"
Expand Down
3 changes: 3 additions & 0 deletions tethys_portal/context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
"""

from .optional_dependencies import has_module
from django.conf import settings


def tethys_portal_context(request):
idps = settings.SOCIAL_AUTH_SAML_ENABLED_IDPS if hasattr(settings, 'SOCIAL_AUTH_SAML_ENABLED_IDPS') else {}
context = {
"has_analytical": has_module("analytical"),
"has_recaptcha": has_module("snowpenguin.django.recaptcha2"),
Expand All @@ -20,6 +22,7 @@ def tethys_portal_context(request):
"has_gravatar": has_module("django_gravatar"),
"has_session_security": has_module("session_security"),
"has_oauth2_provider": has_module("oauth2_provider"),
"idp_backends": idps.keys(),
}

return context
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@
<a class="btn btn-block btn-social btn-onelogin" href="{% url 'social:begin' backend %}{% if request.GET.next %}?next={{request.GET.next|urlencode}}{% endif %}">
<i class="bi bi-onelogin"></i> {{ action }} with OneLogin
</a>
{% elif 'saml' in backend %}
{% for idp in idp_backends %}
<a class="btn btn-block btn-social btn-saml" href="{% url 'social:begin' backend %}?idp={{ idp }}{% if request.GET.next %}&next={{request.GET.next|urlencode}}{% endif %}">
<i class="bi bi-box-arrow-in-left"></i> {{ action }} through {{ idp }} with SAML
</a>
{% endfor %}
{% else %}
<a class="btn btn-block btn-social btn-custom-oauth" href="{% url 'social:begin' backend %}{% if request.GET.next %}?next={{request.GET.next|urlencode}}{% endif %}">
<i class="bi bi-unlock-fill"></i> {{ action }} with {{ backend }}
Expand Down

0 comments on commit 4bb9d03

Please sign in to comment.