we need more logging and somehow some stuff is being suppressed

This commit is contained in:
Sam 2016-05-25 16:23:09 +10:00
parent 870361be98
commit 5bf30f90c2
1 changed files with 7 additions and 4 deletions

View File

@ -48,16 +48,18 @@ class OAuth2BasicAuthenticator < ::Auth::OAuth2Authenticator
end
end
def debug(info)
def log(info)
Rails.logger.warn("OAuth2 Debugging: #{info}") if SiteSetting.oauth2_debug_auth
end
def fetch_user_details(token)
user_json_url = SiteSetting.oauth2_user_json_url.sub(':token', token)
debug("user_json_url: #{user_json_url}")
log("user_json_url: #{user_json_url}")
user_json = JSON.parse(open(user_json_url, 'Authorization' => "Bearer #{token}" ).read)
debug("user_json: #{user_json}")
log("user_json: #{user_json}")
result = {}
if user_json.present?
@ -71,7 +73,8 @@ class OAuth2BasicAuthenticator < ::Auth::OAuth2Authenticator
end
def after_authenticate(auth)
debug("auth response \n\n#{auth}")
log("after_authenticate response: \n\n#{auth}")
result = Auth::Result.new
token = auth['credentials']['token']
user_details = fetch_user_details(token)