Skip to content

Commit

Permalink
fix(jans-auth-server): fixed server and tests after jetty 11 migration (
Browse files Browse the repository at this point in the history
#1354)

* fix(jans-auth-server): restored previous state of authz impl

#1341

* fix(jans-auth-server): cherry-pick 4d5ad26 and adapt code

#1341

* fix(jans-auth-server): cherry-pick ae0b60b and adapt code

#1341

* fix(jans-auth-server): cherry-pick e30e65e and adapt code

#1341

* Revert "fix(jans-auth-server): cherry-pick e30e65e and adapt code"

This reverts commit f3c6bd7.

* Revert "fix(jans-auth-server): cherry-pick ae0b60b and adapt code"

This reverts commit 5e6e939

* fix(jans-auth-server): put back inlined request jwt

* fix(jans-auth-server): extracted authorize method

* fix(jans-auth-server): more extracted methods out of authorize

* fix(jans-auth-server): extracted methods out of authorize

* fix(jans-auth-server): methods out of authorize

* fix(jans-auth-server): request jwt refactoring

* fix(jans-auth-server): corrected redirect uri creation

* fix(jans-auth-server): corrected redirect uri creation

* fix(jans-auth-server): corrected register response assert builder

* fix(jans-auth-server): code clean up

Co-authored-by: YuriyZ <yzabrovarniy@gmail.com>
  • Loading branch information
yuriyzz and yuriyz committed May 17, 2022
1 parent 3c15e44 commit 3fa19f4
Show file tree
Hide file tree
Showing 5 changed files with 120 additions and 93 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import io.jans.as.client.RegisterResponse;
import io.jans.as.model.common.BackchannelTokenDeliveryMode;
import io.jans.as.model.crypto.signature.AsymmetricSignatureAlgorithm;
import org.apache.commons.lang3.BooleanUtils;

import static io.jans.as.model.register.RegisterRequestParam.*;
import static org.testng.Assert.*;
Expand Down Expand Up @@ -84,7 +85,7 @@ public void check() {
assertTrue(response.getClaims().containsKey(BACKCHANNEL_AUTHENTICATION_REQUEST_SIGNING_ALG.toString()));
assertEquals(response.getClaims().get(BACKCHANNEL_AUTHENTICATION_REQUEST_SIGNING_ALG.toString()), backchannelRequestSigningAlgorithm.getValue());
}
if (backchannelUserCodeParameter != null) {
if (BooleanUtils.isTrue(backchannelUserCodeParameter)) {
assertTrue(response.getClaims().containsKey(BACKCHANNEL_USER_CODE_PARAMETER.toString()));
assertEquals(response.getClaims().get(BACKCHANNEL_USER_CODE_PARAMETER.toString()), String.valueOf(backchannelUserCodeParameter));
}
Expand Down
2 changes: 1 addition & 1 deletion jans-auth-server/model/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-jaxb-annotations</artifactId>
<artifactId>jackson-module-jakarta-xmlbind-annotations</artifactId>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,23 +332,20 @@ private static boolean canLogWebApplicationException(WebApplicationException e)

private ResponseBuilder authorize(AuthzRequest authzRequest) throws AcrChangedException, SearchException, TokenBindingParseException {
String tokenBindingHeader = authzRequest.getHttpRequest().getHeader("Sec-Token-Binding");
boolean isPar = authzRequestService.processPar(authzRequest);

List<Prompt> prompts = Prompt.fromString(authzRequest.getPrompt(), " ");
final List<ResponseType> responseTypes = authzRequest.getResponseTypeList();

SessionId sessionUser = identity.getSessionId();
User user = sessionIdService.getUser(sessionUser);

boolean isPar = authzRequestService.processPar(authzRequest);

Map<String, String> customResponseHeaders = Util.jsonObjectArrayStringAsMap(authzRequest.getCustomResponseHeaders());

updateSessionForROPC(authzRequest.getHttpRequest(), sessionUser);

Client client = authorizeRestWebServiceValidator.validateClient(authzRequest, isPar);

String deviceAuthzUserCode = deviceAuthorizationService.getUserCodeFromSession(authzRequest.getHttpRequest());
authzRequest.setRedirectUri(authorizeRestWebServiceValidator.validateRedirectUri(client, authzRequest.getRedirectUri(), authzRequest.getState(), deviceAuthzUserCode, authzRequest.getHttpRequest()));

authzRequestService.createRedirectUriResponse(authzRequest);

authorizeRestWebServiceValidator.validateAcrs(authzRequest, client);
Expand All @@ -357,7 +354,8 @@ private ResponseBuilder authorize(AuthzRequest authzRequest) throws AcrChangedEx

authorizeRestWebServiceValidator.checkSignedRequestRequired(authzRequest);

authzRequestService.processRequestObject(authzRequest, client, scopes, user);
authzRequestService.processRequestObject(authzRequest, client, scopes, user, prompts);

validateRequestJwt(authzRequest, isPar, client);

authorizeRestWebServiceValidator.validate(authzRequest, responseTypes, client);
Expand Down Expand Up @@ -503,18 +501,24 @@ private ResponseBuilder authorize(AuthzRequest authzRequest) throws AcrChangedEx

ResponseBuilder builder = RedirectUtil.getRedirectResponseBuilder(authzRequest.getRedirectUriResponse().getRedirectUri(), authzRequest.getHttpRequest());

if (isTrue(appConfiguration.getCustomHeadersWithAuthorizationResponse())) {
for (Entry<String, String> entry : customResponseHeaders.entrySet()) {
builder.header(entry.getKey(), entry.getValue());
}
}
addCustomHeaders(builder, authzRequest);

runCiba(authzRequest.getAuthReqId(), client, authzRequest.getHttpRequest(), authzRequest.getHttpResponse());
processDeviceAuthorization(deviceAuthzUserCode, user);

return builder;
}

private void addCustomHeaders(ResponseBuilder builder, AuthzRequest authzRequest) {
if (isTrue(appConfiguration.getCustomHeadersWithAuthorizationResponse())) {

Map<String, String> customResponseHeaders = Util.jsonObjectArrayStringAsMap(authzRequest.getCustomResponseHeaders());
for (Entry<String, String> entry : customResponseHeaders.entrySet()) {
builder.header(entry.getKey(), entry.getValue());
}
}
}

private void addResponseParameterScope(AuthzRequest authzRequest, AuthorizationGrant authorizationGrant) {
if (authorizationGrant != null && !appConfiguration.isFapi()) {
authzRequest.setScope(authorizationGrant.checkScopesPolicy(authzRequest.getScope()));
Expand Down
Loading

0 comments on commit 3fa19f4

Please sign in to comment.