mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-07-08 19:42:48 +00:00
SEC-581: Copy authentication details to CAS result token
This commit is contained in:
parent
be62979a01
commit
985818ae2c
@ -122,6 +122,7 @@ public class CasAuthenticationProvider implements AuthenticationProvider, Initia
|
|||||||
|
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
result = this.authenticateNow(authentication);
|
result = this.authenticateNow(authentication);
|
||||||
|
result.setDetails(authentication.getDetails());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stateless) {
|
if (stateless) {
|
||||||
@ -132,8 +133,7 @@ public class CasAuthenticationProvider implements AuthenticationProvider, Initia
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private CasAuthenticationToken authenticateNow(Authentication authentication)
|
private CasAuthenticationToken authenticateNow(Authentication authentication) throws AuthenticationException {
|
||||||
throws AuthenticationException {
|
|
||||||
// Validate
|
// Validate
|
||||||
TicketResponse response = ticketValidator.confirmTicketValid(authentication.getCredentials().toString());
|
TicketResponse response = ticketValidator.confirmTicketValid(authentication.getCredentials().toString());
|
||||||
|
|
||||||
|
@ -73,6 +73,7 @@ public class CasAuthenticationProviderTests {
|
|||||||
|
|
||||||
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(CasProcessingFilter.CAS_STATEFUL_IDENTIFIER,
|
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(CasProcessingFilter.CAS_STATEFUL_IDENTIFIER,
|
||||||
"ST-123");
|
"ST-123");
|
||||||
|
token.setDetails("details");
|
||||||
|
|
||||||
Authentication result = cap.authenticate(token);
|
Authentication result = cap.authenticate(token);
|
||||||
|
|
||||||
@ -92,6 +93,7 @@ public class CasAuthenticationProviderTests {
|
|||||||
assertEquals(new GrantedAuthorityImpl("ROLE_A"), casResult.getAuthorities()[0]);
|
assertEquals(new GrantedAuthorityImpl("ROLE_A"), casResult.getAuthorities()[0]);
|
||||||
assertEquals(new GrantedAuthorityImpl("ROLE_B"), casResult.getAuthorities()[1]);
|
assertEquals(new GrantedAuthorityImpl("ROLE_B"), casResult.getAuthorities()[1]);
|
||||||
assertEquals(cap.getKey().hashCode(), casResult.getKeyHash());
|
assertEquals(cap.getKey().hashCode(), casResult.getKeyHash());
|
||||||
|
assertEquals("details", casResult.getDetails());
|
||||||
|
|
||||||
// Now confirm the CasAuthenticationToken is automatically re-accepted.
|
// Now confirm the CasAuthenticationToken is automatically re-accepted.
|
||||||
// To ensure TicketValidator not called again, set it to deliver an exception...
|
// To ensure TicketValidator not called again, set it to deliver an exception...
|
||||||
@ -115,6 +117,7 @@ public class CasAuthenticationProviderTests {
|
|||||||
|
|
||||||
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(CasProcessingFilter.CAS_STATELESS_IDENTIFIER,
|
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(CasProcessingFilter.CAS_STATELESS_IDENTIFIER,
|
||||||
"ST-456");
|
"ST-456");
|
||||||
|
token.setDetails("details");
|
||||||
|
|
||||||
Authentication result = cap.authenticate(token);
|
Authentication result = cap.authenticate(token);
|
||||||
|
|
||||||
@ -127,6 +130,7 @@ public class CasAuthenticationProviderTests {
|
|||||||
|
|
||||||
assertEquals(makeUserDetailsFromAuthoritiesPopulator(), result.getPrincipal());
|
assertEquals(makeUserDetailsFromAuthoritiesPopulator(), result.getPrincipal());
|
||||||
assertEquals("ST-456", result.getCredentials());
|
assertEquals("ST-456", result.getCredentials());
|
||||||
|
assertEquals("details", result.getDetails());
|
||||||
|
|
||||||
// Now try to authenticate again. To ensure TicketValidator not
|
// Now try to authenticate again. To ensure TicketValidator not
|
||||||
// called again, set it to deliver an exception...
|
// called again, set it to deliver an exception...
|
||||||
|
Loading…
x
Reference in New Issue
Block a user