Merge pull request #261 from kberzinch/master

Add login attempt events to Atlassian integration
This commit is contained in:
Misagh Moayyed 2019-04-11 01:16:55 -07:00 committed by GitHub
commit db0b8f8a42
1 changed files with 9 additions and 6 deletions

View File

@ -60,19 +60,22 @@ public final class ConfluenceCasAuthenticator extends ConfluenceAuthenticator {
final Assertion assertion = (Assertion) session.getAttribute(AbstractCasFilter.CONST_CAS_ASSERTION);
if (assertion != null) {
final Principal p = getUser(assertion.getPrincipal().getName());
final String username = assertion.getPrincipal().getName();
final Principal user = getUser(username);
// user doesn't exist
if (p == null) {
// user doesn't exist
if (user == null) {
LOGGER.error("Could not determine principal for [{}]", assertion.getPrincipal().getName());
getElevatedSecurityGuard().onFailedLoginAttempt(request, username);
return null;
}
LOGGER.debug("Logging in [{}] from CAS.", p.getName());
LOGGER.debug("Logging in [{}] from CAS.", username);
session.setAttribute(LOGGED_IN_KEY, p);
getElevatedSecurityGuard().onSuccessfulLoginAttempt(request, username);
session.setAttribute(LOGGED_IN_KEY, user);
session.setAttribute(LOGGED_OUT_KEY, null);
return p;
return user;
}
return super.getUser(request, response);