Skip to content

Commit b48169d

Browse files
Merge branch 'master' of https://github.com/wso2-extensions/identity-inbound-auth-oauth into master_use_newDCRattributes
2 parents 10c8686 + 87d5542 commit b48169d

File tree

58 files changed

+514
-269
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+514
-269
lines changed

components/org.wso2.carbon.identity.api.server.dcr/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
<parent>
66
<groupId>org.wso2.carbon.identity.inbound.auth.oauth2</groupId>
77
<artifactId>identity-inbound-auth-oauth</artifactId>
8-
<version>6.11.170-SNAPSHOT</version>
8+
<version>6.11.181-SNAPSHOT</version>
99
<relativePath>../..</relativePath>
1010
</parent>
1111

1212
<artifactId>org.wso2.carbon.identity.api.server.dcr</artifactId>
13-
<version>6.11.170-SNAPSHOT</version>
13+
<version>6.11.181-SNAPSHOT</version>
1414
<name>WSO2 Carbon - User DCR Rest API</name>
1515
<description>WSO2 Carbon - User DCR Rest API</description>
1616

components/org.wso2.carbon.identity.api.server.oauth.scope/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
<parent>
66
<groupId>org.wso2.carbon.identity.inbound.auth.oauth2</groupId>
77
<artifactId>identity-inbound-auth-oauth</artifactId>
8-
<version>6.11.170-SNAPSHOT</version>
8+
<version>6.11.181-SNAPSHOT</version>
99
<relativePath>../..</relativePath>
1010
</parent>
1111

1212
<artifactId>org.wso2.carbon.identity.api.server.oauth.scope</artifactId>
13-
<version>6.11.170-SNAPSHOT</version>
13+
<version>6.11.181-SNAPSHOT</version>
1414

1515
<name>WSO2 Carbon - Identity OAuth 2.0 Scope Rest APIs</name>
1616
<description>Rest APIs for OAuth 2.0 Scope Handling</description>

components/org.wso2.carbon.identity.discovery/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<groupId>org.wso2.carbon.identity.inbound.auth.oauth2</groupId>
2222
<artifactId>identity-inbound-auth-oauth</artifactId>
2323
<relativePath>../../pom.xml</relativePath>
24-
<version>6.11.170-SNAPSHOT</version>
24+
<version>6.11.181-SNAPSHOT</version>
2525
</parent>
2626

2727
<modelVersion>4.0.0</modelVersion>

components/org.wso2.carbon.identity.oauth.ciba/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<parent>
2121
<artifactId>identity-inbound-auth-oauth</artifactId>
2222
<groupId>org.wso2.carbon.identity.inbound.auth.oauth2</groupId>
23-
<version>6.11.170-SNAPSHOT</version>
23+
<version>6.11.181-SNAPSHOT</version>
2424
<relativePath>../../pom.xml</relativePath>
2525
</parent>
2626

components/org.wso2.carbon.identity.oauth.client.authn.filter/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<groupId>org.wso2.carbon.identity.inbound.auth.oauth2</groupId>
2323
<artifactId>identity-inbound-auth-oauth</artifactId>
2424
<relativePath>../../pom.xml</relativePath>
25-
<version>6.11.170-SNAPSHOT</version>
25+
<version>6.11.181-SNAPSHOT</version>
2626
</parent>
2727

2828
<modelVersion>4.0.0</modelVersion>

components/org.wso2.carbon.identity.oauth.common/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<groupId>org.wso2.carbon.identity.inbound.auth.oauth2</groupId>
2424
<artifactId>identity-inbound-auth-oauth</artifactId>
2525
<relativePath>../../pom.xml</relativePath>
26-
<version>6.11.170-SNAPSHOT</version>
26+
<version>6.11.181-SNAPSHOT</version>
2727
</parent>
2828

2929
<modelVersion>4.0.0</modelVersion>

components/org.wso2.carbon.identity.oauth.dcr.endpoint/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<groupId>org.wso2.carbon.identity.inbound.auth.oauth2</groupId>
77
<artifactId>identity-inbound-auth-oauth</artifactId>
88
<relativePath>../../pom.xml</relativePath>
9-
<version>6.11.170-SNAPSHOT</version>
9+
<version>6.11.181-SNAPSHOT</version>
1010
</parent>
1111

1212
<modelVersion>4.0.0</modelVersion>

components/org.wso2.carbon.identity.oauth.dcr/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<groupId>org.wso2.carbon.identity.inbound.auth.oauth2</groupId>
2323
<artifactId>identity-inbound-auth-oauth</artifactId>
2424
<relativePath>../../pom.xml</relativePath>
25-
<version>6.11.170-SNAPSHOT</version>
25+
<version>6.11.181-SNAPSHOT</version>
2626
</parent>
2727

2828
<modelVersion>4.0.0</modelVersion>

components/org.wso2.carbon.identity.oauth.endpoint/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<groupId>org.wso2.carbon.identity.inbound.auth.oauth2</groupId>
2323
<artifactId>identity-inbound-auth-oauth</artifactId>
2424
<relativePath>../../pom.xml</relativePath>
25-
<version>6.11.170-SNAPSHOT</version>
25+
<version>6.11.181-SNAPSHOT</version>
2626
</parent>
2727

2828
<modelVersion>4.0.0</modelVersion>

components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/authz/OAuth2AuthzEndpoint.java

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,6 @@ private AuthorizationResponseDTO getAuthResponseDTO(OAuth2Parameters oauth2Param
558558
authorizationResponseDTO.setState(oauth2Params.getState());
559559
authorizationResponseDTO.setResponseMode(oauth2Params.getResponseMode());
560560
authorizationResponseDTO.setResponseType(oauth2Params.getResponseType());
561-
authorizationResponseDTO.getSuccessResponseDTO().setScope(oauth2Params.getScopes());
562561

563562
return authorizationResponseDTO;
564563
}
@@ -1369,7 +1368,7 @@ private Response handleInitialAuthorizationRequest(OAuthMessage oAuthMessage) th
13691368
String type = getRequestProtocolType(oAuthMessage);
13701369

