-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Dictionary style settings for shibboleth configuration * Implement a parser for shib2 encoded multivalue fields. * Parse only a single student number, based on a config value * Authentication backend is rewritten, but should be more robust and handle problems better than before. e.g. before, oo long input values were just cut, and thus multiple different inputs might have resulted same output. Now we raise errors instead and require someone to fix the actual problem. * Better debug output.. So we can actually find out these problems :)
- Loading branch information
Showing
11 changed files
with
675 additions
and
169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import re | ||
|
||
from django.apps import AppConfig | ||
from django_settingsdict import SettingsDict | ||
|
||
|
||
class AplusShibbolethLoginConfig(AppConfig): | ||
name = 'shibboleth_login' | ||
verbose_name = 'A+ Shibboleth Login' | ||
|
||
|
||
def _only_prefix(value, env): | ||
return re.sub(r'^((?:HTTP_)?[^_-]+[_-]).*$', r'\1', value) | ||
|
||
|
||
def _drop_prefix(value, env): | ||
prefix = env.get('PREFIX', '') | ||
if value.startswith(prefix): | ||
return value[len(prefix):] | ||
return value | ||
|
||
|
||
app_settings = SettingsDict( | ||
'SHIBBOLETH_LOGIN', | ||
defaults={ | ||
'ALLOW_CREATE_NEW_USERS': True, | ||
'ALLOW_SEARCH_WITH_EMAIL': False, | ||
}, | ||
) | ||
|
||
|
||
env_settings = SettingsDict( | ||
'SHIBBOLETH_ENVIRONMENT_VARS', | ||
required=[ | ||
# This is typically SHIB_ for Apache 2 and | ||
# HTTP_SHIB_ for nginx with http roxy | ||
'PREFIX', | ||
# Domain where student numbers are valid | ||
# NOTE: this is temporary, until A+ supports multiple domains | ||
'STUDENT_DOMAIN', | ||
], | ||
defaults={ | ||
'USER_ID': 'eppn', | ||
'FIRST_NAME': 'givenName', | ||
'LAST_NAME': 'sn', | ||
'COMMON_NAME': 'cn', | ||
'FULL_NAME': 'displayName', | ||
'EMAIL': 'mail', | ||
'LANGUAGE': 'preferredLanguage', | ||
# student values are based on Haka Federation | ||
# https://wiki.eduuni.fi/display/CSCHAKA/Federation | ||
'STUDENT_IDS': 'schacPersonalUniqueCode', | ||
'STUDENT_URN': ':schac:personalUniqueCode:', | ||
'STUDENT_FILTERS': { | ||
2: 'studentID', | ||
3: 'int', | ||
}, | ||
'URL_DECODE': True, | ||
}, | ||
migrate=[ | ||
# new name, old name, migration script | ||
('PREFIX', 'SHIB_USER_ID_KEY', _only_prefix), | ||
('USER_ID', 'SHIB_USER_ID_KEY', _drop_prefix), | ||
('FIRST_NAME', 'SHIB_FIRST_NAME_KEY', _drop_prefix), | ||
('LAST_NAME', 'SHIB_LAST_NAME_KEY', _drop_prefix), | ||
('EMAIL', 'SHIB_MAIL_KEY', _drop_prefix), | ||
('STUDENT_IDS', 'SHIB_STUDENT_ID_KEY', _drop_prefix), | ||
('URL_DECODE', 'SHIBBOLETH_VARIABLES_URL_ENCODED'), | ||
], | ||
) |
Oops, something went wrong.