SAML Configuration
Open-Source DefectDojo supports SAML authentication via environment variables. DefectDojo Pro users should refer to the Pro SAML guide.
Setup
Navigate to your SAML Identity Provider and locate your metadata.
Set the following as environment variables, or without the
DD_prefix in yourlocal_settings.pyfile (see Configuration):DD_SAML2_ENABLED=(bool, True), # Login button text shown on the DefectDojo login page DD_SAML2_LOGIN_BUTTON_TEXT=(str, 'Login with SAML'), # If the metadata is accessible from a URL: DD_SAML2_METADATA_AUTO_CONF_URL=(str, 'https://your_IdP.com/metadata.xml'), # Otherwise, download the metadata as an XML file and set the path: DD_SAML2_METADATA_LOCAL_FILE_PATH=(str, '/path/to/your/metadata.xml'), # Map SAML assertion attributes to DefectDojo user fields: DD_SAML2_ATTRIBUTES_MAP=(dict, { # Format: 'SAML attribute': 'django_user_field' 'Email': 'email', 'UserName': 'username', 'Firstname': 'first_name', 'Lastname': 'last_name' }),Note: In Kubernetes,
DD_SAML2_ATTRIBUTES_MAPcan be set inextraConfigas:DD_SAML2_ATTRIBUTES_MAP: 'Email'='email', 'Username'='username'...Note:
DD_SITE_URLmay also need to be set depending on whether you use a metadata URL or a local file.Review the SAML section in
dojo/settings/settings.dist.pyto verify the configuration matches your requirements. See the djangosaml2 plugin documentation for further options.Restart DefectDojo. A Login with SAML button will appear on the login page.
Note: If your IdP uses a self-signed certificate, set the REQUESTS_CA_BUNDLE environment variable to the path of your private CA certificate.
Advanced Configuration
The djangosaml2 plugin supports many additional options. All DefectDojo defaults can be overridden in local_settings.py. For example, to customize the organization name:
if SAML2_ENABLED:
SAML_CONFIG['contact_person'] = [{
'given_name': 'Extra',
'sur_name': 'Example',
'company': 'DefectDojo',
'email_address': 'dummy@defectdojo.com',
'contact_type': 'technical'
}]
SAML_CONFIG['organization'] = {
'name': [('DefectDojo', 'en')],
'display_name': [('DefectDojo', 'en')],
},Troubleshooting
The SAML Tracer browser extension can help debug SAML issues: Chrome, Firefox.
Migrating from django-saml2-auth
Prior to release 1.15.0, SAML was handled by django-saml2-auth. The following parameters changed with the switch to djangosaml2:
| Old parameter | Status |
|---|---|
DD_SAML2_ASSERTION_URL | No longer needed — auto-generated |
DD_SAML2_DEFAULT_NEXT_URL | No longer needed — default forwarding is used |
DD_SAML2_NEW_USER_PROFILE | No longer supported — default profile is used |
DD_SAML2_ATTRIBUTES_MAP | Syntax has changed |
DD_SAML2_CREATE_USER | Default changed to False to prevent security issues |