hyperswitch icon indicating copy to clipboard operation
hyperswitch copied to clipboard

feat(users): Role info api with parent tags

Open Riddhiagrawal001 opened this issue 6 months ago • 0 comments

Type of Change

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

Description

The permission_info API previously returned permission groups, each with its own description. With this update, permission groups are now organized under parent groups, and descriptions are tied to the parent group instead of individual groups. Additionally, permissions for each group have been removed, as the dashboard no longer utilizes that data. Older structure :

[
    {
        "group": "operations_view",
        "description": "View Payments, Refunds, Payouts, Mandates, Disputes and Customers",
        "permissions": [
            {
                "enum_name": "PaymentRead",
                "description": "View all payments"
            },
            {
                "enum_name": "RefundRead",
                "description": "View all refunds"
            },
            {
                "enum_name": "MandateRead",
                "description": "View mandates"
            },
            {
                "enum_name": "DisputeRead",
                "description": "View disputes"
            },
            {
                "enum_name": "CustomerRead",
                "description": "View customers"
            },
            {
                "enum_name": "GenerateReport",
                "description": "Generate reports for payments, refunds and disputes"
            },
            {
                "enum_name": "PayoutRead",
                "description": "View all payouts"
            },
            {
                "enum_name": "MerchantAccountRead",
                "description": "View merchant account details"
            }
        ]
    },
    {
        "group": "operations_manage",
        "description": "Create, modify and delete Payments, Refunds, Payouts, Mandates, Disputes and Customers",
        "permissions": [
            {
                "enum_name": "PaymentWrite",
                "description": "Create payment, download payments data"
            },
            {
                "enum_name": "RefundWrite",
                "description": "Create refund, download refunds data"
            },
            {
                "enum_name": "MandateWrite",
                "description": "Create and update mandates"
            },
            {
                "enum_name": "DisputeWrite",
                "description": "Create and update disputes"
            },
            {
                "enum_name": "CustomerWrite",
                "description": "Create, update and delete customers"
            },
            {
                "enum_name": "PayoutWrite",
                "description": "Create payout, download payout data"
            },
            {
                "enum_name": "MerchantAccountRead",
                "description": "View merchant account details"
            }
        ]
    },
]

New structure :

 {
        "name": "Operations",
        "description": "Payments, Refunds, Payouts, Mandates, Disputes and Customers",
        "groups": [
            "operations_view",
            "operations_manage"
        ]
}

Additional Changes

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

Motivation and Context

This will close the issue

How did you test it?

Request :

curl --location 'http://localhost:8080/user/role_info' \
--header 'Authorization: Bearer token '

Response :

[
    {
        "name": "Users",
        "description": "Manage and invite Users to the Team",
        "groups": [
            "users_view",
            "users_manage"
        ]
    },
    {
        "name": "MerchantAccess",
        "description": "Create, modify and delete Merchant Details like api keys, webhooks, etc",
        "groups": [
            "merchant_details_view",
            "merchant_details_manage"
        ]
    },
    {
        "name": "OrganizationAccess",
        "description": "Manage organization level tasks like create new Merchant accounts, Organization level roles, etc",
        "groups": [
            "organization_manage"
        ]
    },
    {
        "name": "Analytics",
        "description": "View Analytics",
        "groups": [
            "analytics_view"
        ]
    },
    {
        "name": "Connectors",
        "description": "Create, modify and delete connectors like Payment Processors, Payout Processors and Fraud & Risk Manager",
        "groups": [
            "connectors_view",
            "connectors_manage"
        ]
    },
    {
        "name": "Operations",
        "description": "Payments, Refunds, Payouts, Mandates, Disputes and Customers",
        "groups": [
            "operations_view",
            "operations_manage"
        ]
    },
    {
        "name": "Workflows",
        "description": "Create, modify and delete Routing, 3DS Decision Manager, Surcharge Decision Manager",
        "groups": [
            "workflows_view",
            "workflows_manage"
        ]
    }
]

Checklist

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

Riddhiagrawal001 avatar Aug 06 '24 09:08 Riddhiagrawal001