Note that this will still not work on the client side; the followup CL for the client side is right after this one.
24 lines
915 B
Python
24 lines
915 B
Python
from oauth.services.github import GithubOAuthService
|
|
from oauth.services.google import GoogleOAuthService
|
|
from oauth.oidc import OIDCLoginService
|
|
|
|
CUSTOM_LOGIN_SERVICES = {
|
|
'GITHUB_LOGIN_CONFIG': GithubOAuthService,
|
|
'GOOGLE_LOGIN_CONFIG': GoogleOAuthService,
|
|
}
|
|
|
|
class OAuthLoginManager(object):
|
|
""" Helper class which manages all registered OAuth login services. """
|
|
def __init__(self, config):
|
|
self.services = []
|
|
|
|
# Register the endpoints for each of the OAuth login services.
|
|
for key in config.keys():
|
|
# All keys which end in _LOGIN_CONFIG setup a login service.
|
|
if key.endswith('_LOGIN_CONFIG'):
|
|
if key in CUSTOM_LOGIN_SERVICES:
|
|
custom_service = CUSTOM_LOGIN_SERVICES[key](config, key)
|
|
if custom_service.login_enabled(config):
|
|
self.services.append(custom_service)
|
|
else:
|
|
self.services.append(OIDCLoginService(config, key))
|