Skip to content

Commit

Permalink
feat(saml): configurable login button (#5449)
Browse files Browse the repository at this point in the history
  • Loading branch information
alles-klar authored Nov 16, 2021
1 parent 7e640cb commit 06cff01
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
5 changes: 3 additions & 2 deletions docs/content/en/integrations/social-authentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,8 @@ homepage](https://github.com/IdentityPython/djangosaml2).

{{< highlight python >}}
DD_SAML2_ENABLED=(bool, **True**),
# SAML Login Button Text
DD_SAML2_LOGIN_BUTTON_TEXT=(str, 'Login with SAML'),
# If the metadata can be accessed from a url, try the
DD_SAML2_METADATA_AUTO_CONF_URL=(str, '<https://your_IdP.com/metadata.xml>'),
# Otherwise, downlaod a copy of the metadata into an xml file, and
Expand All @@ -263,8 +265,7 @@ NOTE: *DD_SAML2_ATTRIBUTES_MAP* in k8s can be referenced as extraConfig (e.g. `D
4. Checkout the SAML section in dojo/`dojo/settings/settings.dist.py` and verfiy if it fits your requirement. If you need help, take a look at the [plugin
documentation](https://djangosaml2.readthedocs.io/contents/setup.html#configuration).

5. Restart DefectDojo, and you should now see a **Login with SAML**
button on the login page.
5. Restart DefectDojo, and you should now see a **Login with SAML** button (default setting of DD_SAML2_LOGIN_BUTTON_TEXT) on the login page.

NOTE: In the case when IDP is configured to use self signed (private) certificate,
than CA needs to be specified by define environments variable
Expand Down
1 change: 1 addition & 0 deletions dojo/context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def globalize_oauth_vars(request):
'GITLAB_ENABLED': settings.GITLAB_OAUTH2_ENABLED,
'AZUREAD_TENANT_OAUTH2_ENABLED': settings.AZUREAD_TENANT_OAUTH2_ENABLED,
'SAML2_ENABLED': settings.SAML2_ENABLED,
'SAML2_LOGIN_BUTTON_TEXT': settings.SAML2_LOGIN_BUTTON_TEXT,
'SAML2_LOGOUT_URL': settings.SAML2_LOGOUT_URL}


Expand Down
2 changes: 2 additions & 0 deletions dojo/settings/settings.dist.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
DD_SOCIAL_AUTH_GITLAB_API_URL=(str, 'https://gitlab.com'),
DD_SOCIAL_AUTH_GITLAB_SCOPE=(list, ['api', 'read_user', 'openid', 'profile', 'email']),
DD_SAML2_ENABLED=(bool, False),
DD_SAML2_LOGIN_BUTTON_TEXT=(str, 'Login with SAML'),
# Optional: display the idp SAML Logout URL in DefectDojo
DD_SAML2_LOGOUT_URL=(str, ''),
# Metadata is required for SAML, choose either remote url or local file path
Expand Down Expand Up @@ -759,6 +760,7 @@ def saml2_attrib_map_format(dict):


SAML2_ENABLED = env('DD_SAML2_ENABLED')
SAML2_LOGIN_BUTTON_TEXT = env('DD_SAML2_LOGIN_BUTTON_TEXT')
SAML2_LOGOUT_URL = env('DD_SAML2_LOGOUT_URL')
if SAML2_ENABLED:
import saml2
Expand Down
2 changes: 1 addition & 1 deletion dojo/templates/dojo/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ <h3>Login</h3>
{% if SAML2_ENABLED is True %}
<div class="col-sm-offset-1 col-sm-2">
<button class="btn btn-success" type="button">
<a id="oauth-login-saml" rel="nofollow" data-method="post" href="/saml2/login" style="color: rgb(255,255,255)">Login with SAML</a>
<a id="oauth-login-saml" rel="nofollow" data-method="post" href="/saml2/login" style="color: rgb(255,255,255)">{{ SAML2_LOGIN_BUTTON_TEXT }}</a>
</button>
</div>
{% endif %}
Expand Down

0 comments on commit 06cff01

Please sign in to comment.