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

Introduce Resource Sharing Policy Management Component #416

Open
wants to merge 42 commits into
base: main
Choose a base branch
from

Conversation

BimsaraBodaragama
Copy link

@BimsaraBodaragama BimsaraBodaragama commented Nov 25, 2024

This PR adds a new component to manage resource-sharing policies between organizations in the WSO2 Identity Server. It enables defining, storing, and retrieving resource-sharing policies for users, applications, and identity providers.

Purpose

This feature addresses the need for a structured and scalable solution to manage resource-sharing policies across organizational hierarchies. It resolves the following issues:

Goals

  • Provide a unified interface for managing resource-sharing policies.
  • Enable consistent policy definitions across resource types.
  • Support dynamic and hierarchical sharing options, such as sharing with all current and future organizations or selected organizational hierarchies.

Approach

  • Created a new component for resource-sharing policy management.
  • Developed a core service with DAO and utility classes for CRUD operations.
  • Defined constants and enums for resource types and sharing policies.
  • Implemented robust exception handling mechanisms.

Release note

Introduced a centralized resource-sharing policy management service to unify and streamline sharing policies across all resource types.

Documentation

N/A (Documentation updates will be tracked separately.)

Test environment

  • JDK 11
  • macOS 15.1.1 (24B91)
  • H2 Database

Related Issue

Introduce a Centralized Resource Sharing Policy Management Service #21815

…licy record and shared resource attributes by resource sharing policy id
… attributes rather than deleting it from record id since that way of deletion is not currently needed.
… attributes rather than deleting it from record id since that way of deletion is not currently needed - Part 2.
@BimsaraBodaragama BimsaraBodaragama self-assigned this Nov 25, 2024
Copy link

codecov bot commented Nov 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 48.57%. Comparing base (021650f) to head (c30c9d5).

Additional details and impacted files
@@             Coverage Diff              @@
##               main     #416      +/-   ##
============================================
+ Coverage     47.13%   48.57%   +1.44%     
- Complexity     1024     1080      +56     
============================================
  Files           112      115       +3     
  Lines          6710     6898     +188     
  Branches        802      810       +8     
============================================
+ Hits           3163     3351     +188     
  Misses         3259     3259              
  Partials        288      288              
Flag Coverage Δ
unit 32.18% <100.00%> (+3.07%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@BimsaraBodaragama BimsaraBodaragama force-pushed the component/resource-sharing-policy-mgt branch from 7b3d125 to bd2a43f Compare December 6, 2024 05:16
AtomicReference<ResourceSharingPolicy> resourceSharingPolicy = new AtomicReference<>(null);

try {
namedJdbcTemplate.executeQuery(
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fetchSingle

throws ResourceSharingPolicyMgtServerException {

NamedJdbcTemplate namedJdbcTemplate = getNewTemplate();
AtomicReference<ResourceSharingPolicy> resourceSharingPolicy = new AtomicReference<>(null);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Research the need of AtomicReference

* these attributes.
* </p>
*/
public interface ResourceSharingPolicyHandlerService {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add two new methods POST and GET to both resource and its attributes at once.


String orgIdsString = policyHoldingOrganizationIds.stream().map(id -> "'" + id + "'")
.collect(Collectors.joining(","));
String query = GET_RESOURCE_SHARING_POLICIES_BY_ORG_IDS_HEAD + "(" + orgIdsString + ");";
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Write in a way to avoid to SQL injections.


@Override
public boolean deleteResourceSharingPolicyRecordById(int resourceSharingPolicyId,
String deleteRequestInitiatedOrgId)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deleteRequestInitiatedOrgId -> sharingPolicyInitiatedOrgId

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check all places.

pom.xml Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants