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

feat(opensearch): restrict search view access based on user roles and permissions #5932

Merged
merged 6 commits into from
Oct 4, 2024

Conversation

tsdk02
Copy link
Contributor

@tsdk02 tsdk02 commented Sep 18, 2024

Type of Change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring
  • Dependency updates
  • Documentation
  • CI/CD

Description

Fixes the issue raised here: https://github.com/juspay/hyperswitch-cloud/issues/6759

  • Currently, a profile level user is able to see the other profile payments list when using global-search, irrespective of whether he has permissions or not. But the user will not be able to view the details related to the payments upon clicking the particular payment.

  • This PR fixes this behaviour by restricting the profiles / merchants to be searched based on the user roles associated with the role_id and the permissions associated with the user role

  • Now, only if the use role has the necessary READ permissions to access the indexes, he would be able to search the payments related to that particular profile/merchant.

  • The search_params will now be constructed with only those ProfileLevel / MerchantLevel / OrgLevel entities which will be searched through the opensearch query.

Additional Changes

  • This PR modifies the API contract
  • This PR modifies the database schema
  • This PR modifies application configuration/environment variables

Motivation and Context

To preserve confidentiality of the payment details

How did you test it?

Try to search payments of a profile from another profile which doesn't have access to the profile where the payments are present. Results should not show up while using global search.

Checklist

  • I formatted the code cargo +nightly fmt --all
  • I addressed lints thrown by cargo clippy
  • I reviewed the submitted code
  • I added unit tests for my changes where possible

@tsdk02 tsdk02 added the C-bug Category: Bug label Sep 18, 2024
@tsdk02 tsdk02 self-assigned this Sep 18, 2024
@tsdk02 tsdk02 requested review from a team as code owners September 18, 2024 06:53
Copy link

semanticdiff-com bot commented Sep 18, 2024

Review changes with SemanticDiff.

Analyzed 3 of 4 files.

Overall, the semantic diff is 10% smaller than the GitHub diff.

Filename Status
✔️ crates/router/src/analytics.rs 7.14% smaller
✔️ crates/router/src/consts/opensearch.rs 31.91% smaller
✔️ crates/analytics/src/opensearch.rs Analyzed
config/dashboard.toml Unsupported file format

crates/router/src/analytics.rs Show resolved Hide resolved
crates/router/src/analytics.rs Outdated Show resolved Hide resolved
@Gnanasundari24 Gnanasundari24 added this pull request to the merge queue Oct 4, 2024
Merged via the queue into main with commit caa0693 Oct 4, 2024
21 checks passed
@Gnanasundari24 Gnanasundari24 deleted the search-api-profile-view branch October 4, 2024 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat(opensearch): restrict search view access based on user roles and permissions
4 participants