mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-16 04:28:17 -06:00
Begin work on SAML2 Authentication
This commit is contained in:
parent
6f5c35c278
commit
e4f43f0038
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,6 +1,7 @@
|
|||||||
*.pyc
|
*.pyc
|
||||||
/netbox/netbox/configuration.py
|
/netbox/netbox/configuration.py
|
||||||
/netbox/netbox/ldap_config.py
|
/netbox/netbox/ldap_config.py
|
||||||
|
/netbox/netbox/saml_config.py
|
||||||
/netbox/reports/*
|
/netbox/reports/*
|
||||||
!/netbox/reports/__init__.py
|
!/netbox/reports/__init__.py
|
||||||
/netbox/static
|
/netbox/static
|
||||||
|
@ -108,6 +108,27 @@ if LDAP_CONFIGURED:
|
|||||||
"netbox/ldap_config.py to disable LDAP."
|
"netbox/ldap_config.py to disable LDAP."
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Attempt to import SAML configuration if it has been defined = False
|
||||||
|
try:
|
||||||
|
from netbox.saml_config import *
|
||||||
|
SAML_CONFIGURED = True
|
||||||
|
except ImportError:
|
||||||
|
SAML_CONFIGURED = False
|
||||||
|
|
||||||
|
# SAML configuration (optional)
|
||||||
|
if SAML_CONFIGURED:
|
||||||
|
try:
|
||||||
|
import django_saml2_auth
|
||||||
|
# Enable logging for django_auth_ldap
|
||||||
|
saml_logger = logging.getLogger('django_auth_saml')
|
||||||
|
saml_logger.addHandler(logging.StreamHandler())
|
||||||
|
saml_logger.setLevel(logging.DEBUG)
|
||||||
|
except ImportError:
|
||||||
|
raise ImproperlyConfigured(
|
||||||
|
"SAML authentication has been configured, but django_saml2_auth is not installed. You can remove "
|
||||||
|
"netbox/saml_config.py to disable SAML."
|
||||||
|
)
|
||||||
|
|
||||||
# Database
|
# Database
|
||||||
configuration.DATABASE.update({'ENGINE': 'django.db.backends.postgresql'})
|
configuration.DATABASE.update({'ENGINE': 'django.db.backends.postgresql'})
|
||||||
DATABASES = {
|
DATABASES = {
|
||||||
@ -175,6 +196,10 @@ INSTALLED_APPS = [
|
|||||||
if WEBHOOKS_ENABLED:
|
if WEBHOOKS_ENABLED:
|
||||||
INSTALLED_APPS.append('django_rq')
|
INSTALLED_APPS.append('django_rq')
|
||||||
|
|
||||||
|
# Only load django_saml2_auth if it is configured
|
||||||
|
if SAML_CONFIGURED:
|
||||||
|
INSTALLED_APPS.append('django_saml2_auth')
|
||||||
|
|
||||||
# Middleware
|
# Middleware
|
||||||
MIDDLEWARE = (
|
MIDDLEWARE = (
|
||||||
'debug_toolbar.middleware.DebugToolbarMiddleware',
|
'debug_toolbar.middleware.DebugToolbarMiddleware',
|
||||||
|
@ -67,6 +67,12 @@ if settings.WEBHOOKS_ENABLED:
|
|||||||
url(r'^admin/webhook-backend-status/', include('django_rq.urls')),
|
url(r'^admin/webhook-backend-status/', include('django_rq.urls')),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
if settings.SAML_CONFIGURED:
|
||||||
|
import django_saml2_auth.views
|
||||||
|
_patterns += [
|
||||||
|
url(r'^saml2_auth/', include('django_saml2_auth.urls')),
|
||||||
|
]
|
||||||
|
|
||||||
if settings.DEBUG:
|
if settings.DEBUG:
|
||||||
import debug_toolbar
|
import debug_toolbar
|
||||||
_patterns += [
|
_patterns += [
|
||||||
|
Loading…
Reference in New Issue
Block a user