Skip to content

Commit

Permalink
feat(jans-auth-server): remove redirect uri on client registration wh…
Browse files Browse the repository at this point in the history
…en grant types is password or client credentials (#3076)
  • Loading branch information
Milton-Ch authored Nov 24, 2022
1 parent 42d49b2 commit cd876b4
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,38 @@ public void registerWithHttpFail(final String redirectUris) throws Exception {
assertNotNull(response.getErrorDescription());
}

@Test
public void registerGrantPasswordRedirectUriNull() {
showTitle("registerGrantPasswordRedirectUriNull");

RegisterRequest registerRequest = new RegisterRequest(ApplicationType.WEB, "Test client with grant password redirect uri null", null);
registerRequest.setGrantTypes(Collections.singletonList(RESOURCE_OWNER_PASSWORD_CREDENTIALS));
registerRequest.setResponseTypes(Collections.singletonList(CODE));

RegisterClient registerClient = new RegisterClient(registrationEndpoint);
registerClient.setRequest(registerRequest);
RegisterResponse response = registerClient.exec();

showClient(registerClient);
AssertBuilder.registerResponse(response).created().check();
}

@Test
public void registerGrantClientCredentialsRedirectUriEmpty() {
showTitle("registerGrantClientCredentialsRedirectUriEmpty");

RegisterRequest registerRequest = new RegisterRequest(ApplicationType.WEB, "Test client with grant client_credentials redirect uri empty", Collections.emptyList());
registerRequest.setGrantTypes(Collections.singletonList(CLIENT_CREDENTIALS));
registerRequest.setResponseTypes(Collections.singletonList(CODE));

RegisterClient registerClient = new RegisterClient(registrationEndpoint);
registerClient.setRequest(registerRequest);
RegisterResponse response = registerClient.exec();

showClient(registerClient);
AssertBuilder.registerResponse(response).created().check();
}

@Parameters({"redirectUris"})
@Test
public void deleteClient(final String redirectUris) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@ public Pair<Boolean, String> validateParamsClientRegister(

if (grantTypes != null &&
(grantTypes.contains(GrantType.AUTHORIZATION_CODE) || grantTypes.contains(GrantType.IMPLICIT)
|| (responseTypes.contains(ResponseType.CODE) && !grantTypes.contains(GrantType.DEVICE_CODE))
|| (responseTypes.contains(ResponseType.CODE) && (
!grantTypes.contains(GrantType.DEVICE_CODE) &&
!grantTypes.contains(GrantType.RESOURCE_OWNER_PASSWORD_CREDENTIALS) &&
!grantTypes.contains(GrantType.CLIENT_CREDENTIALS)))
|| responseTypes.contains(ResponseType.TOKEN) || responseTypes.contains(ResponseType.ID_TOKEN))) {
if (redirectUris == null || redirectUris.isEmpty()) {
return new Pair<>(false, "Redirect uris are empty.");
Expand Down Expand Up @@ -284,7 +287,10 @@ public boolean validateRedirectUris(List<GrantType> grantTypes, List<ResponseTyp
}
}
} else valid = !grantTypes.contains(GrantType.AUTHORIZATION_CODE) && !grantTypes.contains(GrantType.IMPLICIT) &&
(!responseTypes.contains(ResponseType.CODE) || grantTypes.contains(GrantType.DEVICE_CODE))
(!responseTypes.contains(ResponseType.CODE) || (
grantTypes.contains(GrantType.DEVICE_CODE) ||
grantTypes.contains(GrantType.RESOURCE_OWNER_PASSWORD_CREDENTIALS) ||
grantTypes.contains(GrantType.CLIENT_CREDENTIALS)))
&& !responseTypes.contains(ResponseType.TOKEN) && !responseTypes.contains(ResponseType.ID_TOKEN);


Expand Down

0 comments on commit cd876b4

Please sign in to comment.