Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@ public void onLoginSuccess(HttpServletRequest request, HttpServletResponse respo
}
if (!StringUtils.hasLength(password)) {
UserDetails user = getUserDetailsService().loadUserByUsername(username);
Assert.notNull(user, () -> "UserDetailsService " + getUserDetailsService() + " returned null for username "
+ username + ". " + "This is an interface contract violation");
password = user.getPassword();
if (!StringUtils.hasLength(password)) {
this.logger.debug("Unable to obtain password for user: " + username);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,20 @@ public void loginSuccessIgnoredIfParameterNotSetOrFalse() {
assertThat(cookie).isNull();
}

@Test
public void loginSuccessFailsIfUserServiceMisconfigured() {
udsWillReturnNull();
MockHttpServletRequest request = new MockHttpServletRequest();
request.addParameter(AbstractRememberMeServices.DEFAULT_PARAMETER, "true");
MockHttpServletResponse response = new MockHttpServletResponse();
// the token carries no credentials, so the password is looked up via the
// UserDetailsService
Authentication authentication = new TestingAuthenticationToken("someone", null, "ROLE_ABC");
assertThatIllegalArgumentException()
.isThrownBy(() -> this.services.loginSuccess(request, response, authentication))
.withMessageContaining("interface contract violation");
}

@Test
public void loginSuccessNormalWithNonUserDetailsBasedPrincipalSetsExpectedCookie() {
// SEC-822
Expand Down
Loading