Mercurial > kallithea
changeset 3173:db0871d942b6 beta
adde cleanup username flag into get_container_username function
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Sat, 19 Jan 2013 16:35:06 +0100 |
parents | 264d9c930c17 |
children | 37c0ac5fe42f |
files | rhodecode/lib/auth.py |
diffstat | 1 files changed, 13 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/rhodecode/lib/auth.py Sat Jan 19 16:28:18 2013 +0100 +++ b/rhodecode/lib/auth.py Sat Jan 19 16:35:06 2013 +0100 @@ -270,7 +270,18 @@ return user -def get_container_username(environ, config): +def get_container_username(environ, config, clean_username=False): + """ + Get's the container_auth username (or email). It tries to get username + from REMOTE_USER if container_auth_enabled is enabled, if that fails + it tries to get username from HTTP_X_FORWARDED_USER if proxypass_auth_enabled + is enabled. clean_username extracts the username from this data if it's + having @ in it. + + :param environ: + :param config: + :param clean_username: + """ username = None if str2bool(config.get('container_auth_enabled', False)): @@ -282,7 +293,7 @@ username = environ.get('HTTP_X_FORWARDED_USER') log.debug('extracted HTTP_X_FORWARDED_USER:%s' % (username)) - if username: + if username and clean_username: # Removing realm and domain from username username = username.partition('@')[0] username = username.rpartition('\\')[2]