-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(jans-auth-server): turn off consent for pairwise openid-only scope
- Loading branch information
Showing
3 changed files
with
122 additions
and
22 deletions.
There are no files selected for viewing
97 changes: 97 additions & 0 deletions
97
...src/test/java/io/jans/as/client/ws/rs/TurnOffConsentForPairwiseOpenIdOnlyConsentTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
package io.jans.as.client.ws.rs; | ||
|
||
import io.jans.as.client.*; | ||
import io.jans.as.model.common.ResponseType; | ||
import io.jans.as.model.common.SubjectType; | ||
import io.jans.as.model.crypto.signature.SignatureAlgorithm; | ||
import io.jans.as.model.jwt.JwtClaimName; | ||
import io.jans.as.model.register.ApplicationType; | ||
import io.jans.as.model.util.StringUtils; | ||
import org.testng.annotations.Parameters; | ||
import org.testng.annotations.Test; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.UUID; | ||
|
||
import static org.testng.Assert.assertEquals; | ||
import static org.testng.Assert.assertNotNull; | ||
|
||
/** | ||
* Turn off consent for pairwise / openid-only scope | ||
* | ||
* @author Javier Rojas Blum | ||
* @version January 24, 2022 | ||
*/ | ||
public class TurnOffConsentForPairwiseOpenIdOnlyConsentTest extends BaseTest { | ||
|
||
/** | ||
* If a client is configured for pairwise identifiers, and the openid scope is the only scope requested, | ||
* there is no need to present the consent page, because the AS is not releasing any PII. | ||
*/ | ||
@Parameters({"redirectUris", "redirectUri", "userId", "userSecret", "sectorIdentifierUri"}) | ||
@Test | ||
public void turnOffConsentForPairwiseOpenIdOnlyConsentTest( | ||
final String redirectUris, final String redirectUri, final String userId, final String userSecret, | ||
final String sectorIdentifierUri) { | ||
showTitle("turnOffConsentForPairwiseOpenIdOnlyConsentTest"); | ||
|
||
List<ResponseType> responseTypes = Arrays.asList( | ||
ResponseType.TOKEN, | ||
ResponseType.ID_TOKEN); | ||
|
||
// 1. Dynamic Registration | ||
RegisterRequest registerRequest = new RegisterRequest(ApplicationType.WEB, "jans test app", | ||
StringUtils.spaceSeparatedToList(redirectUris)); | ||
registerRequest.setResponseTypes(responseTypes); | ||
registerRequest.setUserInfoSignedResponseAlg(SignatureAlgorithm.RS256); | ||
registerRequest.setSubjectType(SubjectType.PAIRWISE); | ||
registerRequest.setSectorIdentifierUri(sectorIdentifierUri); | ||
|
||
RegisterClient registerClient = new RegisterClient(registrationEndpoint); | ||
registerClient.setRequest(registerRequest); | ||
RegisterResponse registerResponse = registerClient.exec(); | ||
|
||
showClient(registerClient); | ||
assertEquals(registerResponse.getStatus(), 201); | ||
assertNotNull(registerResponse.getClientId()); | ||
assertNotNull(registerResponse.getClientSecret()); | ||
assertNotNull(registerResponse.getRegistrationAccessToken()); | ||
assertNotNull(registerResponse.getClientSecretExpiresAt()); | ||
|
||
String clientId = registerResponse.getClientId(); | ||
|
||
// 2. Request Authorization | ||
List<String> scopes = Arrays.asList("openid"); | ||
String nonce = UUID.randomUUID().toString(); | ||
String state = UUID.randomUUID().toString(); | ||
|
||
AuthorizationRequest authorizationRequest = new AuthorizationRequest( | ||
responseTypes, clientId, scopes, redirectUri, nonce); | ||
authorizationRequest.setState(state); | ||
|
||
AuthorizationResponse authorizationResponse = authenticateResourceOwner( | ||
authorizationEndpoint, authorizationRequest, userId, userSecret, false); | ||
|
||
assertNotNull(authorizationResponse.getLocation()); | ||
assertNotNull(authorizationResponse.getAccessToken()); | ||
assertNotNull(authorizationResponse.getState()); | ||
assertNotNull(authorizationResponse.getTokenType()); | ||
assertNotNull(authorizationResponse.getExpiresIn()); | ||
assertNotNull(authorizationResponse.getScope()); | ||
assertNotNull(authorizationResponse.getIdToken()); | ||
|
||
String accessToken = authorizationResponse.getAccessToken(); | ||
|
||
// 3. Request user info | ||
UserInfoClient userInfoClient = new UserInfoClient(userInfoEndpoint); | ||
userInfoClient.setJwksUri(jwksUri); | ||
UserInfoResponse userInfoResponse = userInfoClient.execUserInfo(accessToken); | ||
|
||
showClient(userInfoClient); | ||
assertEquals(userInfoResponse.getStatus(), 200); | ||
assertNotNull(userInfoResponse.getClaim(JwtClaimName.SUBJECT_IDENTIFIER)); | ||
assertNotNull(userInfoResponse.getClaim(JwtClaimName.ISSUER)); | ||
assertNotNull(userInfoResponse.getClaim(JwtClaimName.AUDIENCE)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
948520c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#350