This package includes a authentication backend and an authentication middleware to integrate Django's authentication system with Atlassian Crowd.
When authenticating an user against Crowd, its nested groups are retrieved and mirrored in Django.
- To authenticate users against Crowd,
add
django_crowd_auth.backends.BackendtoAUTHENTICATION_BACKENDS. - To enable single-sign-on,
add
django_crowd_auth.middlewares.ssotoMIDDLEWARE. Ensure you also havedjango.contrib.sessions.middleware.SessionMiddlewareanddjango.contrib.auth.middleware.AuthenticationMiddlewareplaced before it. - Ensure
django.contrib.sessionsis inINSTALLED_APPS. - Add settings (see below)
Often the SSL session does not terminates directly on the Django application, but on an intermediate proxy.
This package also includes 3 middlewares that rewrites the user's
REMOTE_ADDR using header set by these proxies:
django_crowd_auth.middlewares.x_forwarded_for: OverrideREMOTE_ADDRwith the firstX-Forwarded-Forentry.django_crowd_auth.middlewares.x_real_ip: OverrideREMOTE_ADDRwith theX-Real-IPvalue.django_crowd_auth.middlewares.fake_remote_addr: OverrideREMOTE_ADDRwith theFAKE_REMOTE_ADDRsettings value.
Warning
Only use these middlewares when you KNOW what you're doing. Otherwise you could enable attackers to spoof their IP address.
Note
As the SSO middleware needs REMOTE_ADDR, these middlewares must be
declared BEFORE the SSO middleware.
CROWD_CLIENT: must be a dict with these keys:crowd_url: mandatoryapp_name: mandatoryapp_pass: mandatoryssl_verify: defaults toTrue. Also accepts a path to a CA bundle.timeout: no timeout by defaultclient_cert
CROWD_USERS_ARE_ACTIVE: Defaults toTrue. IfTrue, set theis_activeuser model attribute toTruewhen creating Django users.CROWD_USERS_ARE_STAFF: Defaults toFalse. IfTrue, set theis_staffuser model attribute toTruewhen creating Django users.CROWD_SUPERUSERS_GROUP: If defined, set theis_superuseruser model attribute toTruewhen they belong to the chosen group. By side effect, these users also get theis_staffattribute set toTrue.CROWD_SESSION_VALIDATION_INTERVAL: Default to 300 seconds. The user's Crowd session is re-validated at this interval.
CROWD_CLIENT = {
'crowd_url': 'https://crowd.foo.bar',
'app_name': 'foo',
'app_pass': 'bar',
'ssl_verify': '/etc/pki/tls/certs/ca-bundle.crt',
'timeout': 10,
}
CROWD_USERS_ARE_STAFF = True
CROWD_SUPERUSERS_GROUP = 'administrators'
AUTHENTICATION_BACKENDS = ['django_crowd_auth.backends.Backend']
MIDDLEWARE = [
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django_crowd_auth.middlewares.sso',
]While users and groups are created on the fly (i.e. when they access the Django application), it is sometimes necessary to mirror Crowd users and groups in Django.
This package includes a sync_crowd management command for this purpose.
To use it, simply add django_crowd_auth to the INSTALLED_APPS.