Blacklist any OIDC service ids that may conflict with our own

This commit is contained in:
Joseph Schorr 2017-02-09 12:57:09 -08:00
parent 421c5d6012
commit cc4258c015

View file

@ -1,12 +1,15 @@
from oauth.services.github import GithubOAuthService
from oauth.services.google import GoogleOAuthService
from oauth.oidc import OIDCLoginService
from data.users import UserAuthentication
CUSTOM_LOGIN_SERVICES = {
'GITHUB_LOGIN_CONFIG': GithubOAuthService,
'GOOGLE_LOGIN_CONFIG': GoogleOAuthService,
}
PREFIX_BLACKLIST = ['ldap', 'jwt', 'keystone']
class OAuthLoginManager(object):
""" Helper class which manages all registered OAuth login services. """
def __init__(self, config):
@ -21,6 +24,10 @@ class OAuthLoginManager(object):
if custom_service.login_enabled(config):
self.services.append(custom_service)
else:
prefix = key[0:len(key) - len('_LOGIN_CONFIG')].lower()
if prefix in PREFIX_BLACKLIST:
raise Exception('Cannot use reserved config name %s' % key)
self.services.append(OIDCLoginService(config, key))
def get_service(self, service_id):