Search in sources :

Example 1 with OidcClientRegistrationAuthenticationToken

use of org.springframework.security.oauth2.server.authorization.oidc.authentication.OidcClientRegistrationAuthenticationToken in project spring-authorization-server by spring-projects.

the class OidcClientRegistrationAuthenticationProviderTests method authenticateWhenClientConfigurationRequestClientIdNotEqualToAuthorizedClientThenThrowOAuth2AuthenticationException.

@Test
public void authenticateWhenClientConfigurationRequestClientIdNotEqualToAuthorizedClientThenThrowOAuth2AuthenticationException() {
    Jwt jwt = createJwtClientConfiguration();
    OAuth2AccessToken jwtAccessToken = new OAuth2AccessToken(OAuth2AccessToken.TokenType.BEARER, jwt.getTokenValue(), jwt.getIssuedAt(), jwt.getExpiresAt(), jwt.getClaim(OAuth2ParameterNames.SCOPE));
    RegisteredClient registeredClient = TestRegisteredClients.registeredClient().build();
    RegisteredClient authorizedRegisteredClient = TestRegisteredClients.registeredClient().id("registration-2").clientId("client-2").build();
    OAuth2Authorization authorization = TestOAuth2Authorizations.authorization(authorizedRegisteredClient, jwtAccessToken, jwt.getClaims()).build();
    when(this.authorizationService.findByToken(eq(jwtAccessToken.getTokenValue()), eq(OAuth2TokenType.ACCESS_TOKEN))).thenReturn(authorization);
    when(this.registeredClientRepository.findByClientId(eq(registeredClient.getClientId()))).thenReturn(registeredClient);
    JwtAuthenticationToken principal = new JwtAuthenticationToken(jwt, AuthorityUtils.createAuthorityList("SCOPE_client.read"));
    OidcClientRegistrationAuthenticationToken authentication = new OidcClientRegistrationAuthenticationToken(principal, registeredClient.getClientId());
    assertThatThrownBy(() -> this.authenticationProvider.authenticate(authentication)).isInstanceOf(OAuth2AuthenticationException.class).extracting(ex -> ((OAuth2AuthenticationException) ex).getError()).extracting("errorCode").isEqualTo(OAuth2ErrorCodes.INVALID_CLIENT);
    verify(this.authorizationService).findByToken(eq(jwtAccessToken.getTokenValue()), eq(OAuth2TokenType.ACCESS_TOKEN));
    verify(this.registeredClientRepository).findByClientId(eq(registeredClient.getClientId()));
}
Also used : JwtAuthenticationToken(org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationToken) Jwt(org.springframework.security.oauth2.jwt.Jwt) OAuth2AccessToken(org.springframework.security.oauth2.core.OAuth2AccessToken) OAuth2Authorization(org.springframework.security.oauth2.server.authorization.OAuth2Authorization) OAuth2AuthenticationException(org.springframework.security.oauth2.core.OAuth2AuthenticationException) RegisteredClient(org.springframework.security.oauth2.server.authorization.client.RegisteredClient) Test(org.junit.Test)

Example 2 with OidcClientRegistrationAuthenticationToken

use of org.springframework.security.oauth2.server.authorization.oidc.authentication.OidcClientRegistrationAuthenticationToken in project spring-authorization-server by spring-projects.

the class OidcClientRegistrationAuthenticationProviderTests method authenticateWhenRegistrationAccessTokenNotGeneratedThenThrowOAuth2AuthenticationException.

