mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-06-26 13:53:14 +00:00
added fix to preserve custom UserDetails implementations (Matt DeHoust fix recommendation)
This commit is contained in:
parent
d44b570087
commit
24394b7b2b
@ -462,7 +462,7 @@ public class SwitchUserProcessingFilter implements Filter, InitializingBean,
|
|||||||
authorities = (GrantedAuthority[]) newAuths.toArray(authorities);
|
authorities = (GrantedAuthority[]) newAuths.toArray(authorities);
|
||||||
|
|
||||||
// create the new authentication token
|
// create the new authentication token
|
||||||
targetUserRequest = new UsernamePasswordAuthenticationToken(username,
|
targetUserRequest = new UsernamePasswordAuthenticationToken(targetUser,
|
||||||
targetUser.getPassword(), authorities);
|
targetUser.getPassword(), authorities);
|
||||||
|
|
||||||
// set details
|
// set details
|
||||||
|
@ -355,7 +355,8 @@ public class SwitchUserProcessingFilterTests extends TestCase {
|
|||||||
Authentication targetAuth = SecurityContextHolder.getContext()
|
Authentication targetAuth = SecurityContextHolder.getContext()
|
||||||
.getAuthentication();
|
.getAuthentication();
|
||||||
assertNotNull(targetAuth);
|
assertNotNull(targetAuth);
|
||||||
assertEquals("jacklord", targetAuth.getPrincipal());
|
assertTrue(targetAuth.getPrincipal() instanceof UserDetails);
|
||||||
|
assertEquals("jacklord", ((User)targetAuth.getPrincipal()).getUsername());
|
||||||
}
|
}
|
||||||
|
|
||||||
private MockHttpServletRequest createMockSwitchRequest() {
|
private MockHttpServletRequest createMockSwitchRequest() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user