-
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: support regex client attribute to validate redirect uris (#1005)
* feat: support regex client property to validate redirect uris
- Loading branch information
Showing
20 changed files
with
341 additions
and
21 deletions.
There are no files selected for viewing
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
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
89 changes: 89 additions & 0 deletions
89
...rver/client/src/test/java/io/jans/as/client/ws/rs/AuthorizationRedirectUrisRegexTest.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,89 @@ | ||
package io.jans.as.client.ws.rs; | ||
|
||
import io.jans.as.client.*; | ||
import io.jans.as.model.common.ResponseType; | ||
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 io.jans.as.client.client.Asserter.*; | ||
import static io.jans.as.model.register.RegisterRequestParam.*; | ||
|
||
/** | ||
* Integration tests to validate redirect uris regex behavior | ||
* | ||
*/ | ||
public class AuthorizationRedirectUrisRegexTest extends BaseTest { | ||
|
||
@Parameters({"userId", "userSecret", "redirectUris", "sectorIdentifierUri", "redirectUrisRegex", "redirectUri"}) | ||
@Test | ||
public void requestClientValidateUsingRedirectUrisRegex( final String userId, final String userSecret, | ||
final String redirectUris, final String sectorIdentifierUri, | ||
final String redirectUrisRegex, final String redirectUri) { | ||
showTitle("requestClientValidateUsingRedirectUrisRegex"); | ||
|
||
List<ResponseType> responseTypes = Arrays.asList(ResponseType.CODE); | ||
|
||
// 1. Register client | ||
RegisterRequest registerRequest = new RegisterRequest(ApplicationType.WEB, "jans test app", | ||
StringUtils.spaceSeparatedToList(redirectUris)); | ||
registerRequest.setResponseTypes(responseTypes); | ||
registerRequest.setSectorIdentifierUri(sectorIdentifierUri); | ||
registerRequest.setRedirectUrisRegex(redirectUrisRegex); | ||
registerRequest.setRedirectUris(getRedirectUris()); | ||
|
||
RegisterClient registerClient = new RegisterClient(registrationEndpoint); | ||
registerClient.setRequest(registerRequest); | ||
RegisterResponse registerResponse = registerClient.exec(); | ||
|
||
showClient(registerClient); | ||
assertRegisterResponseOk(registerResponse, 201, true); | ||
|
||
String clientId = registerResponse.getClientId(); | ||
String registrationAccessToken = registerResponse.getRegistrationAccessToken(); | ||
String registrationClientUri = registerResponse.getRegistrationClientUri(); | ||
|
||
// 2. Client read | ||
RegisterRequest readClientRequest = new RegisterRequest(registrationAccessToken); | ||
|
||
RegisterClient readClient = new RegisterClient(registrationClientUri); | ||
readClient.setRequest(readClientRequest); | ||
RegisterResponse readClientResponse = readClient.exec(); | ||
|
||
showClient(readClient); | ||
assertRegisterResponseOk(readClientResponse, 200, false); | ||
|
||
assertRegisterResponseClaimsNotNull(readClientResponse, RESPONSE_TYPES, REDIRECT_URIS. APPLICATION_TYPE, CLIENT_NAME, ID_TOKEN_SIGNED_RESPONSE_ALG, SCOPE); | ||
|
||
// 3. Request authorization and receive the authorization code. | ||
List<String> scopes = Arrays.asList("openid", "profile", "address", "email"); | ||
String state = UUID.randomUUID().toString(); | ||
|
||
AuthorizationRequest authorizationRequest = new AuthorizationRequest(responseTypes, clientId, scopes, redirectUri, null); | ||
authorizationRequest.setState(state); | ||
|
||
AuthorizationResponse authorizationResponse = authenticateResourceOwnerAndGrantAccess( | ||
authorizationEndpoint, authorizationRequest, userId, userSecret); | ||
|
||
assertAuthorizationResponse(authorizationResponse, true); | ||
|
||
} | ||
|
||
private List<String> getRedirectUris() { | ||
return Arrays.asList("https://www.jans.org", | ||
"http://localhost:80/jans-auth-rp/home.htm", | ||
"https://localhost:8443/jans-auth-rp/home.htm", | ||
"https://client.example.org/callback", | ||
"https://client.example.org/callback2", | ||
"https://client.other_company.example.net/callback", | ||
"https://client.example.com/cb", | ||
"https://client.example.com/cb1", | ||
"https://client.example.com/cb2") ; | ||
} | ||
|
||
} |
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
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
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
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
Oops, something went wrong.