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

Return associating roles' allowed audience on request #515

Merged
merged 4 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.wso2.carbon.identity.api.server.application.management.v1.AdvancedApplicationConfiguration;
import org.wso2.carbon.identity.api.server.application.management.v1.AssociatedRolesConfig;
import javax.validation.constraints.*;


Expand Down Expand Up @@ -77,6 +78,7 @@ public static AccessEnum fromValue(String value) {
private String self;
private AdvancedApplicationConfiguration advancedConfigurations;
private String templateId;
private AssociatedRolesConfig associatedRoles;

/**
**/
Expand Down Expand Up @@ -276,6 +278,24 @@ public void setTemplateId(String templateId) {
this.templateId = templateId;
}

/**
**/
public ApplicationListItem associatedRoles(AssociatedRolesConfig associatedRoles) {

this.associatedRoles = associatedRoles;
return this;
}

@ApiModelProperty(value = "")
@JsonProperty("associatedRoles")
@Valid
public AssociatedRolesConfig getAssociatedRoles() {
return associatedRoles;
}
public void setAssociatedRoles(AssociatedRolesConfig associatedRoles) {
this.associatedRoles = associatedRoles;
}



@Override
Expand All @@ -298,12 +318,13 @@ public boolean equals(java.lang.Object o) {
Objects.equals(this.access, applicationListItem.access) &&
Objects.equals(this.self, applicationListItem.self) &&
Objects.equals(this.advancedConfigurations, applicationListItem.advancedConfigurations) &&
Objects.equals(this.templateId, applicationListItem.templateId);
Objects.equals(this.templateId, applicationListItem.templateId) &&
Objects.equals(this.associatedRoles, applicationListItem.associatedRoles);
}

@Override
public int hashCode() {
return Objects.hash(id, name, description, image, accessUrl, clientId, issuer, access, self, advancedConfigurations, templateId);
return Objects.hash(id, name, description, image, accessUrl, clientId, issuer, access, self, advancedConfigurations, templateId, associatedRoles);
}

@Override
Expand All @@ -323,6 +344,7 @@ public String toString() {
sb.append(" self: ").append(toIndentedString(self)).append("\n");
sb.append(" advancedConfigurations: ").append(toIndentedString(advancedConfigurations)).append("\n");
sb.append(" templateId: ").append(toIndentedString(templateId)).append("\n");
sb.append(" associatedRoles: ").append(toIndentedString(associatedRoles)).append("\n");
sb.append("}");
return sb.toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
import org.wso2.carbon.identity.application.common.model.ServiceProvider;
import org.wso2.carbon.identity.application.common.model.SpFileContent;
import org.wso2.carbon.identity.application.common.model.User;
import org.wso2.carbon.identity.application.common.util.IdentityApplicationConstants;
import org.wso2.carbon.identity.application.mgt.ApplicationConstants;
import org.wso2.carbon.identity.application.mgt.ApplicationManagementService;
import org.wso2.carbon.identity.application.mgt.AuthorizedAPIManagementService;
Expand Down Expand Up @@ -227,6 +228,7 @@ public class ServerApplicationManagementService {
SUPPORTED_REQUIRED_ATTRIBUTES.add(CLIENT_ID);
SUPPORTED_REQUIRED_ATTRIBUTES.add(TEMPLATE_ID);
SUPPORTED_REQUIRED_ATTRIBUTES.add(ISSUER);
SUPPORTED_REQUIRED_ATTRIBUTES.add(IdentityApplicationConstants.ALLOWED_ROLE_AUDIENCE_REQUEST_ATTRIBUTE_NAME);
}

@Autowired
Expand Down Expand Up @@ -1628,6 +1630,11 @@ private List<ApplicationListItem> getApplicationListItems(List<ServiceProvider>
if (requiredAttributes.stream().noneMatch(attribute -> attribute.equals(ISSUER))) {
applicationResponseModel.issuer(null);
}
if (requiredAttributes.stream()
.noneMatch(attribute -> attribute.equals(
IdentityApplicationConstants.ALLOWED_ROLE_AUDIENCE_REQUEST_ATTRIBUTE_NAME))) {
applicationResponseModel.associatedRoles(null);
}
applicationListItems.add(new ApplicationInfoWithRequiredPropsToApiModel().apply(applicationResponseModel));
}
return applicationListItems;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.wso2.carbon.identity.api.server.application.management.v1.AdvancedApplicationConfiguration;
import org.wso2.carbon.identity.api.server.application.management.v1.ApplicationListItem;
import org.wso2.carbon.identity.api.server.application.management.v1.ApplicationResponseModel;
import org.wso2.carbon.identity.api.server.application.management.v1.AssociatedRolesConfig;
import org.wso2.carbon.identity.api.server.common.Constants;
import org.wso2.carbon.identity.api.server.common.ContextLoader;

Expand Down Expand Up @@ -54,7 +55,18 @@ public ApplicationListItem apply(ApplicationResponseModel applicationResponseMod
.issuer(applicationResponseModel.getIssuer())
.advancedConfigurations(getAdvancedConfigurations(applicationResponseModel))
.templateId(applicationResponseModel.getTemplateId())
.self(getApplicationLocation(applicationResponseModel.getId()));
.self(getApplicationLocation(applicationResponseModel.getId()))
.associatedRoles(excludeAssociatedRoles(applicationResponseModel.getAssociatedRoles()));
}

private AssociatedRolesConfig excludeAssociatedRoles(AssociatedRolesConfig associatedRolesConfig) {

AssociatedRolesConfig configExcludingRoles = new AssociatedRolesConfig();
if (associatedRolesConfig == null) {
return configExcludingRoles;
}
configExcludingRoles.setAllowedAudience(associatedRolesConfig.getAllowedAudience());
return configExcludingRoles;
}

private AdvancedApplicationConfiguration getAdvancedConfigurations(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2456,9 +2456,9 @@ components:
required: false
description: |
Specifies the required parameters in the response.
Currently supports for only 'advancedConfigurations', 'templateId', 'clientId', and 'issuer' attributes.
Currently supports for only 'advancedConfigurations', 'templateId', 'clientId', 'issuer', and 'associatedRoles.allowedAudience' attributes.

/applications?attributes=advancedConfigurations,templateId,clientId
/applications?attributes=advancedConfigurations,templateId,clientId,associatedRoles.allowedAudience
schema:
type: string
exportSecretsQueryParam:
Expand Down Expand Up @@ -2587,7 +2587,9 @@ components:
templateId:
type: string
example: "980b8tester24c64a8a09a0d80abf8c337bd2555"

associatedRoles:
type: object
$ref: '#/components/schemas/AssociatedRolesConfig'
ApplicationModel:
type: object
required:
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@
<maven.buildnumber.plugin.version>1.4</maven.buildnumber.plugin.version>
<org.apache.felix.annotations.version>1.2.4</org.apache.felix.annotations.version>
<identity.governance.version>1.8.62</identity.governance.version>
<carbon.identity.framework.version>5.25.426</carbon.identity.framework.version>
<carbon.identity.framework.version>5.25.430</carbon.identity.framework.version>
<maven.findbugsplugin.version>3.0.5</maven.findbugsplugin.version>
<identity.workflow.impl.bps.version>5.2.0</identity.workflow.impl.bps.version>
<maven.checkstyleplugin.excludes>**/gen/**/*</maven.checkstyleplugin.excludes>
Expand Down
Loading