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

refactor(analytics): Create new permissions for Generate Report APIs #5178

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

Conversation

ThisIsMani
Copy link
Contributor

@ThisIsMani ThisIsMani commented Jul 2, 2024

Type of Change

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

Description

Currently, internal users are unable to access payment generate report as it requires PaymentWrite.

And other reports are having Analytics permission, but in the Front-end, the option is in Operations tab.

Because Generate reports option is present in both Analytics and Operations, there will be a new permission, which will be available for both Operations and Analytics groups.

Additional Changes

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

Motivation and Context

Closes #5177.

How did you test it?

curl 'http://localhost:8080/analytics/v1/report/payments' \
  -H 'authorization: Bearer Internal user JWT' \
  --data-raw '{"timeRange":{"startTime":"2024-07-01T11:34:38Z","endTime":"2024-07-02T11:34:38.441Z"},"dimensions":[]}'

When this API is hit by a internal user, this API should send email with report.

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

@ThisIsMani ThisIsMani added S-waiting-on-review Status: This PR has been implemented and needs to be reviewed C-refactor Category: Refactor A-Analytics labels Jul 2, 2024
@ThisIsMani ThisIsMani self-assigned this Jul 2, 2024
@ThisIsMani ThisIsMani requested a review from a team as a code owner July 2, 2024 12:20
ivor-juspay
ivor-juspay previously approved these changes Jul 3, 2024
@@ -592,7 +592,7 @@ pub mod routes {
.await
.map(ApplicationResponse::Json)
},
&auth::JWTAuth(Permission::Analytics),
&auth::JWTAuth(Permission::RefundRead),
Copy link
Contributor

Choose a reason for hiding this comment

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

will users with RefundWrite get RefundRead permission too?

Copy link
Contributor Author

@ThisIsMani ThisIsMani Jul 3, 2024

Choose a reason for hiding this comment

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

User Roles are made up of groups, and those groups consists of a set of permissions.

So if there is a group names OperationsWrite, then in that group, we put all the read and write permissions for operations like payments, refunds, etc..

So, users will never have only RefundWrite permission, if they have it, they will also have RefundRead as well. As both of them will be in the same group.

lsampras
lsampras previously approved these changes Jul 3, 2024
@ThisIsMani ThisIsMani dismissed stale reviews from lsampras and ivor-juspay via ee47940 July 8, 2024 09:59
@ThisIsMani ThisIsMani requested a review from a team as a code owner July 8, 2024 09:59
@ThisIsMani ThisIsMani changed the title refactor(analytics): Change permissions for report APIs refactor(analytics): Create permissions for Generate Report APIs Jul 8, 2024
@ThisIsMani ThisIsMani changed the title refactor(analytics): Create permissions for Generate Report APIs refactor(analytics): Create new permissions for Generate Report APIs Jul 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Analytics C-refactor Category: Refactor S-waiting-on-review Status: This PR has been implemented and needs to be reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

refactor(reports): Change permissions for report APIs
3 participants