Skip to content

Commit

Permalink
Merge branch 'master' into reduce_token_issue_lock_weight
Browse files Browse the repository at this point in the history
  • Loading branch information
indeewari authored Jan 26, 2025
2 parents 04e0daf + 4e516a5 commit bc90af4
Show file tree
Hide file tree
Showing 56 changed files with 590 additions and 146 deletions.
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.226-SNAPSHOT</version>
<version>7.0.229-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>

<artifactId>org.wso2.carbon.identity.api.server.dcr</artifactId>
<version>7.0.226-SNAPSHOT</version>
<version>7.0.229-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.226-SNAPSHOT</version>
<version>7.0.229-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent>

<artifactId>org.wso2.carbon.identity.api.server.oauth.scope</artifactId>
<version>7.0.226-SNAPSHOT</version>
<version>7.0.229-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.226-SNAPSHOT</version>
<version>7.0.229-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.226-SNAPSHOT</version>
<version>7.0.229-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.226-SNAPSHOT</version>
<version>7.0.229-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.226-SNAPSHOT</version>
<version>7.0.229-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.226-SNAPSHOT</version>
<version>7.0.229-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.226-SNAPSHOT</version>
<version>7.0.229-SNAPSHOT</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
5 changes: 3 additions & 2 deletions 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.226-SNAPSHOT</version>
<version>7.0.229-SNAPSHOT</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down Expand Up @@ -180,7 +180,8 @@
</Import-Package>
<Export-Package>
!org.wso2.carbon.identity.oauth.dcr.internal,
org.wso2.carbon.identity.oauth.dcr.*;version="${identity.inbound.auth.oauth.exp.pkg.version}"
org.wso2.carbon.identity.oauth.dcr.*;version="${identity.inbound.auth.oauth.exp.pkg.version}",
org.wso2.carbon.identity.oauth.dcr.handler.*;version="${identity.inbound.auth.oauth.exp.pkg.version}"
</Export-Package>
</instructions>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import org.wso2.carbon.identity.application.mgt.ApplicationManagementService;
import org.wso2.carbon.identity.configuration.mgt.core.ConfigurationManager;
import org.wso2.carbon.identity.oauth.dcr.handler.AdditionalAttributeFilter;
import org.wso2.carbon.identity.oauth.dcr.handler.RegistrationHandler;
import org.wso2.carbon.identity.oauth.dcr.handler.UnRegistrationHandler;
import org.wso2.carbon.identity.oauth2.token.bindings.TokenBinder;
Expand All @@ -41,6 +42,7 @@ public class DCRDataHolder {
private List<RegistrationHandler> registrationHandlerList = new ArrayList<>();
private List<UnRegistrationHandler> unRegistrationHandlerList = new ArrayList<>();
private List<TokenBinder> tokenBinders = new ArrayList<>();
private AdditionalAttributeFilter additionalAttributeFilter = null;
private ConfigurationManager configurationManager;
private OrganizationManager organizationManager;

Expand Down Expand Up @@ -122,4 +124,14 @@ public void setOrganizationManager(OrganizationManager organizationManager) {

this.organizationManager = organizationManager;
}

public AdditionalAttributeFilter getAdditionalAttributeFilter() {

return additionalAttributeFilter;
}

public void setAdditionalAttributeFilter(AdditionalAttributeFilter additionalAttributeFilter) {

this.additionalAttributeFilter = additionalAttributeFilter;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import org.wso2.carbon.identity.oauth.dcr.factory.HttpUnregistrationResponseFactory;
import org.wso2.carbon.identity.oauth.dcr.factory.RegistrationRequestFactory;
import org.wso2.carbon.identity.oauth.dcr.factory.UnregistrationRequestFactory;
import org.wso2.carbon.identity.oauth.dcr.handler.AdditionalAttributeFilter;
import org.wso2.carbon.identity.oauth.dcr.handler.RegistrationHandler;
import org.wso2.carbon.identity.oauth.dcr.handler.UnRegistrationHandler;
import org.wso2.carbon.identity.oauth.dcr.processor.DCRProcessor;
Expand Down Expand Up @@ -273,4 +274,19 @@ protected void unsetOrganizationManager(OrganizationManager organizationManager)
DCRDataHolder.getInstance().setOrganizationManager(null);
log.debug("Unset organization management service.");
}

@Reference(name = "identity.oauth.dcr.attribute.filter",
service = AdditionalAttributeFilter.class,
cardinality = ReferenceCardinality.MULTIPLE,
policy = ReferencePolicy.DYNAMIC,
unbind = "unsetAdditionalAttributeFilter")
protected void setAdditionalAttributeFilter(AdditionalAttributeFilter additionalAttributeFilter) {

DCRDataHolder.getInstance().setAdditionalAttributeFilter(additionalAttributeFilter);
}

protected void unsetAdditionalAttributeFilter(AdditionalAttributeFilter tokenBinderInfo) {

DCRDataHolder.getInstance().setAdditionalAttributeFilter(null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import org.wso2.carbon.context.CarbonContext;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.identity.application.common.IdentityApplicationManagementException;
import org.wso2.carbon.identity.application.common.IdentityApplicationManagementValidationException;
import org.wso2.carbon.identity.application.common.model.AssociatedRolesConfig;
import org.wso2.carbon.identity.application.common.model.InboundAuthenticationConfig;
import org.wso2.carbon.identity.application.common.model.InboundAuthenticationRequestConfig;
Expand All @@ -41,7 +40,6 @@
import org.wso2.carbon.identity.oauth.IdentityOAuthAdminException;
import org.wso2.carbon.identity.oauth.IdentityOAuthClientException;
import org.wso2.carbon.identity.oauth.OAuthAdminService;
import org.wso2.carbon.identity.oauth.common.OAuth2ErrorCodes;
import org.wso2.carbon.identity.oauth.common.OAuthConstants;
import org.wso2.carbon.identity.oauth.common.exception.InvalidOAuthClientException;
import org.wso2.carbon.identity.oauth.config.OAuthServerConfiguration;
Expand All @@ -67,7 +65,6 @@
import org.wso2.carbon.identity.organization.management.service.exception.OrganizationManagementException;
import org.wso2.carbon.user.api.UserStoreException;

import java.lang.reflect.InvocationTargetException;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -120,18 +117,8 @@ public Application getApplication(String clientId) throws DCRMException {
Application application = buildResponse(consumerAppDTO, tenantDomain);
application.setExtAllowedAudience(serviceProvider.getAssociatedRolesConfig().getAllowedAudience());

String attributeFilterName = IdentityUtil.getProperty(OAuthConstants.ADDITIONAL_ATTRIBUTE_FILTER);
if (StringUtils.isNotBlank(attributeFilterName)) {
AdditionalAttributeFilter attributeHandler;
try {
attributeHandler = (AdditionalAttributeFilter)
Class.forName(attributeFilterName).getDeclaredConstructor().newInstance();
} catch (ClassNotFoundException | NoSuchMethodException | InstantiationException |
IllegalAccessException | InvocationTargetException e) {
log.error("Configured DCR additional attribute handler cannot be loaded");
throw new DCRMServerException(OAuth2ErrorCodes.SERVER_ERROR,
DCRMConstants.ErrorMessages.ADDITIONAL_ATTRIBUTE_ERROR.getMessage(), e);
}
AdditionalAttributeFilter attributeHandler = DCRDataHolder.getInstance().getAdditionalAttributeFilter();
if (attributeHandler != null) {
List<String> responseAttributes = attributeHandler.getResponseAttributeKeys();
Map<String, String> storedAttributes = Arrays.stream(serviceProvider.getSpProperties())
.filter(entry -> responseAttributes.contains(entry.getName()))
Expand Down Expand Up @@ -285,17 +272,8 @@ public Application updateApplication(ApplicationUpdateRequest updateRequest, Str
}

//Validating and filtering additional attributes via extension
String attributeFilterName = IdentityUtil.getProperty(OAuthConstants.ADDITIONAL_ATTRIBUTE_FILTER);
if (StringUtils.isNotBlank(attributeFilterName)) {
try {
attributeHandler = (AdditionalAttributeFilter)
Class.forName(attributeFilterName).getDeclaredConstructor().newInstance();
} catch (ClassNotFoundException | NoSuchMethodException | InstantiationException |
IllegalAccessException | InvocationTargetException e) {
log.error("Configured DCR additional attribute handler cannot be loaded");
throw new DCRMServerException(OAuth2ErrorCodes.SERVER_ERROR,
DCRMConstants.ErrorMessages.ADDITIONAL_ATTRIBUTE_ERROR.getMessage(), e);
}
attributeHandler = DCRDataHolder.getInstance().getAdditionalAttributeFilter();
if (attributeHandler != null) {
if (ssaClaims != null || !updateRequest.getAdditionalAttributes().isEmpty()) {
processedAttributes = attributeHandler.filterDCRUpdateAttributes(updateRequest, ssaClaims,
sp.getSpProperties());
Expand Down Expand Up @@ -595,20 +573,11 @@ private Application createOAuthApplication(ApplicationRegistrationRequest regist

ServiceProvider serviceProvider;
Map<String, Object> processedAttributes = null;
AdditionalAttributeFilter attributeHandler = null;

//Validating and filtering additional attributes via extension
String attributeFilterName = IdentityUtil.getProperty(OAuthConstants.ADDITIONAL_ATTRIBUTE_FILTER);
if (StringUtils.isNotBlank(attributeFilterName)) {
try {
attributeHandler = (AdditionalAttributeFilter)
Class.forName(attributeFilterName).getDeclaredConstructor().newInstance();
} catch (ClassNotFoundException | NoSuchMethodException | InstantiationException | IllegalAccessException |
InvocationTargetException e) {
log.error("Configured DCR additional attribute handler cannot be loaded");
throw new DCRMServerException(OAuth2ErrorCodes.SERVER_ERROR,
DCRMConstants.ErrorMessages.ADDITIONAL_ATTRIBUTE_ERROR.getMessage(), e);
}
AdditionalAttributeFilter attributeHandler = DCRDataHolder.getInstance().getAdditionalAttributeFilter();
if (attributeHandler != null) {

if (ssaClaims != null || !registrationRequest.getAdditionalAttributes().isEmpty()) {
processedAttributes = attributeHandler.filterDCRRegisterAttributes(registrationRequest, ssaClaims);
}
Expand Down Expand Up @@ -978,9 +947,6 @@ private void updateServiceProvider(ServiceProvider serviceProvider, String tenan
try {
DCRDataHolder.getInstance().getApplicationManagementService()
.updateApplication(serviceProvider, tenantDomain, userName);
} catch (IdentityApplicationManagementValidationException e) {
throw DCRMUtils.generateClientException(DCRMConstants.ErrorMessages.BAD_REQUEST_INVALID_SP_INPUT,
serviceProvider.getApplicationName());
} catch (IdentityApplicationManagementException e) {
throw DCRMUtils.generateServerException(
DCRMConstants.ErrorMessages.FAILED_TO_UPDATE_SP, serviceProvider.getApplicationName(), e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import org.wso2.carbon.identity.oauth.dcr.exception.DCRMClientException;
import org.wso2.carbon.identity.oauth.dcr.exception.DCRMException;
import org.wso2.carbon.identity.oauth.dcr.exception.DCRMServerException;
import org.wso2.carbon.identity.oauth.dcr.handler.AdditionalAttributeFilter;
import org.wso2.carbon.identity.oauth.dcr.internal.DCRDataHolder;
import org.wso2.carbon.identity.oauth.dcr.util.DCRConstants;
import org.wso2.carbon.identity.oauth.dcr.util.ErrorCodes;
Expand Down Expand Up @@ -132,6 +133,7 @@ public void setUp() throws Exception {
mockOAuthAdminService = mock(OAuthAdminService.class);
applicationRegistrationRequest = new ApplicationRegistrationRequest();
applicationRegistrationRequest.setClientName(dummyClientName);
applicationRegistrationRequest.setAdditionalAttributes(new HashMap<>());
dcrmService = new DCRMService();
mockApplicationManagementService = mock(ApplicationManagementService.class);
DCRDataHolder dcrDataHolder = DCRDataHolder.getInstance();
Expand All @@ -148,6 +150,17 @@ public void setUp() throws Exception {
mockedUserStoreManager = mock(AbstractUserStoreManager.class);
mockConfigurationManager = mock(ConfigurationManager.class);
DCRDataHolder.getInstance().setConfigurationManager(mockConfigurationManager);

List<String> responseKeys = new ArrayList<>();
Map<String, Object> processedAttributes = new HashMap<>();
AdditionalAttributeFilter additionalAttributeFilter = mock(AdditionalAttributeFilter.class);
lenient().when(additionalAttributeFilter.filterDCRRegisterAttributes(any(), any()))
.thenReturn(processedAttributes);
lenient().when(additionalAttributeFilter.filterDCRUpdateAttributes(any(), any(), any()))
.thenReturn(processedAttributes);
lenient().when(additionalAttributeFilter.processDCRGetAttributes(any())).thenReturn(processedAttributes);
lenient().when(additionalAttributeFilter.getResponseAttributeKeys()).thenReturn(responseKeys);
DCRDataHolder.getInstance().setAdditionalAttributeFilter(additionalAttributeFilter);
}

@AfterMethod
Expand Down Expand Up @@ -1104,6 +1117,8 @@ private OAuthConsumerAppDTO updateApplication()
applicationUpdateRequest.setGrantTypes(dummyGrantTypes);
applicationUpdateRequest.setTokenType(dummyTokenType);
applicationUpdateRequest.setBackchannelLogoutUri(dummyBackchannelLogoutUri);
applicationUpdateRequest.setAdditionalAttributes(new HashMap<>());


OAuthConsumerAppDTO dto = new OAuthConsumerAppDTO();
dto.setApplicationName(dummyClientName);
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.226-SNAPSHOT</version>
<version>7.0.229-SNAPSHOT</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<parent>
<artifactId>identity-inbound-auth-oauth</artifactId>
<groupId>org.wso2.carbon.identity.inbound.auth.oauth2</groupId>
<version>7.0.226-SNAPSHOT</version>
<version>7.0.229-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion components/org.wso2.carbon.identity.oauth.par/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.226-SNAPSHOT</version>
<version>7.0.229-SNAPSHOT</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion components/org.wso2.carbon.identity.oauth.rar/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.226-SNAPSHOT</version>
<version>7.0.229-SNAPSHOT</version>
</parent>

<modelVersion>4.0.0</modelVersion>
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.226-SNAPSHOT</version>
<version>7.0.229-SNAPSHOT</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion components/org.wso2.carbon.identity.oauth.stub/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.226-SNAPSHOT</version>
<version>7.0.229-SNAPSHOT</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion components/org.wso2.carbon.identity.oauth.ui/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.226-SNAPSHOT</version>
<version>7.0.229-SNAPSHOT</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion components/org.wso2.carbon.identity.oauth/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.226-SNAPSHOT</version>
<version>7.0.229-SNAPSHOT</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
Loading

0 comments on commit bc90af4

Please sign in to comment.