|
@@ -70,15 +70,24 @@ import static org.mockito.Mockito.when;
|
|
* @author Steve Riesenberg
|
|
* @author Steve Riesenberg
|
|
*/
|
|
*/
|
|
public class OAuth2TokenExchangeAuthenticationProviderTests {
|
|
public class OAuth2TokenExchangeAuthenticationProviderTests {
|
|
- private static final Set<String> RESOURCES = Set.of("https://mydomain.com/resource1", "https://mydomain.com/resource2");
|
|
|
|
|
|
+
|
|
|
|
+ private static final Set<String> RESOURCES = Set.of("https://mydomain.com/resource1",
|
|
|
|
+ "https://mydomain.com/resource2");
|
|
|
|
+
|
|
private static final Set<String> AUDIENCES = Set.of("audience1", "audience2");
|
|
private static final Set<String> AUDIENCES = Set.of("audience1", "audience2");
|
|
|
|
+
|
|
private static final String SUBJECT_TOKEN = "EfYu_0jEL";
|
|
private static final String SUBJECT_TOKEN = "EfYu_0jEL";
|
|
|
|
+
|
|
private static final String ACTOR_TOKEN = "JlNE_xR1f";
|
|
private static final String ACTOR_TOKEN = "JlNE_xR1f";
|
|
|
|
+
|
|
private static final String ACCESS_TOKEN_TYPE_VALUE = "urn:ietf:params:oauth:token-type:access_token";
|
|
private static final String ACCESS_TOKEN_TYPE_VALUE = "urn:ietf:params:oauth:token-type:access_token";
|
|
|
|
+
|
|
private static final String JWT_TOKEN_TYPE_VALUE = "urn:ietf:params:oauth:token-type:jwt";
|
|
private static final String JWT_TOKEN_TYPE_VALUE = "urn:ietf:params:oauth:token-type:jwt";
|
|
|
|
|
|
private OAuth2AuthorizationService authorizationService;
|
|
private OAuth2AuthorizationService authorizationService;
|
|
|
|
+
|
|
private OAuth2TokenGenerator<OAuth2Token> tokenGenerator;
|
|
private OAuth2TokenGenerator<OAuth2Token> tokenGenerator;
|
|
|
|
+
|
|
private OAuth2TokenExchangeAuthenticationProvider authenticationProvider;
|
|
private OAuth2TokenExchangeAuthenticationProvider authenticationProvider;
|
|
|
|
|
|
@BeforeEach
|
|
@BeforeEach
|
|
@@ -168,7 +177,8 @@ public class OAuth2TokenExchangeAuthenticationProviderTests {
|
|
@Test
|
|
@Test
|
|
public void authenticateWhenSubjectTokenNotFoundThenThrowOAuth2AuthenticationException() {
|
|
public void authenticateWhenSubjectTokenNotFoundThenThrowOAuth2AuthenticationException() {
|
|
RegisteredClient registeredClient = TestRegisteredClients.registeredClient()
|
|
RegisteredClient registeredClient = TestRegisteredClients.registeredClient()
|
|
- .authorizationGrantType(AuthorizationGrantType.TOKEN_EXCHANGE).build();
|
|
|
|
|
|
+ .authorizationGrantType(AuthorizationGrantType.TOKEN_EXCHANGE)
|
|
|
|
+ .build();
|
|
OAuth2TokenExchangeAuthenticationToken authentication = createDelegationRequest(registeredClient);
|
|
OAuth2TokenExchangeAuthenticationToken authentication = createDelegationRequest(registeredClient);
|
|
when(this.authorizationService.findByToken(anyString(), any(OAuth2TokenType.class))).thenReturn(null);
|
|
when(this.authorizationService.findByToken(anyString(), any(OAuth2TokenType.class))).thenReturn(null);
|
|
// @formatter:off
|
|
// @formatter:off
|
|
@@ -187,10 +197,12 @@ public class OAuth2TokenExchangeAuthenticationProviderTests {
|
|
@Test
|
|
@Test
|
|
public void authenticateWhenSubjectTokenNotActiveThenThrowOAuth2AuthenticationException() {
|
|
public void authenticateWhenSubjectTokenNotActiveThenThrowOAuth2AuthenticationException() {
|
|
RegisteredClient registeredClient = TestRegisteredClients.registeredClient()
|
|
RegisteredClient registeredClient = TestRegisteredClients.registeredClient()
|
|
- .authorizationGrantType(AuthorizationGrantType.TOKEN_EXCHANGE).build();
|
|
|
|
|
|
+ .authorizationGrantType(AuthorizationGrantType.TOKEN_EXCHANGE)
|
|
|
|
+ .build();
|
|
OAuth2TokenExchangeAuthenticationToken authentication = createDelegationRequest(registeredClient);
|
|
OAuth2TokenExchangeAuthenticationToken authentication = createDelegationRequest(registeredClient);
|
|
OAuth2Authorization authorization = TestOAuth2Authorizations.authorization(registeredClient)
|
|
OAuth2Authorization authorization = TestOAuth2Authorizations.authorization(registeredClient)
|
|
- .token(createExpiredAccessToken(SUBJECT_TOKEN)).build();
|
|
|
|
|
|
+ .token(createExpiredAccessToken(SUBJECT_TOKEN))
|
|
|
|
+ .build();
|
|
when(this.authorizationService.findByToken(anyString(), any(OAuth2TokenType.class))).thenReturn(authorization);
|
|
when(this.authorizationService.findByToken(anyString(), any(OAuth2TokenType.class))).thenReturn(authorization);
|
|
// @formatter:off
|
|
// @formatter:off
|
|
assertThatExceptionOfType(OAuth2AuthenticationException.class)
|
|
assertThatExceptionOfType(OAuth2AuthenticationException.class)
|
|
@@ -208,10 +220,12 @@ public class OAuth2TokenExchangeAuthenticationProviderTests {
|
|
@Test
|
|
@Test
|
|
public void authenticateWhenSubjectTokenTypeJwtAndSubjectTokenFormatReferenceThenThrowOAuth2AuthenticationException() {
|
|
public void authenticateWhenSubjectTokenTypeJwtAndSubjectTokenFormatReferenceThenThrowOAuth2AuthenticationException() {
|
|
RegisteredClient registeredClient = TestRegisteredClients.registeredClient()
|
|
RegisteredClient registeredClient = TestRegisteredClients.registeredClient()
|
|
- .authorizationGrantType(AuthorizationGrantType.TOKEN_EXCHANGE).build();
|
|
|
|
|
|
+ .authorizationGrantType(AuthorizationGrantType.TOKEN_EXCHANGE)
|
|
|
|
+ .build();
|
|
OAuth2TokenExchangeAuthenticationToken authentication = createJwtRequest(registeredClient);
|
|
OAuth2TokenExchangeAuthenticationToken authentication = createJwtRequest(registeredClient);
|
|
OAuth2Authorization authorization = TestOAuth2Authorizations.authorization(registeredClient)
|
|
OAuth2Authorization authorization = TestOAuth2Authorizations.authorization(registeredClient)
|
|
- .token(createAccessToken(SUBJECT_TOKEN), withTokenFormat(OAuth2TokenFormat.REFERENCE)).build();
|
|
|
|
|
|
+ .token(createAccessToken(SUBJECT_TOKEN), withTokenFormat(OAuth2TokenFormat.REFERENCE))
|
|
|
|
+ .build();
|
|
when(this.authorizationService.findByToken(anyString(), any(OAuth2TokenType.class))).thenReturn(authorization);
|
|
when(this.authorizationService.findByToken(anyString(), any(OAuth2TokenType.class))).thenReturn(authorization);
|
|
// @formatter:off
|
|
// @formatter:off
|
|
assertThatExceptionOfType(OAuth2AuthenticationException.class)
|
|
assertThatExceptionOfType(OAuth2AuthenticationException.class)
|
|
@@ -229,7 +243,8 @@ public class OAuth2TokenExchangeAuthenticationProviderTests {
|
|
@Test
|
|
@Test
|
|
public void authenticateWhenSubjectPrincipalNullThenThrowOAuth2AuthenticationException() {
|
|
public void authenticateWhenSubjectPrincipalNullThenThrowOAuth2AuthenticationException() {
|
|
RegisteredClient registeredClient = TestRegisteredClients.registeredClient()
|
|
RegisteredClient registeredClient = TestRegisteredClients.registeredClient()
|
|
- .authorizationGrantType(AuthorizationGrantType.TOKEN_EXCHANGE).build();
|
|
|
|
|
|
+ .authorizationGrantType(AuthorizationGrantType.TOKEN_EXCHANGE)
|
|
|
|
+ .build();
|
|
OAuth2TokenExchangeAuthenticationToken authentication = createDelegationRequest(registeredClient);
|
|
OAuth2TokenExchangeAuthenticationToken authentication = createDelegationRequest(registeredClient);
|
|
// @formatter:off
|
|
// @formatter:off
|
|
OAuth2Authorization authorization = TestOAuth2Authorizations.authorization(registeredClient)
|
|
OAuth2Authorization authorization = TestOAuth2Authorizations.authorization(registeredClient)
|
|
@@ -254,12 +269,14 @@ public class OAuth2TokenExchangeAuthenticationProviderTests {
|
|
@Test
|
|
@Test
|
|
public void authenticateWhenActorTokenNotFoundThenThrowOAuth2AuthenticationException() {
|
|
public void authenticateWhenActorTokenNotFoundThenThrowOAuth2AuthenticationException() {
|
|
RegisteredClient registeredClient = TestRegisteredClients.registeredClient()
|
|
RegisteredClient registeredClient = TestRegisteredClients.registeredClient()
|
|
- .authorizationGrantType(AuthorizationGrantType.TOKEN_EXCHANGE).build();
|
|
|
|
|
|
+ .authorizationGrantType(AuthorizationGrantType.TOKEN_EXCHANGE)
|
|
|
|
+ .build();
|
|
OAuth2TokenExchangeAuthenticationToken authentication = createDelegationRequest(registeredClient);
|
|
OAuth2TokenExchangeAuthenticationToken authentication = createDelegationRequest(registeredClient);
|
|
OAuth2Authorization subjectAuthorization = TestOAuth2Authorizations.authorization(registeredClient)
|
|
OAuth2Authorization subjectAuthorization = TestOAuth2Authorizations.authorization(registeredClient)
|
|
- .token(createAccessToken(SUBJECT_TOKEN)).build();
|
|
|
|
- when(this.authorizationService.findByToken(anyString(), any(OAuth2TokenType.class))).thenReturn(
|
|
|
|
- subjectAuthorization, (OAuth2Authorization) null);
|
|
|
|
|
|
+ .token(createAccessToken(SUBJECT_TOKEN))
|
|
|
|
+ .build();
|
|
|
|
+ when(this.authorizationService.findByToken(anyString(), any(OAuth2TokenType.class)))
|
|
|
|
+ .thenReturn(subjectAuthorization, (OAuth2Authorization) null);
|
|
// @formatter:off
|
|
// @formatter:off
|
|
assertThatExceptionOfType(OAuth2AuthenticationException.class)
|
|
assertThatExceptionOfType(OAuth2AuthenticationException.class)
|
|
.isThrownBy(() -> this.authenticationProvider.authenticate(authentication))
|
|
.isThrownBy(() -> this.authenticationProvider.authenticate(authentication))
|
|
@@ -277,14 +294,17 @@ public class OAuth2TokenExchangeAuthenticationProviderTests {
|
|
@Test
|
|
@Test
|
|
public void authenticateWhenActorTokenNotActiveThenThrowOAuth2AuthenticationException() {
|
|
public void authenticateWhenActorTokenNotActiveThenThrowOAuth2AuthenticationException() {
|
|
RegisteredClient registeredClient = TestRegisteredClients.registeredClient()
|
|
RegisteredClient registeredClient = TestRegisteredClients.registeredClient()
|
|
- .authorizationGrantType(AuthorizationGrantType.TOKEN_EXCHANGE).build();
|
|
|
|
|
|
+ .authorizationGrantType(AuthorizationGrantType.TOKEN_EXCHANGE)
|
|
|
|
+ .build();
|
|
OAuth2TokenExchangeAuthenticationToken authentication = createDelegationRequest(registeredClient);
|
|
OAuth2TokenExchangeAuthenticationToken authentication = createDelegationRequest(registeredClient);
|
|
OAuth2Authorization subjectAuthorization = TestOAuth2Authorizations.authorization(registeredClient)
|
|
OAuth2Authorization subjectAuthorization = TestOAuth2Authorizations.authorization(registeredClient)
|
|
- .token(createAccessToken(SUBJECT_TOKEN)).build();
|
|
|
|
|
|
+ .token(createAccessToken(SUBJECT_TOKEN))
|
|
|
|
+ .build();
|
|
OAuth2Authorization actorAuthorization = TestOAuth2Authorizations.authorization(registeredClient)
|
|
OAuth2Authorization actorAuthorization = TestOAuth2Authorizations.authorization(registeredClient)
|
|
- .token(createExpiredAccessToken(ACTOR_TOKEN)).build();
|
|
|
|
- when(this.authorizationService.findByToken(anyString(), any(OAuth2TokenType.class))).thenReturn(
|
|
|
|
- subjectAuthorization, actorAuthorization);
|
|
|
|
|
|
+ .token(createExpiredAccessToken(ACTOR_TOKEN))
|
|
|
|
+ .build();
|
|
|
|
+ when(this.authorizationService.findByToken(anyString(), any(OAuth2TokenType.class)))
|
|
|
|
+ .thenReturn(subjectAuthorization, actorAuthorization);
|
|
// @formatter:off
|
|
// @formatter:off
|
|
assertThatExceptionOfType(OAuth2AuthenticationException.class)
|
|
assertThatExceptionOfType(OAuth2AuthenticationException.class)
|
|
.isThrownBy(() -> this.authenticationProvider.authenticate(authentication))
|
|
.isThrownBy(() -> this.authenticationProvider.authenticate(authentication))
|
|
@@ -302,14 +322,17 @@ public class OAuth2TokenExchangeAuthenticationProviderTests {
|
|
@Test
|
|
@Test
|
|
public void authenticateWhenActorTokenTypeJwtAndActorTokenFormatReferenceThenThrowOAuth2AuthenticationException() {
|
|
public void authenticateWhenActorTokenTypeJwtAndActorTokenFormatReferenceThenThrowOAuth2AuthenticationException() {
|
|
RegisteredClient registeredClient = TestRegisteredClients.registeredClient()
|
|
RegisteredClient registeredClient = TestRegisteredClients.registeredClient()
|
|
- .authorizationGrantType(AuthorizationGrantType.TOKEN_EXCHANGE).build();
|
|
|
|
|
|
+ .authorizationGrantType(AuthorizationGrantType.TOKEN_EXCHANGE)
|
|
|
|
+ .build();
|
|
OAuth2TokenExchangeAuthenticationToken authentication = createJwtRequest(registeredClient);
|
|
OAuth2TokenExchangeAuthenticationToken authentication = createJwtRequest(registeredClient);
|
|
OAuth2Authorization subjectAuthorization = TestOAuth2Authorizations.authorization(registeredClient)
|
|
OAuth2Authorization subjectAuthorization = TestOAuth2Authorizations.authorization(registeredClient)
|
|
- .token(createAccessToken(SUBJECT_TOKEN), withTokenFormat(OAuth2TokenFormat.SELF_CONTAINED)).build();
|
|
|
|
|
|
+ .token(createAccessToken(SUBJECT_TOKEN), withTokenFormat(OAuth2TokenFormat.SELF_CONTAINED))
|
|
|
|
+ .build();
|
|
OAuth2Authorization actorAuthorization = TestOAuth2Authorizations.authorization(registeredClient)
|
|
OAuth2Authorization actorAuthorization = TestOAuth2Authorizations.authorization(registeredClient)
|
|
- .token(createAccessToken(ACTOR_TOKEN), withTokenFormat(OAuth2TokenFormat.REFERENCE)).build();
|
|
|
|
- when(this.authorizationService.findByToken(anyString(), any(OAuth2TokenType.class))).thenReturn(
|
|
|
|
- subjectAuthorization, actorAuthorization);
|
|
|
|
|
|
+ .token(createAccessToken(ACTOR_TOKEN), withTokenFormat(OAuth2TokenFormat.REFERENCE))
|
|
|
|
+ .build();
|
|
|
|
+ when(this.authorizationService.findByToken(anyString(), any(OAuth2TokenType.class)))
|
|
|
|
+ .thenReturn(subjectAuthorization, actorAuthorization);
|
|
// @formatter:off
|
|
// @formatter:off
|
|
assertThatExceptionOfType(OAuth2AuthenticationException.class)
|
|
assertThatExceptionOfType(OAuth2AuthenticationException.class)
|
|
.isThrownBy(() -> this.authenticationProvider.authenticate(authentication))
|
|
.isThrownBy(() -> this.authenticationProvider.authenticate(authentication))
|
|
@@ -327,7 +350,8 @@ public class OAuth2TokenExchangeAuthenticationProviderTests {
|
|
@Test
|
|
@Test
|
|
public void authenticateWhenMayActAndActorIssClaimNotAuthorizedThenThrowOAuth2AuthenticationException() {
|
|
public void authenticateWhenMayActAndActorIssClaimNotAuthorizedThenThrowOAuth2AuthenticationException() {
|
|
RegisteredClient registeredClient = TestRegisteredClients.registeredClient()
|
|
RegisteredClient registeredClient = TestRegisteredClients.registeredClient()
|
|
- .authorizationGrantType(AuthorizationGrantType.TOKEN_EXCHANGE).build();
|
|
|
|
|
|
+ .authorizationGrantType(AuthorizationGrantType.TOKEN_EXCHANGE)
|
|
|
|
+ .build();
|
|
OAuth2TokenExchangeAuthenticationToken authentication = createDelegationRequest(registeredClient);
|
|
OAuth2TokenExchangeAuthenticationToken authentication = createDelegationRequest(registeredClient);
|
|
Map<String, String> authorizedActorClaims = Map.of(OAuth2TokenClaimNames.ISS, "issuer",
|
|
Map<String, String> authorizedActorClaims = Map.of(OAuth2TokenClaimNames.ISS, "issuer",
|
|
OAuth2TokenClaimNames.SUB, "actor");
|
|
OAuth2TokenClaimNames.SUB, "actor");
|
|
@@ -339,9 +363,10 @@ public class OAuth2TokenExchangeAuthenticationProviderTests {
|
|
Map<String, Object> actorTokenClaims = Map.of(OAuth2TokenClaimNames.ISS, "invalid-issuer",
|
|
Map<String, Object> actorTokenClaims = Map.of(OAuth2TokenClaimNames.ISS, "invalid-issuer",
|
|
OAuth2TokenClaimNames.SUB, "actor");
|
|
OAuth2TokenClaimNames.SUB, "actor");
|
|
OAuth2Authorization actorAuthorization = TestOAuth2Authorizations.authorization(registeredClient)
|
|
OAuth2Authorization actorAuthorization = TestOAuth2Authorizations.authorization(registeredClient)
|
|
- .token(createAccessToken(ACTOR_TOKEN), withClaims(actorTokenClaims)).build();
|
|
|
|
- when(this.authorizationService.findByToken(anyString(), any(OAuth2TokenType.class))).thenReturn(
|
|
|
|
- subjectAuthorization, actorAuthorization);
|
|
|
|
|
|
+ .token(createAccessToken(ACTOR_TOKEN), withClaims(actorTokenClaims))
|
|
|
|
+ .build();
|
|
|
|
+ when(this.authorizationService.findByToken(anyString(), any(OAuth2TokenType.class)))
|
|
|
|
+ .thenReturn(subjectAuthorization, actorAuthorization);
|
|
// @formatter:off
|
|
// @formatter:off
|
|
assertThatExceptionOfType(OAuth2AuthenticationException.class)
|
|
assertThatExceptionOfType(OAuth2AuthenticationException.class)
|
|
.isThrownBy(() -> this.authenticationProvider.authenticate(authentication))
|
|
.isThrownBy(() -> this.authenticationProvider.authenticate(authentication))
|
|
@@ -359,7 +384,8 @@ public class OAuth2TokenExchangeAuthenticationProviderTests {
|
|
@Test
|
|
@Test
|
|
public void authenticateWhenMayActAndActorSubClaimNotAuthorizedThenThrowOAuth2AuthenticationException() {
|
|
public void authenticateWhenMayActAndActorSubClaimNotAuthorizedThenThrowOAuth2AuthenticationException() {
|
|
RegisteredClient registeredClient = TestRegisteredClients.registeredClient()
|
|
RegisteredClient registeredClient = TestRegisteredClients.registeredClient()
|
|
- .authorizationGrantType(AuthorizationGrantType.TOKEN_EXCHANGE).build();
|
|
|
|
|
|
+ .authorizationGrantType(AuthorizationGrantType.TOKEN_EXCHANGE)
|
|
|
|
+ .build();
|
|
OAuth2TokenExchangeAuthenticationToken authentication = createDelegationRequest(registeredClient);
|
|
OAuth2TokenExchangeAuthenticationToken authentication = createDelegationRequest(registeredClient);
|
|
Map<String, String> authorizedActorClaims = Map.of(OAuth2TokenClaimNames.ISS, "issuer",
|
|
Map<String, String> authorizedActorClaims = Map.of(OAuth2TokenClaimNames.ISS, "issuer",
|
|
OAuth2TokenClaimNames.SUB, "actor");
|
|
OAuth2TokenClaimNames.SUB, "actor");
|
|
@@ -371,9 +397,10 @@ public class OAuth2TokenExchangeAuthenticationProviderTests {
|
|
Map<String, Object> actorTokenClaims = Map.of(OAuth2TokenClaimNames.ISS, "issuer", OAuth2TokenClaimNames.SUB,
|
|
Map<String, Object> actorTokenClaims = Map.of(OAuth2TokenClaimNames.ISS, "issuer", OAuth2TokenClaimNames.SUB,
|
|
"invalid-actor");
|
|
"invalid-actor");
|
|
OAuth2Authorization actorAuthorization = TestOAuth2Authorizations.authorization(registeredClient)
|
|
OAuth2Authorization actorAuthorization = TestOAuth2Authorizations.authorization(registeredClient)
|
|
- .token(createAccessToken(ACTOR_TOKEN), withClaims(actorTokenClaims)).build();
|
|
|
|
- when(this.authorizationService.findByToken(anyString(), any(OAuth2TokenType.class))).thenReturn(
|
|
|
|
- subjectAuthorization, actorAuthorization);
|
|
|
|
|
|
+ .token(createAccessToken(ACTOR_TOKEN), withClaims(actorTokenClaims))
|
|
|
|
+ .build();
|
|
|
|
+ when(this.authorizationService.findByToken(anyString(), any(OAuth2TokenType.class)))
|
|
|
|
+ .thenReturn(subjectAuthorization, actorAuthorization);
|
|
// @formatter:off
|
|
// @formatter:off
|
|
assertThatExceptionOfType(OAuth2AuthenticationException.class)
|
|
assertThatExceptionOfType(OAuth2AuthenticationException.class)
|
|
.isThrownBy(() -> this.authenticationProvider.authenticate(authentication))
|
|
.isThrownBy(() -> this.authenticationProvider.authenticate(authentication))
|
|
@@ -391,7 +418,8 @@ public class OAuth2TokenExchangeAuthenticationProviderTests {
|
|
@Test
|
|
@Test
|
|
public void authenticateWhenMayActAndImpersonationThenThrowOAuth2AuthenticationException() {
|
|
public void authenticateWhenMayActAndImpersonationThenThrowOAuth2AuthenticationException() {
|
|
RegisteredClient registeredClient = TestRegisteredClients.registeredClient()
|
|
RegisteredClient registeredClient = TestRegisteredClients.registeredClient()
|
|
- .authorizationGrantType(AuthorizationGrantType.TOKEN_EXCHANGE).build();
|
|
|
|
|
|
+ .authorizationGrantType(AuthorizationGrantType.TOKEN_EXCHANGE)
|
|
|
|
+ .build();
|
|
OAuth2TokenExchangeAuthenticationToken authentication = createImpersonationRequest(registeredClient);
|
|
OAuth2TokenExchangeAuthenticationToken authentication = createImpersonationRequest(registeredClient);
|
|
Map<String, String> authorizedActorClaims = Map.of(OAuth2TokenClaimNames.ISS, "issuer",
|
|
Map<String, String> authorizedActorClaims = Map.of(OAuth2TokenClaimNames.ISS, "issuer",
|
|
OAuth2TokenClaimNames.SUB, "actor");
|
|
OAuth2TokenClaimNames.SUB, "actor");
|
|
@@ -400,8 +428,8 @@ public class OAuth2TokenExchangeAuthenticationProviderTests {
|
|
.token(createAccessToken(SUBJECT_TOKEN), withClaims(Map.of("may_act", authorizedActorClaims)))
|
|
.token(createAccessToken(SUBJECT_TOKEN), withClaims(Map.of("may_act", authorizedActorClaims)))
|
|
.build();
|
|
.build();
|
|
// @formatter:on
|
|
// @formatter:on
|
|
- when(this.authorizationService.findByToken(anyString(), any(OAuth2TokenType.class))).thenReturn(
|
|
|
|
- subjectAuthorization);
|
|
|
|
|
|
+ when(this.authorizationService.findByToken(anyString(), any(OAuth2TokenType.class)))
|
|
|
|
+ .thenReturn(subjectAuthorization);
|
|
// @formatter:off
|
|
// @formatter:off
|
|
assertThatExceptionOfType(OAuth2AuthenticationException.class)
|
|
assertThatExceptionOfType(OAuth2AuthenticationException.class)
|
|
.isThrownBy(() -> this.authenticationProvider.authenticate(authentication))
|
|
.isThrownBy(() -> this.authenticationProvider.authenticate(authentication))
|
|
@@ -418,15 +446,18 @@ public class OAuth2TokenExchangeAuthenticationProviderTests {
|
|
@Test
|
|
@Test
|
|
public void authenticateWhenInvalidScopeInRequestThenThrowOAuth2AuthenticationException() {
|
|
public void authenticateWhenInvalidScopeInRequestThenThrowOAuth2AuthenticationException() {
|
|
RegisteredClient registeredClient = TestRegisteredClients.registeredClient()
|
|
RegisteredClient registeredClient = TestRegisteredClients.registeredClient()
|
|
- .authorizationGrantType(AuthorizationGrantType.TOKEN_EXCHANGE).build();
|
|
|
|
|
|
+ .authorizationGrantType(AuthorizationGrantType.TOKEN_EXCHANGE)
|
|
|
|
+ .build();
|
|
OAuth2TokenExchangeAuthenticationToken authentication = createDelegationRequest(registeredClient,
|
|
OAuth2TokenExchangeAuthenticationToken authentication = createDelegationRequest(registeredClient,
|
|
Set.of("invalid"));
|
|
Set.of("invalid"));
|
|
OAuth2Authorization subjectAuthorization = TestOAuth2Authorizations.authorization(registeredClient)
|
|
OAuth2Authorization subjectAuthorization = TestOAuth2Authorizations.authorization(registeredClient)
|
|
- .token(createAccessToken(SUBJECT_TOKEN)).build();
|
|
|
|
|
|
+ .token(createAccessToken(SUBJECT_TOKEN))
|
|
|
|
+ .build();
|
|
OAuth2Authorization actorAuthorization = TestOAuth2Authorizations.authorization(registeredClient)
|
|
OAuth2Authorization actorAuthorization = TestOAuth2Authorizations.authorization(registeredClient)
|
|
- .token(createAccessToken(ACTOR_TOKEN)).build();
|
|
|
|
- when(this.authorizationService.findByToken(anyString(), any(OAuth2TokenType.class))).thenReturn(
|
|
|
|
- subjectAuthorization, actorAuthorization);
|
|
|
|
|
|
+ .token(createAccessToken(ACTOR_TOKEN))
|
|
|
|
+ .build();
|
|
|
|
+ when(this.authorizationService.findByToken(anyString(), any(OAuth2TokenType.class)))
|
|
|
|
+ .thenReturn(subjectAuthorization, actorAuthorization);
|
|
// @formatter:off
|
|
// @formatter:off
|
|
assertThatExceptionOfType(OAuth2AuthenticationException.class)
|
|
assertThatExceptionOfType(OAuth2AuthenticationException.class)
|
|
.isThrownBy(() -> this.authenticationProvider.authenticate(authentication))
|
|
.isThrownBy(() -> this.authenticationProvider.authenticate(authentication))
|
|
@@ -444,14 +475,18 @@ public class OAuth2TokenExchangeAuthenticationProviderTests {
|
|
@Test
|
|
@Test
|
|
public void authenticateWhenInvalidScopeInSubjectAuthorizationThenThrowOAuth2AuthenticationException() {
|
|
public void authenticateWhenInvalidScopeInSubjectAuthorizationThenThrowOAuth2AuthenticationException() {
|
|
RegisteredClient registeredClient = TestRegisteredClients.registeredClient()
|
|
RegisteredClient registeredClient = TestRegisteredClients.registeredClient()
|
|
- .authorizationGrantType(AuthorizationGrantType.TOKEN_EXCHANGE).build();
|
|
|
|
|
|
+ .authorizationGrantType(AuthorizationGrantType.TOKEN_EXCHANGE)
|
|
|
|
+ .build();
|
|
OAuth2TokenExchangeAuthenticationToken authentication = createDelegationRequest(registeredClient, Set.of());
|
|
OAuth2TokenExchangeAuthenticationToken authentication = createDelegationRequest(registeredClient, Set.of());
|
|
OAuth2Authorization subjectAuthorization = TestOAuth2Authorizations.authorization(registeredClient)
|
|
OAuth2Authorization subjectAuthorization = TestOAuth2Authorizations.authorization(registeredClient)
|
|
- .token(createAccessToken(SUBJECT_TOKEN)).authorizedScopes(Set.of("invalid")).build();
|
|
|
|
|
|
+ .token(createAccessToken(SUBJECT_TOKEN))
|
|
|
|
+ .authorizedScopes(Set.of("invalid"))
|
|
|
|
+ .build();
|
|
OAuth2Authorization actorAuthorization = TestOAuth2Authorizations.authorization(registeredClient)
|
|
OAuth2Authorization actorAuthorization = TestOAuth2Authorizations.authorization(registeredClient)
|
|
- .token(createAccessToken(ACTOR_TOKEN)).build();
|
|
|
|
- when(this.authorizationService.findByToken(anyString(), any(OAuth2TokenType.class))).thenReturn(
|
|
|
|
- subjectAuthorization, actorAuthorization);
|
|
|
|
|
|
+ .token(createAccessToken(ACTOR_TOKEN))
|
|
|
|
+ .build();
|
|
|
|
+ when(this.authorizationService.findByToken(anyString(), any(OAuth2TokenType.class)))
|
|
|
|
+ .thenReturn(subjectAuthorization, actorAuthorization);
|
|
// @formatter:off
|
|
// @formatter:off
|
|
assertThatExceptionOfType(OAuth2AuthenticationException.class)
|
|
assertThatExceptionOfType(OAuth2AuthenticationException.class)
|
|
.isThrownBy(() -> this.authenticationProvider.authenticate(authentication))
|
|
.isThrownBy(() -> this.authenticationProvider.authenticate(authentication))
|
|
@@ -469,7 +504,8 @@ public class OAuth2TokenExchangeAuthenticationProviderTests {
|
|
@Test
|
|
@Test
|
|
public void authenticateWhenNoActorTokenAndValidTokenExchangeThenReturnAccessTokenForImpersonation() {
|
|
public void authenticateWhenNoActorTokenAndValidTokenExchangeThenReturnAccessTokenForImpersonation() {
|
|
RegisteredClient registeredClient = TestRegisteredClients.registeredClient()
|
|
RegisteredClient registeredClient = TestRegisteredClients.registeredClient()
|
|
- .authorizationGrantType(AuthorizationGrantType.TOKEN_EXCHANGE).build();
|
|
|
|
|
|
+ .authorizationGrantType(AuthorizationGrantType.TOKEN_EXCHANGE)
|
|
|
|
+ .build();
|
|
OAuth2TokenExchangeAuthenticationToken authentication = createImpersonationRequest(registeredClient);
|
|
OAuth2TokenExchangeAuthenticationToken authentication = createImpersonationRequest(registeredClient);
|
|
TestingAuthenticationToken userPrincipal = new TestingAuthenticationToken("user", null, "ROLE_USER");
|
|
TestingAuthenticationToken userPrincipal = new TestingAuthenticationToken("user", null, "ROLE_USER");
|
|
// @formatter:off
|
|
// @formatter:off
|
|
@@ -478,19 +514,19 @@ public class OAuth2TokenExchangeAuthenticationProviderTests {
|
|
.attribute(Principal.class.getName(), userPrincipal)
|
|
.attribute(Principal.class.getName(), userPrincipal)
|
|
.build();
|
|
.build();
|
|
// @formatter:on
|
|
// @formatter:on
|
|
- when(this.authorizationService.findByToken(anyString(), any(OAuth2TokenType.class))).thenReturn(
|
|
|
|
- subjectAuthorization);
|
|
|
|
|
|
+ when(this.authorizationService.findByToken(anyString(), any(OAuth2TokenType.class)))
|
|
|
|
+ .thenReturn(subjectAuthorization);
|
|
OAuth2AccessToken accessToken = createAccessToken("token-value");
|
|
OAuth2AccessToken accessToken = createAccessToken("token-value");
|
|
when(this.tokenGenerator.generate(any(OAuth2TokenContext.class))).thenReturn(accessToken);
|
|
when(this.tokenGenerator.generate(any(OAuth2TokenContext.class))).thenReturn(accessToken);
|
|
- OAuth2AccessTokenAuthenticationToken authenticationResult =
|
|
|
|
- (OAuth2AccessTokenAuthenticationToken) this.authenticationProvider.authenticate(authentication);
|
|
|
|
|
|
+ OAuth2AccessTokenAuthenticationToken authenticationResult = (OAuth2AccessTokenAuthenticationToken) this.authenticationProvider
|
|
|
|
+ .authenticate(authentication);
|
|
assertThat(authenticationResult.getRegisteredClient()).isEqualTo(registeredClient);
|
|
assertThat(authenticationResult.getRegisteredClient()).isEqualTo(registeredClient);
|
|
assertThat(authenticationResult.getPrincipal()).isEqualTo(authentication.getPrincipal());
|
|
assertThat(authenticationResult.getPrincipal()).isEqualTo(authentication.getPrincipal());
|
|
assertThat(authenticationResult.getAccessToken()).isEqualTo(accessToken);
|
|
assertThat(authenticationResult.getAccessToken()).isEqualTo(accessToken);
|
|
assertThat(authenticationResult.getRefreshToken()).isNull();
|
|
assertThat(authenticationResult.getRefreshToken()).isNull();
|
|
assertThat(authenticationResult.getAdditionalParameters()).hasSize(1);
|
|
assertThat(authenticationResult.getAdditionalParameters()).hasSize(1);
|
|
assertThat(authenticationResult.getAdditionalParameters().get(OAuth2ParameterNames.ISSUED_TOKEN_TYPE))
|
|
assertThat(authenticationResult.getAdditionalParameters().get(OAuth2ParameterNames.ISSUED_TOKEN_TYPE))
|
|
- .isEqualTo(JWT_TOKEN_TYPE_VALUE);
|
|
|
|
|
|
+ .isEqualTo(JWT_TOKEN_TYPE_VALUE);
|
|
|
|
|
|
ArgumentCaptor<OAuth2Authorization> authorizationCaptor = ArgumentCaptor.forClass(OAuth2Authorization.class);
|
|
ArgumentCaptor<OAuth2Authorization> authorizationCaptor = ArgumentCaptor.forClass(OAuth2Authorization.class);
|
|
ArgumentCaptor<OAuth2TokenContext> tokenContextCaptor = ArgumentCaptor.forClass(OAuth2TokenContext.class);
|
|
ArgumentCaptor<OAuth2TokenContext> tokenContextCaptor = ArgumentCaptor.forClass(OAuth2TokenContext.class);
|
|
@@ -521,32 +557,33 @@ public class OAuth2TokenExchangeAuthenticationProviderTests {
|
|
@Test
|
|
@Test
|
|
public void authenticateWhenNoActorTokenAndPreviousActorThenReturnAccessTokenForImpersonation() {
|
|
public void authenticateWhenNoActorTokenAndPreviousActorThenReturnAccessTokenForImpersonation() {
|
|
RegisteredClient registeredClient = TestRegisteredClients.registeredClient()
|
|
RegisteredClient registeredClient = TestRegisteredClients.registeredClient()
|
|
- .authorizationGrantType(AuthorizationGrantType.TOKEN_EXCHANGE).build();
|
|
|
|
|
|
+ .authorizationGrantType(AuthorizationGrantType.TOKEN_EXCHANGE)
|
|
|
|
+ .build();
|
|
OAuth2TokenExchangeAuthenticationToken authentication = createImpersonationRequest(registeredClient);
|
|
OAuth2TokenExchangeAuthenticationToken authentication = createImpersonationRequest(registeredClient);
|
|
TestingAuthenticationToken userPrincipal = new TestingAuthenticationToken("user", null, "ROLE_USER");
|
|
TestingAuthenticationToken userPrincipal = new TestingAuthenticationToken("user", null, "ROLE_USER");
|
|
- OAuth2TokenExchangeActor previousActor = new OAuth2TokenExchangeActor(Map.of(OAuth2TokenClaimNames.ISS, "issuer1",
|
|
|
|
- OAuth2TokenClaimNames.SUB, "actor"));
|
|
|
|
- OAuth2TokenExchangeCompositeAuthenticationToken subjectPrincipal =
|
|
|
|
- new OAuth2TokenExchangeCompositeAuthenticationToken(userPrincipal, List.of(previousActor));
|
|
|
|
|
|
+ OAuth2TokenExchangeActor previousActor = new OAuth2TokenExchangeActor(
|
|
|
|
+ Map.of(OAuth2TokenClaimNames.ISS, "issuer1", OAuth2TokenClaimNames.SUB, "actor"));
|
|
|
|
+ OAuth2TokenExchangeCompositeAuthenticationToken subjectPrincipal = new OAuth2TokenExchangeCompositeAuthenticationToken(
|
|
|
|
+ userPrincipal, List.of(previousActor));
|
|
// @formatter:off
|
|
// @formatter:off
|
|
OAuth2Authorization subjectAuthorization = TestOAuth2Authorizations.authorization(registeredClient)
|
|
OAuth2Authorization subjectAuthorization = TestOAuth2Authorizations.authorization(registeredClient)
|
|
.token(createAccessToken(SUBJECT_TOKEN))
|
|
.token(createAccessToken(SUBJECT_TOKEN))
|
|
.attribute(Principal.class.getName(), subjectPrincipal)
|
|
.attribute(Principal.class.getName(), subjectPrincipal)
|
|
.build();
|
|
.build();
|
|
// @formatter:on
|
|
// @formatter:on
|
|
- when(this.authorizationService.findByToken(anyString(), any(OAuth2TokenType.class))).thenReturn(
|
|
|
|
- subjectAuthorization);
|
|
|
|
|
|
+ when(this.authorizationService.findByToken(anyString(), any(OAuth2TokenType.class)))
|
|
|
|
+ .thenReturn(subjectAuthorization);
|
|
OAuth2AccessToken accessToken = createAccessToken("token-value");
|
|
OAuth2AccessToken accessToken = createAccessToken("token-value");
|
|
when(this.tokenGenerator.generate(any(OAuth2TokenContext.class))).thenReturn(accessToken);
|
|
when(this.tokenGenerator.generate(any(OAuth2TokenContext.class))).thenReturn(accessToken);
|
|
- OAuth2AccessTokenAuthenticationToken authenticationResult =
|
|
|
|
- (OAuth2AccessTokenAuthenticationToken) this.authenticationProvider.authenticate(authentication);
|
|
|
|
|
|
+ OAuth2AccessTokenAuthenticationToken authenticationResult = (OAuth2AccessTokenAuthenticationToken) this.authenticationProvider
|
|
|
|
+ .authenticate(authentication);
|
|
assertThat(authenticationResult.getRegisteredClient()).isEqualTo(registeredClient);
|
|
assertThat(authenticationResult.getRegisteredClient()).isEqualTo(registeredClient);
|
|
assertThat(authenticationResult.getPrincipal()).isEqualTo(authentication.getPrincipal());
|
|
assertThat(authenticationResult.getPrincipal()).isEqualTo(authentication.getPrincipal());
|
|
assertThat(authenticationResult.getAccessToken()).isEqualTo(accessToken);
|
|
assertThat(authenticationResult.getAccessToken()).isEqualTo(accessToken);
|
|
assertThat(authenticationResult.getRefreshToken()).isNull();
|
|
assertThat(authenticationResult.getRefreshToken()).isNull();
|
|
assertThat(authenticationResult.getAdditionalParameters()).hasSize(1);
|
|
assertThat(authenticationResult.getAdditionalParameters()).hasSize(1);
|
|
assertThat(authenticationResult.getAdditionalParameters().get(OAuth2ParameterNames.ISSUED_TOKEN_TYPE))
|
|
assertThat(authenticationResult.getAdditionalParameters().get(OAuth2ParameterNames.ISSUED_TOKEN_TYPE))
|
|
- .isEqualTo(JWT_TOKEN_TYPE_VALUE);
|
|
|
|
|
|
+ .isEqualTo(JWT_TOKEN_TYPE_VALUE);
|
|
|
|
|
|
ArgumentCaptor<OAuth2Authorization> authorizationCaptor = ArgumentCaptor.forClass(OAuth2Authorization.class);
|
|
ArgumentCaptor<OAuth2Authorization> authorizationCaptor = ArgumentCaptor.forClass(OAuth2Authorization.class);
|
|
ArgumentCaptor<OAuth2TokenContext> tokenContextCaptor = ArgumentCaptor.forClass(OAuth2TokenContext.class);
|
|
ArgumentCaptor<OAuth2TokenContext> tokenContextCaptor = ArgumentCaptor.forClass(OAuth2TokenContext.class);
|
|
@@ -577,15 +614,16 @@ public class OAuth2TokenExchangeAuthenticationProviderTests {
|
|
@Test
|
|
@Test
|
|
public void authenticateWhenActorTokenAndValidTokenExchangeThenReturnAccessTokenForDelegation() {
|
|
public void authenticateWhenActorTokenAndValidTokenExchangeThenReturnAccessTokenForDelegation() {
|
|
RegisteredClient registeredClient = TestRegisteredClients.registeredClient()
|
|
RegisteredClient registeredClient = TestRegisteredClients.registeredClient()
|
|
- .authorizationGrantType(AuthorizationGrantType.TOKEN_EXCHANGE).build();
|
|
|
|
|
|
+ .authorizationGrantType(AuthorizationGrantType.TOKEN_EXCHANGE)
|
|
|
|
+ .build();
|
|
OAuth2TokenExchangeAuthenticationToken authentication = createDelegationRequest(registeredClient);
|
|
OAuth2TokenExchangeAuthenticationToken authentication = createDelegationRequest(registeredClient);
|
|
TestingAuthenticationToken userPrincipal = new TestingAuthenticationToken("user", null, "ROLE_USER");
|
|
TestingAuthenticationToken userPrincipal = new TestingAuthenticationToken("user", null, "ROLE_USER");
|
|
- OAuth2TokenExchangeActor actor1 = new OAuth2TokenExchangeActor(Map.of(OAuth2TokenClaimNames.ISS, "issuer1",
|
|
|
|
- OAuth2TokenClaimNames.SUB, "actor1"));
|
|
|
|
- OAuth2TokenExchangeActor actor2 = new OAuth2TokenExchangeActor(Map.of(OAuth2TokenClaimNames.ISS, "issuer2",
|
|
|
|
- OAuth2TokenClaimNames.SUB, "actor2"));
|
|
|
|
- OAuth2TokenExchangeCompositeAuthenticationToken subjectPrincipal =
|
|
|
|
- new OAuth2TokenExchangeCompositeAuthenticationToken(userPrincipal, List.of(actor1));
|
|
|
|
|
|
+ OAuth2TokenExchangeActor actor1 = new OAuth2TokenExchangeActor(
|
|
|
|
+ Map.of(OAuth2TokenClaimNames.ISS, "issuer1", OAuth2TokenClaimNames.SUB, "actor1"));
|
|
|
|
+ OAuth2TokenExchangeActor actor2 = new OAuth2TokenExchangeActor(
|
|
|
|
+ Map.of(OAuth2TokenClaimNames.ISS, "issuer2", OAuth2TokenClaimNames.SUB, "actor2"));
|
|
|
|
+ OAuth2TokenExchangeCompositeAuthenticationToken subjectPrincipal = new OAuth2TokenExchangeCompositeAuthenticationToken(
|
|
|
|
+ userPrincipal, List.of(actor1));
|
|
// @formatter:off
|
|
// @formatter:off
|
|
OAuth2Authorization subjectAuthorization = TestOAuth2Authorizations.authorization(registeredClient)
|
|
OAuth2Authorization subjectAuthorization = TestOAuth2Authorizations.authorization(registeredClient)
|
|
.token(createAccessToken(SUBJECT_TOKEN), withClaims(Map.of("may_act", actor2.getClaims())))
|
|
.token(createAccessToken(SUBJECT_TOKEN), withClaims(Map.of("may_act", actor2.getClaims())))
|
|
@@ -596,19 +634,19 @@ public class OAuth2TokenExchangeAuthenticationProviderTests {
|
|
.token(createAccessToken(ACTOR_TOKEN), withClaims(actor2.getClaims()))
|
|
.token(createAccessToken(ACTOR_TOKEN), withClaims(actor2.getClaims()))
|
|
.build();
|
|
.build();
|
|
// @formatter:on
|
|
// @formatter:on
|
|
- when(this.authorizationService.findByToken(anyString(), any(OAuth2TokenType.class))).thenReturn(
|
|
|
|
- subjectAuthorization, actorAuthorization);
|
|
|
|
|
|
+ when(this.authorizationService.findByToken(anyString(), any(OAuth2TokenType.class)))
|
|
|
|
+ .thenReturn(subjectAuthorization, actorAuthorization);
|
|
OAuth2AccessToken accessToken = createAccessToken("token-value");
|
|
OAuth2AccessToken accessToken = createAccessToken("token-value");
|
|
when(this.tokenGenerator.generate(any(OAuth2TokenContext.class))).thenReturn(accessToken);
|
|
when(this.tokenGenerator.generate(any(OAuth2TokenContext.class))).thenReturn(accessToken);
|
|
- OAuth2AccessTokenAuthenticationToken authenticationResult =
|
|
|
|
- (OAuth2AccessTokenAuthenticationToken) this.authenticationProvider.authenticate(authentication);
|
|
|
|
|
|
+ OAuth2AccessTokenAuthenticationToken authenticationResult = (OAuth2AccessTokenAuthenticationToken) this.authenticationProvider
|
|
|
|
+ .authenticate(authentication);
|
|
assertThat(authenticationResult.getRegisteredClient()).isEqualTo(registeredClient);
|
|
assertThat(authenticationResult.getRegisteredClient()).isEqualTo(registeredClient);
|
|
assertThat(authenticationResult.getPrincipal()).isEqualTo(authentication.getPrincipal());
|
|
assertThat(authenticationResult.getPrincipal()).isEqualTo(authentication.getPrincipal());
|
|
assertThat(authenticationResult.getAccessToken()).isEqualTo(accessToken);
|
|
assertThat(authenticationResult.getAccessToken()).isEqualTo(accessToken);
|
|
assertThat(authenticationResult.getRefreshToken()).isNull();
|
|
assertThat(authenticationResult.getRefreshToken()).isNull();
|
|
assertThat(authenticationResult.getAdditionalParameters()).hasSize(1);
|
|
assertThat(authenticationResult.getAdditionalParameters()).hasSize(1);
|
|
assertThat(authenticationResult.getAdditionalParameters().get(OAuth2ParameterNames.ISSUED_TOKEN_TYPE))
|
|
assertThat(authenticationResult.getAdditionalParameters().get(OAuth2ParameterNames.ISSUED_TOKEN_TYPE))
|
|
- .isEqualTo(JWT_TOKEN_TYPE_VALUE);
|
|
|
|
|
|
+ .isEqualTo(JWT_TOKEN_TYPE_VALUE);
|
|
|
|
|
|
ArgumentCaptor<OAuth2Authorization> authorizationCaptor = ArgumentCaptor.forClass(OAuth2Authorization.class);
|
|
ArgumentCaptor<OAuth2Authorization> authorizationCaptor = ArgumentCaptor.forClass(OAuth2Authorization.class);
|
|
ArgumentCaptor<OAuth2TokenContext> tokenContextCaptor = ArgumentCaptor.forClass(OAuth2TokenContext.class);
|
|
ArgumentCaptor<OAuth2TokenContext> tokenContextCaptor = ArgumentCaptor.forClass(OAuth2TokenContext.class);
|
|
@@ -638,8 +676,8 @@ public class OAuth2TokenExchangeAuthenticationProviderTests {
|
|
assertThat(authorization.getAccessToken().getToken()).isEqualTo(accessToken);
|
|
assertThat(authorization.getAccessToken().getToken()).isEqualTo(accessToken);
|
|
assertThat(authorization.getRefreshToken()).isNull();
|
|
assertThat(authorization.getRefreshToken()).isNull();
|
|
|
|
|
|
- OAuth2TokenExchangeCompositeAuthenticationToken authorizationPrincipal =
|
|
|
|
- authorization.getAttribute(Principal.class.getName());
|
|
|
|
|
|
+ OAuth2TokenExchangeCompositeAuthenticationToken authorizationPrincipal = authorization
|
|
|
|
+ .getAttribute(Principal.class.getName());
|
|
assertThat(authorizationPrincipal).isNotNull();
|
|
assertThat(authorizationPrincipal).isNotNull();
|
|
assertThat(authorizationPrincipal.getSubject()).isSameAs(subjectPrincipal.getSubject());
|
|
assertThat(authorizationPrincipal.getSubject()).isSameAs(subjectPrincipal.getSubject());
|
|
assertThat(authorizationPrincipal.getActors()).containsExactly(actor2, actor1);
|
|
assertThat(authorizationPrincipal.getActors()).containsExactly(actor2, actor1);
|
|
@@ -664,7 +702,8 @@ public class OAuth2TokenExchangeAuthenticationProviderTests {
|
|
clientPrincipal, ACTOR_TOKEN, ACCESS_TOKEN_TYPE_VALUE, RESOURCES, AUDIENCES, requestedScopes, null);
|
|
clientPrincipal, ACTOR_TOKEN, ACCESS_TOKEN_TYPE_VALUE, RESOURCES, AUDIENCES, requestedScopes, null);
|
|
}
|
|
}
|
|
|
|
|
|
- private static OAuth2TokenExchangeAuthenticationToken createImpersonationRequest(RegisteredClient registeredClient) {
|
|
|
|
|
|
+ private static OAuth2TokenExchangeAuthenticationToken createImpersonationRequest(
|
|
|
|
+ RegisteredClient registeredClient) {
|
|
OAuth2ClientAuthenticationToken clientPrincipal = new OAuth2ClientAuthenticationToken(registeredClient,
|
|
OAuth2ClientAuthenticationToken clientPrincipal = new OAuth2ClientAuthenticationToken(registeredClient,
|
|
ClientAuthenticationMethod.CLIENT_SECRET_BASIC, null);
|
|
ClientAuthenticationMethod.CLIENT_SECRET_BASIC, null);
|
|
return new OAuth2TokenExchangeAuthenticationToken(JWT_TOKEN_TYPE_VALUE, SUBJECT_TOKEN, ACCESS_TOKEN_TYPE_VALUE,
|
|
return new OAuth2TokenExchangeAuthenticationToken(JWT_TOKEN_TYPE_VALUE, SUBJECT_TOKEN, ACCESS_TOKEN_TYPE_VALUE,
|