--- a/server/src/metaeducation/auth.py Mon Mar 14 14:35:10 2016 +0100
+++ b/server/src/metaeducation/auth.py Mon Mar 14 15:08:25 2016 +0100
@@ -29,7 +29,7 @@
return
else:
token = re.search("(?<=\s).*", request.META["HTTP_AUTHORIZATION"]).group(0)
- logger.debug("CLIENT CREDENTIAL AUTH: token is "+token)
+ logger.debug("CLIENT CREDENTIAL AUTH: token is %r", token)
# send token to Oauth server
token_validate_response = requests.get(
settings.MTDC_VALIDATE_TOKEN_BASE_URL+token+"?redirect_uri="+parse.quote_plus(settings.MTDC_GED_BASE_URL)
@@ -37,6 +37,6 @@
if token_validate_response.status_code != 200:
logger.debug("CLIENT CREDENTIAL AUTH: token validate failed, abort")
return
- logger.debug("CLIENT CREDENTIAL AUTH: user "+external_id+" is authenticated by token "+token+", auth success")
+ logger.debug("CLIENT CREDENTIAL AUTH: user %r is authenticated by token %r, auth success", external_id, token)
return (user, None)
--- a/server/src/metaeducation/middleware.py Mon Mar 14 14:35:10 2016 +0100
+++ b/server/src/metaeducation/middleware.py Mon Mar 14 15:08:25 2016 +0100
@@ -23,7 +23,7 @@
if request.GET.get("context", ""):
context = request.GET["context"]
response = redirect(settings.LOGIN_URL)
- logger.debug("LOGIN_REQUIRED: will redirect to "+settings.LOGIN_URL)
- logger.debug("LOGIN_REQUIRED: query args will be "+str({"context": context, "next": settings.BASE_URL+path}))
+ logger.debug("LOGIN_REQUIRED: will redirect to %r", settings.LOGIN_URL)
+ logger.debug("LOGIN_REQUIRED: query args will be %r", {"context": context, "next": settings.BASE_URL+path})
response["LOCATION"] += "?"+urlencode({"context": context, "next": settings.BASE_URL+path})
return response
--- a/server/src/metaeducation/mtdc_oauth_provider/views.py Mon Mar 14 14:35:10 2016 +0100
+++ b/server/src/metaeducation/mtdc_oauth_provider/views.py Mon Mar 14 15:08:25 2016 +0100
@@ -45,35 +45,35 @@
if request.session.get("OAUTH_CONTEXT_BASE_URL", None) is None:
logger.debug("AUTHORIZATION CODE AUTH: no context in session, storing context")
request.session["OAUTH_CONTEXT_BASE_URL"] = request.GET.get("context", None)
- logger.debug("AUTHORIZATION CODE AUTH: context queryarg is "+request.GET.get("context", None))
+ logger.debug("AUTHORIZATION CODE AUTH: context queryarg is %r", request.GET.get("context", None))
self.oauth_base_url = request.session.get("OAUTH_CONTEXT_BASE_URL", None)
- logger.debug("AUTHORIZATION CODE AUTH: context is "+self.oauth_base_url)
+ logger.debug("AUTHORIZATION CODE AUTH: context is %r", self.oauth_base_url)
self.access_token_url = self.oauth_base_url + settings.MTDC_ACCESS_TOKEN_URL
self.authorize_url = self.oauth_base_url + settings.MTDC_AUTHORIZE_URL
self.profile_url = self.oauth_base_url + settings.MTDC_PROFILE_URL
def pre_social_login(self, request, sociallogin):
try:
- logger.debug("AUTHORIZATION CODE AUTH: login almost complete, checking if user exists")
+ logger.debug("AUTHORIZATION CODE AUTH: login almost complete, checking if user %r exists", sociallogin.account.extra_data.get('external_id', 'NO_ID'))
user = get_user_model().objects.get(external_id=sociallogin.account.extra_data.get('external_id', '')) # if user exists, connect the account to the existing account and login
- logger.debug("AUTHORIZATION CODE AUTH: user exists, connecting to existing account")
+ logger.debug("AUTHORIZATION CODE AUTH: user %r exists, connecting to existing account", sociallogin.account.extra_data.get('external_id', 'NO_ID'))
sociallogin.state['process'] = 'connect'
perform_login(request, user, 'none')
except get_user_model().DoesNotExist:
- logger.debug("AUTHORIZATION CODE AUTH: user does not exist")
+ logger.debug("AUTHORIZATION CODE AUTH: user %r does not exist", sociallogin.account.extra_data.get('external_id', 'NO_ID'))
def get_login_redirect_url(self, request):
return super(MtdcOAuth2Adapter, self).get_login_redirect_url(self, request)
def new_user(self, request, sociallogin):
if 'username' in sociallogin.account.extra_data:
- logger.debug("AUTHORIZATION CODE AUTH: checking if user exists to populate sociallogin")
- user_queryset = get_user_model().objects.filter(external_id=sociallogin.account.extra_data['external_id'], username=sociallogin.account.extra_data['username'])
+ logger.debug("AUTHORIZATION CODE AUTH: checking if user %r exists to populate sociallogin", sociallogin.account.extra_data.get('external_id', 'NO_ID'))
+ user_queryset = get_user_model().objects.filter(external_id=sociallogin.account.extra_data.get('external_id', ''), username=sociallogin.account.extra_data['username'])
if user_queryset.exists():
- logger.debug("AUTHORIZATION CODE AUTH: user exists")
+ logger.debug("AUTHORIZATION CODE AUTH: user %r exists", sociallogin.account.extra_data.get('external_id', 'NO_ID'))
user = user_queryset.first()
else:
- logger.debug("AUTHORIZATION CODE AUTH: user does not exist, creating new user and populating")
+ logger.debug("AUTHORIZATION CODE AUTH: user %r does not exist, creating new user and populating", sociallogin.account.extra_data.get('external_id', 'NO_ID'))
user = get_user_model()()
user.username = sociallogin.account.extra_data.get('username', '')
user.external_id = sociallogin.account.extra_data.get('external_id', '')
@@ -101,7 +101,7 @@
params={'access_token': token.token})
extra_data = resp.json()
- logger.debug("AUTHORIZATION CODE AUTH: response extra_data: "+str(extra_data))
+ logger.debug("AUTHORIZATION CODE AUTH: response extra_data: %r ", extra_data)
if request.session.get("OAUTH_CONTEXT_BASE_URL", None) is not None:
del request.session["OAUTH_CONTEXT_BASE_URL"]
return self.get_provider().sociallogin_from_response(request,
--- a/server/src/metaeducation/signals.py Mon Mar 14 14:35:10 2016 +0100
+++ b/server/src/metaeducation/signals.py Mon Mar 14 15:08:25 2016 +0100
@@ -31,8 +31,8 @@
"title": instance.title
})
resource_ws_url = settings.MTDC_REFERENCE_RESOURCE_BASE_URL# + str(instance.renkan_guid)
- logger.debug("REFERENCING RENKAN: sending reference request to: "+resource_ws_url)
- logger.debug("REFERENCING RENKAN: post_data: "+str(post_data))
+ logger.debug("REFERENCING RENKAN: sending reference request to: POST %r", resource_ws_url)
+ logger.debug("REFERENCING RENKAN: post_data: %r", post_data)
reference_response = requests.post(
resource_ws_url,
data = post_data,
@@ -41,7 +41,7 @@
"content-type": "application/json"
}
)
- logger.debug("REFERENCING RENKAN: response is "+str(reference_response.status_code))
+ logger.debug("REFERENCING RENKAN: response is %r", reference_response.status_code)
if not 'test' in sys.argv: