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(auth): Add Authorization for JWT Authentication types #2973

Merged
merged 9 commits into from
Nov 24, 2023

Conversation

ThisIsMani
Copy link
Contributor

@ThisIsMani ThisIsMani commented Nov 24, 2023

Type of Change

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

Description

This PR adds required permissions for all APIs using JWT related auth types and a permission module which can be used to control the permissions.

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 support user roles and permissions.

How did you test it?

Postman.
The following APIs now use authorization (These routes cannot be called without having required permissions in the JWT Token).

  1. Analytics
    a. Get Payment Metrics: /analytics/v1/metrics/payments
    b. Get Refund Metrics: /analytics/v1/metrics/refunds
    c. Get Payment Filters: /analytics/v1/filters/payments
    d. Get Refund Filters: /analytics/v1/filters/payments

  2. Admin
    a. Merchant Account - Retrieve: /accounts/{id}
    b. Merchant Account - Update: /accounts/{id}
    c. Payment Connector - Create: /account/{merchant_id}/connectors
    d. Payment Connector - Retrieve: /account/{merchant_id}/connectors/{mca_id}
    e. Payment Connector - List (By MID): /account/{merchant_id}/connectors
    f. Payment Connector - Delete: /account/{merchant_id}/connectors/{mca_id}
    g. Business Profile - Create: /account/{merchant_id}/business_profile
    h. Business Profile - Retrieve: /account/{merchant_id}/business_profile/profile_id}
    i. Business Profile - Update: /account/{merchant_id}/business_profile/{profile_id}
    j. Business Profile - List (By MID): /account/{merchant_id}/business_profile

  3. API Keys
    a. API Key - Create: /api_keys/{merchant_id}
    b. Api Key - Retrieve: /api_keys/{merchant_id}/{key_id}
    c. API Key - Revoke: /api_keys/{merchant_id}/{key_id}
    d. API Key - List: /api_keys/{merchant_id}/list

  4. Disputes
    a. Dispute - Retrieve: /disputes/{dispute_id}
    b. Dispute - List: /disputes/list
    c. Dispute - Accept: /disputes/accept/{dispute_id}
    d. Dispute - Submit Evidence: /disputes/evidence
    e. Dispute - Attach Evidence: /disputes/evidence
    f. Dispute - Retrieve Evidence: /disputes/evidence/{dispute_id}

  5. Files
    a. Files - Create: /files
    b. Files - Delete: /files/{file_id}
    c. Files - Retrieve: /files/{file_id}

  6. Mandates
    a. Mandates - List: /mandates/list

  7. Payments
    a. Payments - Create: /payments
    b. Payments - Retrieve: /payments/{payment_id}
    c. Payments - List: /payments/list
    d. Payments - List by Filter: /payments/list
    e. Payments - Get Filters: /payments/filter

  8. Refunds
    a. Refunds - Create: /refunds
    b. Refunds - Retrieve: /refunds/{id}
    c. Refunds - List: /refunds/list
    d. Refunds - Filter List: /refunds/filter

  9. Routing
    a. Routing - Create Config: /routing
    b. Routing - Link Config: /routing/{alg_id}/activate
    c. Routing - Retrieve Config: /routing/{alg_id}
    d. Routing - Retrieve Dictionary: /routing
    e. Routing - Unlink Config: /routing/deactivate
    f. Routing - Update Default Config: /routing/default
    g. Routing - Retrieve Default Config: /routing/default
    h. Routing - Upsert Surcharge Decision Manager Config: /routing/decision/surcharge
    i. Routing - Delete Surcharge Decision Manager Config: /routing/decision/surcharge
    j. Routing - Retrieve Surcharge Decision Manager Config: /routing/decision/surcharge
    k. Routing - Upsert Decision Manager Config: /routing/decision
    l. Routing - Delete Decision Manager Config: /routing/decision
    m. Routing - Retrieve Decision Manager Config: /routing/decision
    n. Routing - Retrieve Linked Config: /routing/active
    o. Routing - Retrieve Default Config For Profiles: /routing/default/profile
    p. Routing - Update Default Config For Profile: /routing/default/profile/{profile_id}

  10. Apple Pay - Merchant Registration: /verify/apple_pay/{merchant_id}

  11. Retrieve Apple Pay Verified Domains: /verify/applepay/verified_domains

Removed JWT Authentication from the following APIs

  1. Payment Link - List: /payment_link/list

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
  • I added a CHANGELOG entry if applicable

@ThisIsMani ThisIsMani self-assigned this Nov 24, 2023
@ThisIsMani ThisIsMani added A-framework Area: Framework C-feature Category: Feature request or enhancement S-waiting-on-review Status: This PR has been implemented and needs to be reviewed labels Nov 24, 2023
@ThisIsMani ThisIsMani added this to the November 2023 Release milestone Nov 24, 2023
@ThisIsMani ThisIsMani changed the title feat(auth): Add Authorization in JWT Authentication types feat(auth): Add Authorization for JWT Authentication types Nov 24, 2023
@ThisIsMani ThisIsMani marked this pull request as ready for review November 24, 2023 09:30
@ThisIsMani ThisIsMani requested review from a team as code owners November 24, 2023 09:30
racnan
racnan previously approved these changes Nov 24, 2023
@Gnanasundari24 Gnanasundari24 added this pull request to the merge queue Nov 24, 2023
Merged via the queue into main with commit 03c0a77 Nov 24, 2023
14 of 16 checks passed
@Gnanasundari24 Gnanasundari24 deleted the authorization branch November 24, 2023 14:02
@SanchithHegde SanchithHegde removed the S-waiting-on-review Status: This PR has been implemented and needs to be reviewed label Nov 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-framework Area: Framework C-feature Category: Feature request or enhancement
Projects
No open projects
Status: Merged
Development

Successfully merging this pull request may close these issues.

7 participants