@Test
public void authenticateWhenRegistrationAccessTokenNotGeneratedThenThrowOAuth2AuthenticationException() {
    Jwt jwt = createJwtClientRegistration();
    OAuth2AccessToken jwtAccessToken = new OAuth2AccessToken(OAuth2AccessToken.TokenType.BEARER, jwt.getTokenValue(), jwt.getIssuedAt(), jwt.getExpiresAt(), jwt.getClaim(OAuth2ParameterNames.SCOPE));
    RegisteredClient registeredClient = TestRegisteredClients.registeredClient().build();
    OAuth2Authorization authorization = TestOAuth2Authorizations.authorization(registeredClient, jwtAccessToken, jwt.getClaims()).build();
    when(this.authorizationService.findByToken(eq(jwtAccessToken.getTokenValue()), eq(OAuth2TokenType.ACCESS_TOKEN))).thenReturn(authorization);
    doReturn(null).when(this.tokenGenerator).generate(any());
    JwtAuthenticationToken principal = new JwtAuthenticationToken(jwt, AuthorityUtils.createAuthorityList("SCOPE_client.create"));
    // @formatter:off
    OidcClientRegistration clientRegistration = OidcClientRegistration.builder().clientName("client-name").redirectUri("https://client.example.com").grantType(AuthorizationGrantType.AUTHORIZATION_CODE.getValue()).grantType(AuthorizationGrantType.CLIENT_CREDENTIALS.getValue()).scope("scope1").scope("scope2").build();
    // @formatter:on
    OidcClientRegistrationAuthenticationToken authentication = new OidcClientRegistrationAuthenticationToken(principal, clientRegistration);
    assertThatThrownBy(() -> this.authenticationProvider.authenticate(authentication)).isInstanceOf(OAuth2AuthenticationException.class).extracting(ex -> ((OAuth2AuthenticationException) ex).getError()).satisfies(error -> {
        assertThat(error.getErrorCode()).isEqualTo(OAuth2ErrorCodes.SERVER_ERROR);
        assertThat(error.getDescription()).contains("The token generator failed to generate the registration access token.");
    });
}
Also used : UriComponentsBuilder(org.springframework.web.util.UriComponentsBuilder) Arrays(java.util.Arrays) TestingAuthenticationToken(org.springframework.security.authentication.TestingAuthenticationToken) TestJoseHeaders(org.springframework.security.oauth2.jwt.TestJoseHeaders) OAuth2TokenGenerator(org.springframework.security.oauth2.server.authorization.OAuth2TokenGenerator) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) RegisteredClientRepository(org.springframework.security.oauth2.server.authorization.client.RegisteredClientRepository) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) MacAlgorithm(org.springframework.security.oauth2.jose.jws.MacAlgorithm) TestOAuth2Authorizations(org.springframework.security.oauth2.server.authorization.TestOAuth2Authorizations) After(org.junit.After) Jwt(org.springframework.security.oauth2.jwt.Jwt) Mockito.doReturn(org.mockito.Mockito.doReturn) ProviderSettings(org.springframework.security.oauth2.server.authorization.config.ProviderSettings) OAuth2AuthenticationException(org.springframework.security.oauth2.core.OAuth2AuthenticationException) Set(java.util.Set) JwtGenerator(org.springframework.security.oauth2.server.authorization.JwtGenerator) ProviderContextHolder(org.springframework.security.oauth2.server.authorization.context.ProviderContextHolder) List(java.util.List) OAuth2TokenContext(org.springframework.security.oauth2.server.authorization.OAuth2TokenContext) ProviderContext(org.springframework.security.oauth2.server.authorization.context.ProviderContext) Authentication(org.springframework.security.core.Authentication) Mockito.mock(org.mockito.Mockito.mock) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) OAuth2ParameterNames(org.springframework.security.oauth2.core.endpoint.OAuth2ParameterNames) OidcClientMetadataClaimNames(org.springframework.security.oauth2.core.oidc.OidcClientMetadataClaimNames) OAuth2AuthorizationResponseType(org.springframework.security.oauth2.core.endpoint.OAuth2AuthorizationResponseType) JwtEncoder(org.springframework.security.oauth2.jwt.JwtEncoder) Mockito.spy(org.mockito.Mockito.spy) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) JwtClaimsSet(org.springframework.security.oauth2.jwt.JwtClaimsSet) ArgumentCaptor(org.mockito.ArgumentCaptor) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) ClientAuthenticationMethod(org.springframework.security.oauth2.core.ClientAuthenticationMethod) OAuth2AccessToken(org.springframework.security.oauth2.core.OAuth2AccessToken) ClientSettings(org.springframework.security.oauth2.server.authorization.config.ClientSettings) Before(org.junit.Before) OAuth2Authorization(org.springframework.security.oauth2.server.authorization.OAuth2Authorization) JwtAuthenticationToken(org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationToken) RegisteredClient(org.springframework.security.oauth2.server.authorization.client.RegisteredClient) Test(org.junit.Test) Mockito.times(org.mockito.Mockito.times) Mockito.when(org.mockito.Mockito.when) OAuth2ErrorCodes(org.springframework.security.oauth2.core.OAuth2ErrorCodes) TestRegisteredClients(org.springframework.security.oauth2.server.authorization.client.TestRegisteredClients) OAuth2AuthorizationService(org.springframework.security.oauth2.server.authorization.OAuth2AuthorizationService) Mockito.verify(org.mockito.Mockito.verify) JoseHeader(org.springframework.security.oauth2.jwt.JoseHeader) Mockito.never(org.mockito.Mockito.never) SignatureAlgorithm(org.springframework.security.oauth2.jose.jws.SignatureAlgorithm) OAuth2TokenType(org.springframework.security.oauth2.core.OAuth2TokenType) OidcClientRegistration(org.springframework.security.oauth2.core.oidc.OidcClientRegistration) Assertions.assertThatIllegalArgumentException(org.assertj.core.api.Assertions.assertThatIllegalArgumentException) TestJwtClaimsSets(org.springframework.security.oauth2.jwt.TestJwtClaimsSets) Collections(java.util.Collections) AuthorityUtils(org.springframework.security.core.authority.AuthorityUtils) AuthorizationGrantType(org.springframework.security.oauth2.core.AuthorizationGrantType) JwtAuthenticationToken(org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationToken) Jwt(org.springframework.security.oauth2.jwt.Jwt) OAuth2AccessToken(org.springframework.security.oauth2.core.OAuth2AccessToken) OAuth2Authorization(org.springframework.security.oauth2.server.authorization.OAuth2Authorization) OidcClientRegistration(org.springframework.security.oauth2.core.oidc.OidcClientRegistration) OAuth2AuthenticationException(org.springframework.security.oauth2.core.OAuth2AuthenticationException) RegisteredClient(org.springframework.security.oauth2.server.authorization.client.RegisteredClient) Test(org.junit.Test)

