Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes to getAMRValues method #2712

Closed
wants to merge 56 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
a4bda37
Fix associate user token not revoke in password reset.
Malith-19 Feb 14, 2025
fa55801
Improve the formatting.
Malith-19 Feb 14, 2025
975e867
Fix org role update filter issue.
Malith-19 Feb 14, 2025
ba31964
Bump netty-all version
inthirakumaaran Feb 14, 2025
b62dcc0
Changes to getAMRValues method
Eranda2001 Feb 14, 2025
09405f6
Merge pull request #2711 from wso2-extensions/fix_netty_all
inthirakumaaran Feb 17, 2025
361e9b2
[WSO2 Release] [Jenkins #5226] [Release 7.0.245] prepare release v7.0…
wso2-jenkins-bot Feb 17, 2025
8b1ca79
[WSO2 Release] [Jenkins #5226] [Release 7.0.245] prepare for next dev…
wso2-jenkins-bot Feb 17, 2025
47ba3b7
Merge pull request #2709 from Malith-19/fix-token-revocation-in-passw…
ThaminduDilshan Feb 17, 2025
740ad7a
Merge commit '8b1ca79f9df8ea410a2ffbf3a0a0b08e5c89a589' into 45ff91e7…
wso2-jenkins-bot Feb 17, 2025
a01481b
Stop issuing tokens for disabled idps.
mpmadhavig Feb 17, 2025
b9c09aa
Add unit tests.
mpmadhavig Feb 17, 2025
df662da
fix switching issue of cc grant based JWT tokens to sub orgs
AnuradhaSK Feb 17, 2025
ba65c7b
Merge pull request #2715 from mpmadhavig/saml2-bearer
mpmadhavig Feb 17, 2025
e22d30a
[WSO2 Release] [Jenkins #5228] [Release 7.0.246] prepare release v7.0…
wso2-jenkins-bot Feb 17, 2025
b91761a
[WSO2 Release] [Jenkins #5228] [Release 7.0.246] prepare for next dev…
wso2-jenkins-bot Feb 17, 2025
84d67c3
Merge pull request #2717 from AnuradhaSK/fix--cc-grant-request-switch
AnuradhaSK Feb 17, 2025
dd17804
[WSO2 Release] [Jenkins #5230] [Release 7.0.247] prepare release v7.0…
wso2-jenkins-bot Feb 17, 2025
f04412c
[WSO2 Release] [Jenkins #5230] [Release 7.0.247] prepare for next dev…
wso2-jenkins-bot Feb 17, 2025
ed111f7
Update to new request builder and processor contracts.
malithie Feb 17, 2025
3e976fe
Merge pull request #2710 from Malith-19/fix-org-role-filter-issue
SujanSanjula96 Feb 18, 2025
c7a616d
Merge pull request #2719 from malithie/action-improvement
malithie Feb 18, 2025
c5932a4
[WSO2 Release] [Jenkins #5232] [Release 7.0.248] prepare release v7.0…
wso2-jenkins-bot Feb 18, 2025
d487210
[WSO2 Release] [Jenkins #5232] [Release 7.0.248] prepare for next dev…
wso2-jenkins-bot Feb 18, 2025
82f527f
Merge commit 'd487210825f610dbff52c785205b9c8b7175741b' into c4b326bd…
wso2-jenkins-bot Feb 18, 2025
2e537c8
[WSO2 Release] [Jenkins #5233] [Release 7.0.249] prepare release v7.0…
wso2-jenkins-bot Feb 18, 2025
2818e97
[WSO2 Release] [Jenkins #5233] [Release 7.0.249] prepare for next dev…
wso2-jenkins-bot Feb 18, 2025
8ce0b80
Fix import paths of rule evaluation component
ashanthamara Feb 18, 2025
20515c8
Merge pull request #2720 from ashanthamara/package-refactor
malithie Feb 18, 2025
90c36a6
[WSO2 Release] [Jenkins #5235] [Release 7.0.250] prepare release v7.0…
wso2-jenkins-bot Feb 18, 2025
2d747e6
[WSO2 Release] [Jenkins #5235] [Release 7.0.250] prepare for next dev…
wso2-jenkins-bot Feb 18, 2025
a37f5a4
Update framework version.
malithie Feb 18, 2025
b16123f
Update actions/cache version.
malithie Feb 18, 2025
36ffddf
Fix import paths of action execution component classes
ashanthamara Feb 18, 2025
2093d00
Bump framework
ashanthamara Feb 18, 2025
71e30f4
Merge pull request #2722 from malithie/action-improvement
ashanthamara Feb 18, 2025
e9f7143
Merge remote-tracking branch 'upstream/master' into package-refactor
ashanthamara Feb 18, 2025
113b868
[WSO2 Release] [Jenkins #5237] [Release 7.0.251] prepare release v7.0…
wso2-jenkins-bot Feb 18, 2025
35cbaff
[WSO2 Release] [Jenkins #5237] [Release 7.0.251] prepare for next dev…
wso2-jenkins-bot Feb 18, 2025
5c1ea8c
Merge pull request #2724 from ashanthamara/package-refactor
ashanthamara Feb 18, 2025
8b4d5d0
[WSO2 Release] [Jenkins #5239] [Release 7.0.252] prepare release v7.0…
wso2-jenkins-bot Feb 18, 2025
c3b3529
[WSO2 Release] [Jenkins #5239] [Release 7.0.252] prepare for next dev…
wso2-jenkins-bot Feb 18, 2025
e5a5d78
Fix roles retrieval in user info response for sub org and fragment apps.
SujanSanjula96 Feb 18, 2025
46a983f
Update tests for getClaimsFromUserStore for sub orgs
SujanSanjula96 Feb 19, 2025
7a47c74
Add tests for OIDCClaimUtilTest
SujanSanjula96 Feb 19, 2025
853f444
Merge pull request #2721 from SujanSanjula96/fix-shared-roles
SujanSanjula96 Feb 19, 2025
e9b29d9
[WSO2 Release] [Jenkins #5241] [Release 7.0.253] prepare release v7.0…
wso2-jenkins-bot Feb 19, 2025
f04d876
[WSO2 Release] [Jenkins #5241] [Release 7.0.253] prepare for next dev…
wso2-jenkins-bot Feb 19, 2025
45484e8
Fix the client ids missing in filtering.
Malith-19 Feb 20, 2025
2cc27a3
Merge pull request #2726 from Malith-19/fix-client-ids-missing-in-fil…
SujanSanjula96 Feb 20, 2025
45d7c89
[WSO2 Release] [Jenkins #5243] [Release 7.0.254] prepare release v7.0…
wso2-jenkins-bot Feb 20, 2025
9db893b
[WSO2 Release] [Jenkins #5243] [Release 7.0.254] prepare for next dev…
wso2-jenkins-bot Feb 20, 2025
6d5cb32
Merge conflict
Eranda2001 Feb 20, 2025
9a04e81
Add-amr conflict resolve
Eranda2001 Feb 20, 2025
008f9a6
update getAmrValues to getAmrValue
Eranda2001 Feb 25, 2025
9ba2619
Merge conflicts
Eranda2001 Feb 25, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pr-builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
distribution: "adopt"
- name: Cache local Maven repository
id: cache-maven-m2
uses: actions/cache@v2
uses: actions/cache@v3
env:
cache-name: cache-m2
with:
Expand Down
4 changes: 2 additions & 2 deletions components/org.wso2.carbon.identity.api.server.dcr/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
<parent>
<groupId>org.wso2.carbon.identity.inbound.auth.oauth2</groupId>
<artifactId>identity-inbound-auth-oauth</artifactId>
<version>7.0.245-SNAPSHOT</version>
<version>7.0.255-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>

<artifactId>org.wso2.carbon.identity.api.server.dcr</artifactId>
<version>7.0.245-SNAPSHOT</version>
<version>7.0.255-SNAPSHOT</version>
<name>WSO2 Carbon - User DCR Rest API</name>
<description>WSO2 Carbon - User DCR Rest API</description>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
<parent>
<groupId>org.wso2.carbon.identity.inbound.auth.oauth2</groupId>
<artifactId>identity-inbound-auth-oauth</artifactId>
<version>7.0.245-SNAPSHOT</version>
<version>7.0.255-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent>

<artifactId>org.wso2.carbon.identity.api.server.oauth.scope</artifactId>
<version>7.0.245-SNAPSHOT</version>
<version>7.0.255-SNAPSHOT</version>

<name>WSO2 Carbon - Identity OAuth 2.0 Scope Rest APIs</name>
<description>Rest APIs for OAuth 2.0 Scope Handling</description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>org.wso2.carbon.identity.inbound.auth.oauth2</groupId>
<artifactId>identity-inbound-auth-oauth</artifactId>
<version>7.0.245-SNAPSHOT</version>
<version>7.0.255-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion components/org.wso2.carbon.identity.discovery/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<groupId>org.wso2.carbon.identity.inbound.auth.oauth2</groupId>
<artifactId>identity-inbound-auth-oauth</artifactId>
<relativePath>../../pom.xml</relativePath>
<version>7.0.245-SNAPSHOT</version>
<version>7.0.255-SNAPSHOT</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion components/org.wso2.carbon.identity.oauth.ciba/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<artifactId>identity-inbound-auth-oauth</artifactId>
<groupId>org.wso2.carbon.identity.inbound.auth.oauth2</groupId>
<version>7.0.245-SNAPSHOT</version>
<version>7.0.255-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<groupId>org.wso2.carbon.identity.inbound.auth.oauth2</groupId>
<artifactId>identity-inbound-auth-oauth</artifactId>
<relativePath>../../pom.xml</relativePath>
<version>7.0.245-SNAPSHOT</version>
<version>7.0.255-SNAPSHOT</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion components/org.wso2.carbon.identity.oauth.common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<groupId>org.wso2.carbon.identity.inbound.auth.oauth2</groupId>
<artifactId>identity-inbound-auth-oauth</artifactId>
<relativePath>../../pom.xml</relativePath>
<version>7.0.245-SNAPSHOT</version>
<version>7.0.255-SNAPSHOT</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<groupId>org.wso2.carbon.identity.inbound.auth.oauth2</groupId>
<artifactId>identity-inbound-auth-oauth</artifactId>
<relativePath>../../pom.xml</relativePath>
<version>7.0.245-SNAPSHOT</version>
<version>7.0.255-SNAPSHOT</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion components/org.wso2.carbon.identity.oauth.dcr/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<groupId>org.wso2.carbon.identity.inbound.auth.oauth2</groupId>
<artifactId>identity-inbound-auth-oauth</artifactId>
<relativePath>../../pom.xml</relativePath>
<version>7.0.245-SNAPSHOT</version>
<version>7.0.255-SNAPSHOT</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion components/org.wso2.carbon.identity.oauth.endpoint/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<groupId>org.wso2.carbon.identity.inbound.auth.oauth2</groupId>
<artifactId>identity-inbound-auth-oauth</artifactId>
<relativePath>../../pom.xml</relativePath>
<version>7.0.245-SNAPSHOT</version>
<version>7.0.255-SNAPSHOT</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4206,6 +4206,21 @@ private void associateAuthenticationHistory(SessionDataCacheEntry resultFromLogi
*/
private List<String> getAMRValues(List<String> authMethods, Map<String, AuthenticatedIdPData> authenticatedIdPs) {

boolean authenticatorAMREnabled = true;
if (authenticatorAMREnabled) {
List<String> resultantAuthMethods = new ArrayList<>();
for (Map.Entry<String, AuthenticatedIdPData> entry : authenticatedIdPs.entrySet()) {
if (entry.getValue() != null && entry.getValue().getAuthenticators() != null) {
for (AuthenticatorConfig authenticatorConfig : entry.getValue().getAuthenticators()) {
if (authenticatorConfig != null && authenticatorConfig.getAmrValue() != null) {
resultantAuthMethods.addAll(Arrays.asList(authenticatorConfig.getAmrValue()));
}
}
}
}
return resultantAuthMethods;
}

boolean readAMRValueFromIdp = Boolean.parseBoolean(IdentityUtil.getProperty(
OAuthConstants.READ_AMR_VALUE_FROM_IDP));
if (readAMRValueFromIdp) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,16 @@

package org.wso2.carbon.identity.oauth.endpoint.util;

import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.oltu.oauth2.common.error.OAuthError;
import org.wso2.carbon.identity.application.authentication.framework.exception.FrameworkException;
import org.wso2.carbon.identity.application.authentication.framework.handler.approles.exception.ApplicationRolesException;
import org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser;
import org.wso2.carbon.identity.application.authentication.framework.util.FrameworkConstants;
import org.wso2.carbon.identity.application.authentication.framework.util.FrameworkUtils;
import org.wso2.carbon.identity.application.common.model.ClaimMapping;
import org.wso2.carbon.identity.application.common.model.ServiceProvider;
Expand All @@ -50,6 +53,8 @@
import org.wso2.carbon.identity.oauth2.util.AuthzUtil;
import org.wso2.carbon.identity.oauth2.util.OAuth2Util;
import org.wso2.carbon.identity.openidconnect.OIDCClaimUtil;
import org.wso2.carbon.identity.organization.management.service.exception.OrganizationManagementException;
import org.wso2.carbon.identity.organization.management.service.util.OrganizationManagementUtil;
import org.wso2.carbon.user.api.RealmConfiguration;
import org.wso2.carbon.user.api.UserStoreException;
import org.wso2.carbon.user.core.UserRealm;
Expand Down Expand Up @@ -190,13 +195,15 @@ public static Map<String, Object> getClaimsFromUserStore(OAuth2TokenValidationRe
realm = getUserRealm(null, userAccessingTenantDomain);
try {
FrameworkUtils.startTenantFlow(userAccessingTenantDomain);
userClaims = getUserClaimsFromUserStore(sharedUserId, realm, claimURIList);
userClaims = getUserClaimsFromUserStoreWithResolvedRoles(authenticatedUser, serviceProvider,
sharedUserId, realm, claimURIList);
} finally {
FrameworkUtils.endTenantFlow();
}
} else {
realm = getUserRealm(null, userTenantDomain);
userClaims = getUserClaimsFromUserStore(userId, realm, claimURIList);
userClaims = getUserClaimsFromUserStoreWithResolvedRoles(authenticatedUser, serviceProvider,
userId, realm, claimURIList);
}

if (isNotEmpty(userClaims)) {
Expand Down Expand Up @@ -335,6 +342,42 @@ private static Map<String, String> getUserClaimsFromUserStore(String userId,
return userClaims;
}

private static Map<String, String> getUserClaimsFromUserStoreWithResolvedRoles(AuthenticatedUser authenticatedUser,
ServiceProvider serviceProvider,
String resolvedUserId,
UserRealm realm,
List<String> claimURIList)
throws UserStoreException {

Map<String, String> userClaims = getUserClaimsFromUserStore(resolvedUserId, realm, claimURIList);
try {
// Check whether the roles claim is requested.
boolean isRoleClaimRequested = CollectionUtils.isNotEmpty(claimURIList) &&
claimURIList.contains(FrameworkConstants.ROLES_CLAIM);
String appTenantDomain = serviceProvider.getTenantDomain();
// Check whether the application is a shared app or an application created in sub org.
boolean isSubOrgApp = OrganizationManagementUtil.isOrganization(appTenantDomain);
// Resolving roles claim for sub org apps and shared apps since backward compatibility is not needed.
if (isRoleClaimRequested && isSubOrgApp) {
String[] appAssociatedRoles = OIDCClaimUtil.getAppAssociatedRolesOfUser(authenticatedUser,
serviceProvider.getApplicationResourceId());
if (appAssociatedRoles != null && appAssociatedRoles.length > 0) {
// If application associated roles are returned, set the roles claim using resolved roles.
userClaims.put(FrameworkConstants.ROLES_CLAIM,
String.join(FrameworkUtils.getMultiAttributeSeparator(), appAssociatedRoles));
} else {
// If no roles are returned, remove the roles claim from user claims.
userClaims.remove(FrameworkConstants.ROLES_CLAIM);
}
}
} catch (ApplicationRolesException e) {
throw new UserStoreException("Error while retrieving application associated roles for user.", e);
} catch (OrganizationManagementException e) {
throw new UserStoreException("Error while checking whether application tenant domain is an organization.");
}
return userClaims;
}

private static UserRealm getUserRealm(String username,
String userTenantDomain) throws IdentityException, UserInfoEndpointException {

Expand Down
Loading
Loading