Remove jwt validation for jschorr to fix later

Refactor oauth validate method to take config over entire appconfig
This commit is contained in:
Sam Chow 2018-06-01 11:31:19 -04:00
parent 7df8ed4a60
commit 301cc6992a
27 changed files with 136 additions and 76 deletions

View file

@ -6,7 +6,6 @@ import urlparse
from abc import ABCMeta, abstractmethod
from six import add_metaclass
from util import get_app_url
from util.config import URLSchemeAndHostname
logger = logging.getLogger(__name__)
@ -74,7 +73,7 @@ class OAuthService(object):
pass
@abstractmethod
def validate_client_id_and_secret(self, http_client, app_config):
def validate_client_id_and_secret(self, http_client, url_scheme_and_hostname):
""" Performs validation of the client ID and secret, raising an exception on failure. """
pass
@ -99,9 +98,10 @@ class OAuthService(object):
"""
return self.config.get('LOGIN_BINDING_FIELD', None)
def get_auth_url(self, app_config, redirect_suffix, csrf_token, scopes):
def get_auth_url(self, url_scheme_and_hostname, redirect_suffix, csrf_token, scopes):
""" Retrieves the authorization URL for this login service. """
redirect_uri = '%s/oauth2/%s/callback%s' % (get_app_url(app_config), self.service_id(),
redirect_uri = '%s/oauth2/%s/callback%s' % (url_scheme_and_hostname.get_url(),
self.service_id(),
redirect_suffix)
params = {
'client_id': self.client_id(),
@ -154,7 +154,7 @@ class OAuthService(object):
def exchange_code(self, app_config, http_client, code, form_encode=False, redirect_suffix='',
client_auth=False):
""" Exchanges an OAuth access code for associated OAuth token and other data. """
url_scheme_and_hostname = URLSchemeAndHostname(app_config['PREFERRED_URL_SCHEME'], app_config['SERVER_HOSTNAME'])
url_scheme_and_hostname = URLSchemeAndHostname.from_app_config(app_config)
payload = {
'code': code,
'grant_type': 'authorization_code',