-
Notifications
You must be signed in to change notification settings - Fork 543
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
Introduce application role #4873
Closed
Closed
Changes from 18 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
c2d1d55
add changes
shashimalcse c208ffc
add changes
shashimalcse 6c4b1b1
add changes
shashimalcse 2f02e6f
Add validations
shashimalcse be5dd89
fix app role update
shashimalcse 6409377
add licenses
shashimalcse f8cccb8
fix idp null
shashimalcse 24cef0d
imporve error msg
shashimalcse 5fc3a85
add return for patch app role
shashimalcse 7cedd73
initial unit tests
shashimalcse 70d31f9
change update return
shashimalcse d640fff
add unit tests
shashimalcse c0ad0df
add method comments
shashimalcse 63fae60
add manager tests
shashimalcse ae86c1f
add permission assigning to app role
shashimalcse f691dca
fix idp endpoint changes
shashimalcse 966bc0d
fix db schema curser keys
shashimalcse 04ba731
fix groupname check null
shashimalcse 8246103
add support for rbac
shashimalcse 065eece
fix role patching
shashimalcse 69ea785
add method to validate role name
shashimalcse File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
201 changes: 201 additions & 0 deletions
201
components/application-role-mgt/org.wso2.carbon.identity.application.role.mgt/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,201 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
~ Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). | ||
~ | ||
~ WSO2 LLC. licenses this file to you under the Apache License, | ||
~ Version 2.0 (the "License"); you may not use this file except | ||
~ in compliance with the License. | ||
~ You may obtain a copy of the License at | ||
~ | ||
~ http://www.apache.org/licenses/LICENSE-2.0 | ||
~ | ||
~ Unless required by applicable law or agreed to in writing, | ||
~ software distributed under the License is distributed on an | ||
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
~ KIND, either express or implied. See the License for the | ||
~ specific language governing permissions and limitations | ||
~ under the License. | ||
--> | ||
|
||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<groupId>org.wso2.carbon.identity.framework</groupId> | ||
<artifactId>application-role-mgt</artifactId> | ||
<version>5.25.287-SNAPSHOT</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
<artifactId>org.wso2.carbon.identity.application.role.mgt</artifactId> | ||
<name>Application Role Management Service</name> | ||
<packaging>bundle</packaging> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.apache.felix</groupId> | ||
<artifactId>org.apache.felix.scr.ds-annotations</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.wso2.carbon.identity.framework</groupId> | ||
<artifactId>org.wso2.carbon.identity.core</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.wso2.carbon.identity.framework</groupId> | ||
<artifactId>org.wso2.carbon.idp.mgt</artifactId> | ||
</dependency> | ||
<!-- Test dependencies --> | ||
<dependency> | ||
<groupId>org.jacoco</groupId> | ||
<artifactId>org.jacoco.agent</artifactId> | ||
<classifier>runtime</classifier> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.testng</groupId> | ||
<artifactId>testng</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.h2database</groupId> | ||
<artifactId>h2</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.powermock</groupId> | ||
<artifactId>powermock-api-mockito2</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.powermock</groupId> | ||
<artifactId>powermock-module-testng</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.powermock</groupId> | ||
<artifactId>powermock-module-testng-common</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.wso2.carbon.identity.framework</groupId> | ||
<artifactId>org.wso2.carbon.identity.testutil</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.felix</groupId> | ||
<artifactId>maven-bundle-plugin</artifactId> | ||
<extensions>true</extensions> | ||
<configuration> | ||
<instructions> | ||
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName> | ||
<Bundle-Name>${project.artifactId}</Bundle-Name> | ||
<Bundle-Description>Application Role Management Service Bundle</Bundle-Description> | ||
<Private-Package>org.wso2.carbon.identity.application.role.mgt.internal | ||
</Private-Package> | ||
<Export-Package> | ||
!org.wso2.carbon.identity.application.role.mgt.internal, | ||
org.wso2.carbon.identity.application.role.mgt.*; | ||
version="${project.version}", | ||
</Export-Package> | ||
<Import-Package> | ||
javax.sql, | ||
org.osgi.framework; version="${osgi.framework.imp.pkg.version.range}", | ||
org.osgi.service.component; version="${osgi.service.component.imp.pkg.version.range}", | ||
org.apache.commons.lang; version="${commons-lang.wso2.osgi.version.range}", | ||
org.apache.commons.logging; version="${import.package.version.commons.logging}", | ||
org.wso2.carbon.context; version="${carbon.kernel.package.import.version.range}", | ||
org.wso2.carbon.identity.core.*; version="${carbon.identity.package.import.version.range}", | ||
org.wso2.carbon.database.utils.jdbc; | ||
version="${org.wso2.carbon.database.utils.version.range}", | ||
org.wso2.carbon.user.api; version="${carbon.user.api.imp.pkg.version.range}", | ||
org.wso2.carbon.user.core.*;version="${carbon.kernel.package.import.version.range}", | ||
org.wso2.carbon.database.utils.jdbc.exceptions;version="${org.wso2.carbon.database.utils.version.range}", | ||
org.wso2.carbon.utils; version="${carbon.kernel.package.import.version.range}", | ||
org.wso2.carbon.idp.mgt.*; version="${carbon.identity.package.import.version.range}", | ||
org.wso2.carbon.identity.application.common.*; version="${carbon.identity.package.import.version.range}", | ||
</Import-Package> | ||
</instructions> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<version>${maven.surefire.plugin.version}</version> | ||
<configuration> | ||
<argLine> | ||
--add-opens java.xml/jdk.xml.internal=ALL-UNNAMED | ||
--add-exports java.base/jdk.internal.loader=ALL-UNNAMED | ||
</argLine> | ||
<suiteXmlFiles> | ||
<suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile> | ||
</suiteXmlFiles> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.jacoco</groupId> | ||
<artifactId>jacoco-maven-plugin</artifactId> | ||
<version>${jacoco.version}</version> | ||
<executions> | ||
<execution> | ||
<id>default-prepare-agent</id> | ||
<goals> | ||
<goal>prepare-agent</goal> | ||
</goals> | ||
</execution> | ||
<execution> | ||
<id>default-prepare-agent-integration</id> | ||
<goals> | ||
<goal>prepare-agent-integration</goal> | ||
</goals> | ||
</execution> | ||
<execution> | ||
<id>default-report</id> | ||
<goals> | ||
<goal>report</goal> | ||
</goals> | ||
</execution> | ||
<execution> | ||
<id>default-report-integration</id> | ||
<goals> | ||
<goal>report-integration</goal> | ||
</goals> | ||
</execution> | ||
<execution> | ||
<id>default-check</id> | ||
<goals> | ||
<goal>check</goal> | ||
</goals> | ||
<configuration> | ||
<rules> | ||
<rule implementation="org.jacoco.maven.RuleConfiguration"> | ||
<element>BUNDLE</element> | ||
<limits> | ||
<limit implementation="org.jacoco.report.check.Limit"> | ||
<counter>COMPLEXITY</counter> | ||
<value>COVEREDRATIO</value> | ||
<minimum>0.90</minimum> | ||
</limit> | ||
</limits> | ||
</rule> | ||
</rules> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.codehaus.mojo</groupId> | ||
<artifactId>findbugs-maven-plugin</artifactId> | ||
<configuration> | ||
<threshold>High</threshold> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
140 changes: 140 additions & 0 deletions
140
...t/src/main/java/org/wso2/carbon/identity/application/role/mgt/ApplicationRoleManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
/* | ||
* Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). | ||
* | ||
* WSO2 LLC. licenses this file to you under the Apache License, | ||
* Version 2.0 (the "License"); you may not use this file except | ||
* in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.wso2.carbon.identity.application.role.mgt; | ||
|
||
import org.wso2.carbon.identity.application.role.mgt.exceptions.ApplicationRoleManagementException; | ||
import org.wso2.carbon.identity.application.role.mgt.model.ApplicationRole; | ||
import org.wso2.carbon.identity.application.role.mgt.model.Group; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Application Role Manager. | ||
*/ | ||
public interface ApplicationRoleManager { | ||
|
||
/** | ||
* Add application role. | ||
* | ||
* @param applicationRole Application role. | ||
* @throws ApplicationRoleManagementException Error occurred while adding application role. | ||
*/ | ||
ApplicationRole addApplicationRole(ApplicationRole applicationRole) throws ApplicationRoleManagementException; | ||
|
||
/** | ||
* Update application role. | ||
* | ||
* @param roleId role Id. | ||
* @param newName new role name. | ||
* @param addedScopes List of scopes to be added. | ||
* @param removedScopes List of scopes to be removed. | ||
* @throws ApplicationRoleManagementException Error occurred while updating the application role. | ||
*/ | ||
ApplicationRole updateApplicationRole(String applicationId, String roleId, String newName, List<String> addedScopes, | ||
List<String> removedScopes) throws ApplicationRoleManagementException; | ||
|
||
/** | ||
* Get the application role by role id. | ||
* | ||
* @param roleId Role id. | ||
* @return Application role. | ||
* @throws ApplicationRoleManagementException Error occurred while retrieving the application role. | ||
*/ | ||
ApplicationRole getApplicationRoleById(String roleId) throws ApplicationRoleManagementException; | ||
|
||
/** | ||
* Get all the application roles by application id. | ||
* | ||
* @param applicationId Application id. | ||
* @return Application roles. | ||
* @throws ApplicationRoleManagementException Error occurred while retrieving the application roles of a given app. | ||
*/ | ||
List<ApplicationRole> getApplicationRoles(String applicationId) throws ApplicationRoleManagementException; | ||
|
||
/** | ||
* Delete application role. | ||
* | ||
* @param roleId Role id. | ||
* @throws ApplicationRoleManagementException Error occurred while deleting the application role. | ||
*/ | ||
void deleteApplicationRole(String roleId) throws ApplicationRoleManagementException; | ||
|
||
|
||
/** | ||
* Update the list of assigned users for an application role. | ||
* | ||
* @param roleId Application role ID. | ||
* @param addedUsers List of user IDs to be assigned. | ||
* @param removedUsers List of user IDs to be unassigned. | ||
* @throws ApplicationRoleManagementException Error occurred while updating the application role. | ||
*/ | ||
ApplicationRole updateApplicationRoleAssignedUsers(String roleId, List<String> addedUsers, | ||
List<String> removedUsers) | ||
throws ApplicationRoleManagementException; | ||
|
||
/** | ||
* Get the list of assigned users of an application role. | ||
* | ||
* @param roleId Application role ID. | ||
* @throws ApplicationRoleManagementException Error occurred while updating the application role. | ||
*/ | ||
ApplicationRole getApplicationRoleAssignedUsers(String roleId) throws ApplicationRoleManagementException; | ||
|
||
/** | ||
* Update the list of assigned groups for an application role. | ||
* | ||
* @param roleId Application role ID. | ||
* @param addedGroups List of group IDs to be assigned. | ||
* @param removedGroups List of group IDs to be unassigned. | ||
* @throws ApplicationRoleManagementException Error occurred while updating the application role. | ||
*/ | ||
ApplicationRole updateApplicationRoleAssignedGroups(String roleId, List<Group> addedGroups, | ||
List<String> removedGroups) throws ApplicationRoleManagementException; | ||
|
||
/** | ||
* Get the list of assigned groups of an application role. | ||
* | ||
* @param roleId Application role ID. | ||
* @throws ApplicationRoleManagementException Error occurred while updating the application role. | ||
*/ | ||
ApplicationRole getApplicationRoleAssignedGroups(String roleId, String idpId) | ||
throws ApplicationRoleManagementException; | ||
|
||
/** | ||
* Get the list of application roles of a user. | ||
* | ||
* @param userId user ID. | ||
* @param tenantDomain tenant domain. | ||
* @throws ApplicationRoleManagementException Error occurred while updating the application role. | ||
*/ | ||
List<ApplicationRole> getApplicationRolesByUserId(String userId, String tenantDomain) | ||
throws ApplicationRoleManagementException; | ||
|
||
/** | ||
* Get the list of application roles of a group. | ||
* | ||
* @param groupId group ID. | ||
* @param tenantDomain tenant domain. | ||
* @throws ApplicationRoleManagementException Error occurred while updating the application role. | ||
*/ | ||
List<ApplicationRole> getApplicationRolesByGroupId(String groupId, String tenantDomain) | ||
throws ApplicationRoleManagementException; | ||
|
||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix formatting