13711370
if (AuthenticatorFlowStatus.SUCCESS_COMPLETED == oAuthMessage.getFlowStatus()) {
1372-
return handleAuthFlowThroughFramework(oAuthMessage, type);
1371+
return handleAuthFlowThroughFramework(oAuthMessage, type, redirectURL);
13731372
} else {
13741373
return Response.status(HttpServletResponse.SC_FOUND).location(new URI(redirectURL)).build();
13751374
}
@@ -1724,7 +1723,7 @@ private OAuthResponse handleSuccessAuthorization(OAuthMessage oAuthMessage, OIDC
17241723
}
17251724
if (isResponseTypeNotIdTokenOrNone(responseType, authzRespDTO)) {
17261725
setAccessToken(authzRespDTO, builder, authorizationResponseDTO);
1727-
setScopes(authzRespDTO, builder);
1726+
setScopes(authzRespDTO, builder, authorizationResponseDTO);
17281727
}
17291728
if (isIdTokenExists(authzRespDTO)) {
17301729
setIdToken(authzRespDTO, builder, authorizationResponseDTO);
@@ -1907,12 +1906,15 @@ private void setAccessToken(OAuth2AuthorizeRespDTO authzRespDTO,
19071906
}
19081907

19091908
private void setScopes(OAuth2AuthorizeRespDTO authzRespDTO,
1910-
OAuthASResponse.OAuthAuthorizationResponseBuilder builder) {
1909+
OAuthASResponse.OAuthAuthorizationResponseBuilder builder, AuthorizationResponseDTO
1910+
authorizationResponseDTO) {
19111911

19121912
String[] scopes = authzRespDTO.getScope();
19131913
if (scopes != null && scopes.length > 0) {
19141914
String scopeString = StringUtils.join(scopes, " ");
19151915
builder.setScope(scopeString.trim());
1916+
Set<String> scopesSet = new HashSet<>(Arrays.asList(scopes));
1917+
authorizationResponseDTO.getSuccessResponseDTO().setScope(scopesSet);
19161918
}
19171919
}
19181920

@@ -3752,8 +3754,8 @@ private void invokeCommonauthFlow(OAuthMessage oAuthMessage, CommonAuthResponseW
37523754
* @throws InvalidRequestParentException
37533755
* @Param type OAuthMessage
37543756
*/
3755-
private Response handleAuthFlowThroughFramework(OAuthMessage oAuthMessage, String type) throws URISyntaxException,
3756-
InvalidRequestParentException {
3757+
private Response handleAuthFlowThroughFramework(OAuthMessage oAuthMessage, String type, String redirectUrl)
3758+
throws URISyntaxException, InvalidRequestParentException {
37573759

37583760
if (LoggerUtils.isDiagnosticLogsEnabled()) {
37593761
DiagnosticLog.DiagnosticLogBuilder diagnosticLogBuilder = new DiagnosticLog.DiagnosticLogBuilder(
@@ -4341,14 +4343,19 @@ private Response handleApiBasedAuthenticationResponse(OAuthMessage oAuthMessage,
43414343
ObjectMapper objectMapper = new ObjectMapper();
43424344
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
43434345
String jsonString = objectMapper.writeValueAsString(authResponse);
4346+
oAuthMessage.getRequest().setAttribute(IS_API_BASED_AUTH_HANDLED, true);
43444347
return Response.ok().entity(jsonString).build();
43454348

43464349
} else {
4347-
String location = oauthResponse.getMetadata().get("Location").get(0).toString();
4348-
if (StringUtils.isNotBlank(location)) {
4349-
Map<String, String> queryParams = getQueryParamsFromUrl(location);
4350-
String jsonPayload = new Gson().toJson(queryParams);
4351-
return Response.status(HttpServletResponse.SC_OK).entity(jsonPayload).build();
4350+
List<Object> locationHeader = oauthResponse.getMetadata().get("Location");
4351+
if (CollectionUtils.isNotEmpty(locationHeader)) {
4352+
String location = locationHeader.get(0).toString();
4353+
if (StringUtils.isNotBlank(location)) {
4354+
Map<String, String> queryParams = getQueryParamsFromUrl(location);
4355+
String jsonPayload = new Gson().toJson(queryParams);
4356+
oAuthMessage.getRequest().setAttribute(IS_API_BASED_AUTH_HANDLED, true);
4357+
return Response.status(HttpServletResponse.SC_OK).entity(jsonPayload).build();
4358+
}
43524359
}
43534360
}
43544361
} catch (AuthServiceException | JsonProcessingException | UnsupportedEncodingException | URISyntaxException e) {
@@ -4357,6 +4364,7 @@ private Response handleApiBasedAuthenticationResponse(OAuthMessage oAuthMessage,
43574364
params.put(OAuthConstants.OAUTH_ERROR, OAuth2ErrorCodes.SERVER_ERROR);
43584365
params.put(OAuthConstants.OAUTH_ERROR_DESCRIPTION, "Server error occurred while performing authorization.");
43594366
String jsonString = new Gson().toJson(params);
4367+
oAuthMessage.getRequest().setAttribute(IS_API_BASED_AUTH_HANDLED, true);
43604368
return Response.status(HttpServletResponse.SC_INTERNAL_SERVER_ERROR).entity(jsonString).build();
43614369
}
43624370

0 commit comments

Comments
 (0)