Example 3 with OidcClientRegistrationAuthenticationToken

use of org.springframework.security.oauth2.server.authorization.oidc.authentication.OidcClientRegistrationAuthenticationToken in project spring-authorization-server by spring-projects.

the class OidcClientRegistrationAuthenticationProviderTests method authenticateWhenClientRegistrationRequestAndAccessTokenContainsRequiredScopeAndAdditionalScopeThenThrowOAuth2AuthenticationException.

@Test
public void authenticateWhenClientRegistrationRequestAndAccessTokenContainsRequiredScopeAndAdditionalScopeThenThrowOAuth2AuthenticationException() {
    Jwt jwt = createJwt(new HashSet<>(Arrays.asList("client.create", "scope1")));
    OAuth2AccessToken jwtAccessToken = new OAuth2AccessToken(OAuth2AccessToken.TokenType.BEARER, jwt.getTokenValue(), jwt.getIssuedAt(), jwt.getExpiresAt(), jwt.getClaim(OAuth2ParameterNames.SCOPE));
    RegisteredClient registeredClient = TestRegisteredClients.registeredClient().build();
    OAuth2Authorization authorization = TestOAuth2Authorizations.authorization(registeredClient, jwtAccessToken, jwt.getClaims()).build();
    when(this.authorizationService.findByToken(eq(jwtAccessToken.getTokenValue()), eq(OAuth2TokenType.ACCESS_TOKEN))).thenReturn(authorization);
    JwtAuthenticationToken principal = new JwtAuthenticationToken(jwt, AuthorityUtils.createAuthorityList("SCOPE_client.create", "SCOPE_scope1"));
    OidcClientRegistration clientRegistration = OidcClientRegistration.builder().redirectUri("https://client.example.com").build();
    OidcClientRegistrationAuthenticationToken authentication = new OidcClientRegistrationAuthenticationToken(principal, clientRegistration);
    assertThatThrownBy(() -> this.authenticationProvider.authenticate(authentication)).isInstanceOf(OAuth2AuthenticationException.class).extracting(ex -> ((OAuth2AuthenticationException) ex).getError()).extracting("errorCode").isEqualTo(OAuth2ErrorCodes.INVALID_TOKEN);
    verify(this.authorizationService).findByToken(eq(jwtAccessToken.getTokenValue()), eq(OAuth2TokenType.ACCESS_TOKEN));
}
Also used : JwtAuthenticationToken(org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationToken) Jwt(org.springframework.security.oauth2.jwt.Jwt) OAuth2AccessToken(org.springframework.security.oauth2.core.OAuth2AccessToken) OAuth2Authorization(org.springframework.security.oauth2.server.authorization.OAuth2Authorization) OidcClientRegistration(org.springframework.security.oauth2.core.oidc.OidcClientRegistration) OAuth2AuthenticationException(org.springframework.security.oauth2.core.OAuth2AuthenticationException) RegisteredClient(org.springframework.security.oauth2.server.authorization.client.RegisteredClient) Test(org.junit.Test)

