-
Notifications
You must be signed in to change notification settings - Fork 845
feat: token exchange for UAA-issued opaque access tokens #3845
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -13,12 +13,14 @@ | |||||||||
| import org.cloudfoundry.identity.uaa.oauth.provider.OAuth2RequestFactory; | ||||||||||
| import org.cloudfoundry.identity.uaa.oauth.provider.TokenRequest; | ||||||||||
| import org.cloudfoundry.identity.uaa.oauth.provider.token.AuthorizationServerTokenServices; | ||||||||||
| import org.cloudfoundry.identity.uaa.provider.oauth.TokenActor; | ||||||||||
| import org.cloudfoundry.identity.uaa.user.UaaUser; | ||||||||||
| import org.cloudfoundry.identity.uaa.zone.IdentityZoneHolder; | ||||||||||
| import org.cloudfoundry.identity.uaa.zone.MultitenantClientServices; | ||||||||||
| import org.junit.jupiter.api.AfterEach; | ||||||||||
| import org.junit.jupiter.api.BeforeEach; | ||||||||||
| import org.junit.jupiter.api.Test; | ||||||||||
| import org.springframework.dao.EmptyResultDataAccessException; | ||||||||||
| import org.springframework.security.core.context.SecurityContextHolder; | ||||||||||
|
|
||||||||||
| import java.util.Collections; | ||||||||||
|
|
@@ -33,6 +35,7 @@ | |||||||||
| import static org.cloudfoundry.identity.uaa.oauth.token.TokenConstants.TOKEN_TYPE_ACCESS; | ||||||||||
| import static org.cloudfoundry.identity.uaa.oauth.token.TokenConstants.TOKEN_TYPE_ID; | ||||||||||
| import static org.cloudfoundry.identity.uaa.oauth.token.TokenConstants.TOKEN_TYPE_REFRESH; | ||||||||||
| import static org.mockito.ArgumentMatchers.any; | ||||||||||
| import static org.mockito.ArgumentMatchers.anyString; | ||||||||||
| import static org.mockito.ArgumentMatchers.eq; | ||||||||||
|
strehle marked this conversation as resolved.
|
||||||||||
| import static org.mockito.ArgumentMatchers.same; | ||||||||||
|
|
@@ -52,14 +55,16 @@ class TokenExchangeGranterTests { | |||||||||
| private AuthorizationServerTokenServices tokenServices; | ||||||||||
| private MultitenantClientServices clientDetailsService; | ||||||||||
| private OAuth2RequestFactory requestFactory; | ||||||||||
| private RevocableTokenProvisioning revocableTokenProvisioning; | ||||||||||
| private Map<String, String> requestParameters; | ||||||||||
|
|
||||||||||
| @BeforeEach | ||||||||||
| void setUp() { | ||||||||||
| tokenServices = mock(AuthorizationServerTokenServices.class); | ||||||||||
| clientDetailsService = mock(MultitenantClientServices.class); | ||||||||||
| requestFactory = mock(OAuth2RequestFactory.class); | ||||||||||
| granter = spy(new TokenExchangeGranter(tokenServices, clientDetailsService, requestFactory)); | ||||||||||
| revocableTokenProvisioning = mock(RevocableTokenProvisioning.class); | ||||||||||
| granter = spy(new TokenExchangeGranter(tokenServices, clientDetailsService, requestFactory, revocableTokenProvisioning)); | ||||||||||
| tokenRequest = new TokenRequest(Collections.emptyMap(), "client_ID", Collections.emptySet(), GRANT_TYPE_TOKEN_EXCHANGE); | ||||||||||
|
|
||||||||||
| authentication = mock(UaaOauth2Authentication.class); | ||||||||||
|
|
@@ -211,4 +216,43 @@ void invalid_requested_token_type() { | |||||||||
| .isInstanceOf(InvalidGrantException.class) | ||||||||||
| .hasMessageContaining("Invalid requested token type, only urn:ietf:params:oauth:token-type:access_token is supported"); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| @Test | ||||||||||
| void opaque_subject_token_is_resolved_from_db() { | ||||||||||
| // A real JWT signed with a trivial key — three dot-separated parts | ||||||||||
| String jwtValue = "eyJhbGciOiJSUzI1NiJ9.eyJzdWIiOiJ1c2VyMTIzIiwiaXNzIjoiaHR0cHM6Ly91YWEuZXhhbXBsZS5jb20iLCJ1c2VyX25hbWUiOiJqb2huIiwidXNlcl9pZCI6InVzZXIxMjMiLCJvcmlnaW4iOiJ1YWEifQ.signature"; | ||||||||||
|
Comment on lines
+221
to
+222
|
||||||||||
| // A real JWT signed with a trivial key — three dot-separated parts | |
| String jwtValue = "eyJhbGciOiJSUzI1NiJ9.eyJzdWIiOiJ1c2VyMTIzIiwiaXNzIjoiaHR0cHM6Ly91YWEuZXhhbXBsZS5jb20iLCJ1c2VyX25hbWUiOiJqb2huIiwidXNlcl9pZCI6InVzZXIxMjMiLCJvcmlnaW4iOiJ1YWEifQ.signature"; | |
| // A parseable JWT fixture with three Base64URL-encoded parts | |
| String jwtValue = "eyJhbGciOiJSUzI1NiJ9.eyJzdWIiOiJ1c2VyMTIzIiwiaXNzIjoiaHR0cHM6Ly91YWEuZXhhbXBsZS5jb20iLCJ1c2VyX25hbWUiOiJqb2huIiwidXNlcl9pZCI6InVzZXIxMjMiLCJvcmlnaW4iOiJ1YWEifQ.c2lnbmF0dXJl"; |
Uh oh!
There was an error while loading. Please reload this page.