Skip to content

Commit

Permalink
added more verbose logging around failed SAML and OAuth2 requests
Browse files Browse the repository at this point in the history
  • Loading branch information
albogdano committed Jun 23, 2021
1 parent 4ffce90 commit d153b34
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,8 @@ private Map<String, Object> fetchProfileFromIDP(App app, String accessToken, Str
profile = jreader.readValue(respEntity.getContent());
}
if (profile == null || profile.isEmpty()) {
LOG.error("OAuth 2 provider did not return any valid user information - response code {} {}",
resp2.getStatusLine().getStatusCode(), resp2.getStatusLine().getReasonPhrase());
LOG.error("OAuth 2 provider did not return any valid user information - response code {} {}, app '{}'",
resp2.getStatusLine().getStatusCode(), resp2.getStatusLine().getReasonPhrase(), app.getId());
}
EntityUtils.consumeQuietly(respEntity);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ public Authentication attemptAuthentication(HttpServletRequest request, HttpServ
appid = Config.getRootAppIdentifier();
}
}
boolean samlSettingsLoaded = false;
try {
App app = Para.getDAO().read(App.id(appid == null ? Config.getRootAppIdentifier() : appid));
if (app != null) {
Expand All @@ -128,6 +129,7 @@ public Authentication attemptAuthentication(HttpServletRequest request, HttpServ

Auth auth = new Auth(settings, request, response);

samlSettingsLoaded = true;
if (request.getParameter("SAMLResponse") != null) {
auth.processResponse();
if (auth.isAuthenticated()) {
Expand All @@ -151,6 +153,10 @@ public Authentication attemptAuthentication(HttpServletRequest request, HttpServ
LOG.error("Invalid SAML certificate key for app '{}': {}", appid, ex.getMessage());
} catch (Exception ex) {
LOG.error("Failed to authenticate app '" + appid + "' with SAML: ", ex);
} finally {
if (!samlSettingsLoaded) {
LOG.error("Failed to load SAML certificate for app '{}', check the format and encoding.");
}
}
}

Expand Down

0 comments on commit d153b34

Please sign in to comment.