Example 4 with OidcClientRegistrationAuthenticationToken

use of org.springframework.security.oauth2.server.authorization.oidc.authentication.OidcClientRegistrationAuthenticationToken in project spring-authorization-server by spring-projects.

the class OidcClientRegistrationAuthenticationProviderTests method authenticateWhenAccessTokenNotActiveThenThrowOAuth2AuthenticationException.

@Test
public void authenticateWhenAccessTokenNotActiveThenThrowOAuth2AuthenticationException() {
    Jwt jwt = createJwtClientRegistration();
    OAuth2AccessToken jwtAccessToken = new OAuth2AccessToken(OAuth2AccessToken.TokenType.BEARER, jwt.getTokenValue(), jwt.getIssuedAt(), jwt.getExpiresAt(), jwt.getClaim(OAuth2ParameterNames.SCOPE));
    RegisteredClient registeredClient = TestRegisteredClients.registeredClient().build();
    OAuth2Authorization authorization = TestOAuth2Authorizations.authorization(registeredClient, jwtAccessToken, jwt.getClaims()).build();
    authorization = OidcAuthenticationProviderUtils.invalidate(authorization, jwtAccessToken);
    when(this.authorizationService.findByToken(eq(jwtAccessToken.getTokenValue()), eq(OAuth2TokenType.ACCESS_TOKEN))).thenReturn(authorization);
    JwtAuthenticationToken principal = new JwtAuthenticationToken(jwt, AuthorityUtils.createAuthorityList("SCOPE_client.create"));
    OidcClientRegistration clientRegistration = OidcClientRegistration.builder().redirectUri("https://client.example.com").build();
    OidcClientRegistrationAuthenticationToken authentication = new OidcClientRegistrationAuthenticationToken(principal, clientRegistration);
    assertThatThrownBy(() -> this.authenticationProvider.authenticate(authentication)).isInstanceOf(OAuth2AuthenticationException.class).extracting(ex -> ((OAuth2AuthenticationException) ex).getError()).extracting("errorCode").isEqualTo(OAuth2ErrorCodes.INVALID_TOKEN);
    verify(this.authorizationService).findByToken(eq(jwtAccessToken.getTokenValue()), eq(OAuth2TokenType.ACCESS_TOKEN));
}
Also used : JwtAuthenticationToken(org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationToken) Jwt(org.springframework.security.oauth2.jwt.Jwt) OAuth2AccessToken(org.springframework.security.oauth2.core.OAuth2AccessToken) OAuth2Authorization(org.springframework.security.oauth2.server.authorization.OAuth2Authorization) OidcClientRegistration(org.springframework.security.oauth2.core.oidc.OidcClientRegistration) OAuth2AuthenticationException(org.springframework.security.oauth2.core.OAuth2AuthenticationException) RegisteredClient(org.springframework.security.oauth2.server.authorization.client.RegisteredClient) Test(org.junit.Test)

Example 5 with OidcClientRegistrationAuthenticationToken

use of org.springframework.security.oauth2.server.authorization.oidc.authentication.OidcClientRegistrationAuthenticationToken in project spring-authorization-server by spring-projects.

the class OidcClientRegistrationAuthenticationProviderTests method authenticateWhenClientRegistrationRequestAndValidAccessTokenThenReturnClientRegistration.

@Test
public void authenticateWhenClientRegistrationRequestAndValidAccessTokenThenReturnClientRegistration() {
    Jwt jwt = createJwtClientRegistration();
    OAuth2AccessToken jwtAccessToken = new OAuth2AccessToken(OAuth2AccessToken.TokenType.BEARER, jwt.getTokenValue(), jwt.getIssuedAt(), jwt.getExpiresAt(), jwt.getClaim(OAuth2ParameterNames.SCOPE));
    RegisteredClient registeredClient = TestRegisteredClients.registeredClient().build();
    OAuth2Authorization authorization = TestOAuth2Authorizations.authorization(registeredClient, jwtAccessToken, jwt.getClaims()).build();
    when(this.authorizationService.findByToken(eq(jwtAccessToken.getTokenValue()), eq(OAuth2TokenType.ACCESS_TOKEN))).thenReturn(authorization);
    when(this.jwtEncoder.encode(any(), any())).thenReturn(createJwtClientConfiguration());
    JwtAuthenticationToken principal = new JwtAuthenticationToken(jwt, AuthorityUtils.createAuthorityList("SCOPE_client.create"));
    // @formatter:off
    OidcClientRegistration clientRegistration = OidcClientRegistration.builder().clientName("client-name").redirectUri("https://client.example.com").grantType(AuthorizationGrantType.AUTHORIZATION_CODE.getValue()).grantType(AuthorizationGrantType.CLIENT_CREDENTIALS.getValue()).scope("scope1").scope("scope2").build();
    // @formatter:on
    OidcClientRegistrationAuthenticationToken authentication = new OidcClientRegistrationAuthenticationToken(principal, clientRegistration);
    OidcClientRegistrationAuthenticationToken authenticationResult = (OidcClientRegistrationAuthenticationToken) this.authenticationProvider.authenticate(authentication);
    ArgumentCaptor<RegisteredClient> registeredClientCaptor = ArgumentCaptor.forClass(RegisteredClient.class);
    ArgumentCaptor<OAuth2Authorization> authorizationCaptor = ArgumentCaptor.forClass(OAuth2Authorization.class);
    verify(this.authorizationService).findByToken(eq(jwtAccessToken.getTokenValue()), eq(OAuth2TokenType.ACCESS_TOKEN));
    verify(this.registeredClientRepository).save(registeredClientCaptor.capture());
    verify(this.authorizationService, times(2)).save(authorizationCaptor.capture());
    verify(this.jwtEncoder).encode(any(), any());
    // assert "registration" access token, which should be used for subsequent calls to client configuration endpoint
    OAuth2Authorization authorizationResult = authorizationCaptor.getAllValues().get(0);
    assertThat(authorizationResult.getAccessToken().getToken().getScopes()).containsExactly("client.read");
    assertThat(authorizationResult.getAccessToken().isActive()).isTrue();
    assertThat(authorizationResult.getRefreshToken()).isNull();
    // assert "initial" access token is invalidated
    authorizationResult = authorizationCaptor.getAllValues().get(1);
    assertThat(authorizationResult.getAccessToken().isInvalidated()).isTrue();
    if (authorizationResult.getRefreshToken() != null) {
        assertThat(authorizationResult.getRefreshToken().isInvalidated()).isTrue();
    }
    RegisteredClient registeredClientResult = registeredClientCaptor.getValue();
    assertThat(registeredClientResult.getId()).isNotNull();
    assertThat(registeredClientResult.getClientId()).isNotNull();
    assertThat(registeredClientResult.getClientIdIssuedAt()).isNotNull();
    assertThat(registeredClientResult.getClientSecret()).isNotNull();
    assertThat(registeredClientResult.getClientName()).isEqualTo(clientRegistration.getClientName());
    assertThat(registeredClientResult.getClientAuthenticationMethods()).containsExactly(ClientAuthenticationMethod.CLIENT_SECRET_BASIC);
    assertThat(registeredClientResult.getRedirectUris()).containsExactly("https://client.example.com");
    assertThat(registeredClientResult.getAuthorizationGrantTypes()).containsExactlyInAnyOrder(AuthorizationGrantType.AUTHORIZATION_CODE, AuthorizationGrantType.CLIENT_CREDENTIALS);
    assertThat(registeredClientResult.getScopes()).containsExactlyInAnyOrder("scope1", "scope2");
    assertThat(registeredClientResult.getClientSettings().isRequireProofKey()).isTrue();
    assertThat(registeredClientResult.getClientSettings().isRequireAuthorizationConsent()).isTrue();
    assertThat(registeredClientResult.getTokenSettings().getIdTokenSignatureAlgorithm()).isEqualTo(SignatureAlgorithm.RS256);
    OidcClientRegistration clientRegistrationResult = authenticationResult.getClientRegistration();
    assertThat(clientRegistrationResult.getClientId()).isEqualTo(registeredClientResult.getClientId());
    assertThat(clientRegistrationResult.getClientIdIssuedAt()).isEqualTo(registeredClientResult.getClientIdIssuedAt());
    assertThat(clientRegistrationResult.getClientSecret()).isEqualTo(registeredClientResult.getClientSecret());
    assertThat(clientRegistrationResult.getClientSecretExpiresAt()).isEqualTo(registeredClientResult.getClientSecretExpiresAt());
    assertThat(clientRegistrationResult.getClientName()).isEqualTo(registeredClientResult.getClientName());
    assertThat(clientRegistrationResult.getRedirectUris()).containsExactlyInAnyOrderElementsOf(registeredClientResult.getRedirectUris());
    List<String> grantTypes = new ArrayList<>();
    registeredClientResult.getAuthorizationGrantTypes().forEach(authorizationGrantType -> grantTypes.add(authorizationGrantType.getValue()));
    assertThat(clientRegistrationResult.getGrantTypes()).containsExactlyInAnyOrderElementsOf(grantTypes);
    assertThat(clientRegistrationResult.getResponseTypes()).containsExactly(OAuth2AuthorizationResponseType.CODE.getValue());
    assertThat(clientRegistrationResult.getScopes()).containsExactlyInAnyOrderElementsOf(registeredClientResult.getScopes());
    assertThat(clientRegistrationResult.getTokenEndpointAuthenticationMethod()).isEqualTo(registeredClientResult.getClientAuthenticationMethods().iterator().next().getValue());
    assertThat(clientRegistrationResult.getIdTokenSignedResponseAlgorithm()).isEqualTo(registeredClientResult.getTokenSettings().getIdTokenSignatureAlgorithm().getName());
    ProviderContext providerContext = ProviderContextHolder.getProviderContext();
    String expectedRegistrationClientUrl = UriComponentsBuilder.fromUriString(providerContext.getIssuer()).path(providerContext.getProviderSettings().getOidcClientRegistrationEndpoint()).queryParam(OAuth2ParameterNames.CLIENT_ID, registeredClientResult.getClientId()).toUriString();
    assertThat(clientRegistrationResult.getRegistrationClientUrl().toString()).isEqualTo(expectedRegistrationClientUrl);
    assertThat(clientRegistrationResult.getRegistrationAccessToken()).isEqualTo(jwt.getTokenValue());
}
Also used : JwtAuthenticationToken(org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationToken) ProviderContext(org.springframework.security.oauth2.server.authorization.context.ProviderContext) Jwt(org.springframework.security.oauth2.jwt.Jwt) ArrayList(java.util.ArrayList) OAuth2Authorization(org.springframework.security.oauth2.server.authorization.OAuth2Authorization) OidcClientRegistration(org.springframework.security.oauth2.core.oidc.OidcClientRegistration) RegisteredClient(org.springframework.security.oauth2.server.authorization.client.RegisteredClient) OAuth2AccessToken(org.springframework.security.oauth2.core.OAuth2AccessToken) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)18 OAuth2AuthenticationException (org.springframework.security.oauth2.core.OAuth2AuthenticationException)17 OidcClientRegistration (org.springframework.security.oauth2.core.oidc.OidcClientRegistration)17 JwtAuthenticationToken (org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationToken)17 OAuth2AccessToken (org.springframework.security.oauth2.core.OAuth2AccessToken)16 Jwt (org.springframework.security.oauth2.jwt.Jwt)16 OAuth2Authorization (org.springframework.security.oauth2.server.authorization.OAuth2Authorization)16 RegisteredClient (org.springframework.security.oauth2.server.authorization.client.RegisteredClient)15 ArrayList (java.util.ArrayList)5 ProviderContext (org.springframework.security.oauth2.server.authorization.context.ProviderContext)5 TestingAuthenticationToken (org.springframework.security.authentication.TestingAuthenticationToken)4 Authentication (org.springframework.security.core.Authentication)4 Arrays (java.util.Arrays)3 Collections (java.util.Collections)3 HashSet (java.util.HashSet)3 List (java.util.List)3 Set (java.util.Set)3 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)3 Assertions.assertThatIllegalArgumentException (org.assertj.core.api.Assertions.assertThatIllegalArgumentException)3 Assertions.assertThatThrownBy (org.assertj.core.api.Assertions.assertThatThrownBy)3