feat(authz): Make permissions entity and scope aware

Currently the permissions we use doesn't have any entity level context. But some of our APIs need that context.
For example,
1. `payment/list` - This can only be accessible by merchant level users or higher. Profile level users should not be able to access it.
2. `payment/profile/list` - This can be accessible by all level of users.

With current setup, this is not directly possible by the permissions. We had to introduce `min_entity_level` to solve this, but this is very separated from the permissions.

To solve this, we need to have entity level context at permissions level itself.

### Scope for permissions
The write permissions currently doesn't have access to read APIs, but since write is a superset of read, they should be able to access read APIs as well.

So, this PR also introduces scope context in permissions.

<think>
PR Context:
- Title: feat(authz): Create a permission generator
- Merged: 2024-10-24T14:36:07Z
- Files changed: 30 files
- Commits: 11 commits

Implementation approach:
## Type of Change
<!-- Put an `x` in the boxes that apply -->

- [ ] Bugfix
- [ ] New feature
- [x] Enhancement
- [ ] Refactoring
- [ ] Dependency updates
- [ ] Documentation
- [ ] CI/CD

## Description
<!-- Describe your changes in detail -->

### Entity level context in Permissions
Currently the permissions we use doesn't have any entity level context. But some of our APIs need that context.
For example,
1. `payment/list` - This can only be accessible by merchant level users o
</think>

To implement this, you'll need to modify:


**Detailed Implementation:**


**Commit 1:** feat(authz): Create a permission generator (#6394)
Co-authored-by: hyperswitch-bot[bot] <148525504+h
Files to modify:


**crates/api_models/src/user_role.rs**
  Remove:
    - enum: pub::ParentGroup

**crates/common_enums/src/enums.rs**
  Add:
    - enum: pub::ParentGroup
    - enum: pub::Resource
    - enum: pub::PermissionScope

**crates/router/src/analytics.rs**
  Modify existing code

**crates/router/src/core/user_role.rs**
  Modify existing code

**crates/router/src/routes/admin.rs**
  Modify existing code

**crates/router/src/routes/api_keys.rs**
  Modify existing code

**crates/router/src/routes/blocklist.rs**
  Modify existing code

**crates/router/src/routes/connector_onboarding.rs**
  Modify existing code

**crates/router/src/routes/customers.rs**
  Modify existing code

**crates/router/src/routes/disputes.rs**
  Modify existing code

**crates/router/src/routes/mandates.rs**
  Modify existing code

**crates/router/src/routes/payment_methods.rs**
  Modify existing code

**crates/router/src/routes/payments.rs**
  Modify existing code

**crates/router/src/routes/payouts.rs**
  Modify existing code

**crates/router/src/routes/profiles.rs**
  Modify existing code

**crates/router/src/routes/recon.rs**
  Modify existing code

**crates/router/src/routes/refunds.rs**
  Modify existing code

**crates/router/src/routes/routing.rs**
  Modify existing code

**crates/router/src/routes/user.rs**
  Modify existing code

**crates/router/src/routes/user_role.rs**
  Modify existing code

**crates/router/src/routes/verification.rs**
  Modify existing code

**crates/router/src/routes/verify_connector.rs**
  Modify existing code

**crates/router/src/routes/webhook_events.rs**
  Modify existing code

**crates/router/src/services/authentication.rs**
  Modify existing code

**crates/router/src/services/authorization.rs**
  Remove:
    - function: pub::check_entity

**crates/router/src/services/authorization/info.rs**
  Modify existing code

**crates/router/src/services/authorization/permission_groups.rs**
  Add:
    - function: private::scope
    - function: private::parent
    - function: private::resources
    - function: private::accessible_groups
    - function: private::resources
    - trait: pub::PermissionGroupExt
    - trait: pub::ParentGroupExt
    - impl: impl PermissionGroupExt for PermissionGroup
    - impl: impl ParentGroupExt for ParentGroup

**crates/router/src/services/authorization/permissions.rs**
  Remove:
    - enum: pub::Permission

**crates/router/src/services/authorization/roles.rs**
  Modify existing code

**crates/router_derive/src/lib.rs**
  Add:
    - function: pub::generate_permissions

**crates/router_derive/src/macros.rs**
  Add:
    - mod: pub::generate_permissions

**crates/router_derive/src/macros/generate_permissions.rs**
  Add:
    - function: private::parse
    - function: private::parse
    - function: private::parse_label_with_punctuated_data
    - function: pub::generate_permissions_inner
    - struct: private::ResourceInput
    - struct: private::Input
    - impl: impl Parse for Input
    - impl: impl Parse for ResourceInput
{"issue_number": 6391, "pr_number": 6394, "commits_count": 1, "files_changed": 30, "response_length": 3882, "file_count": 34, "needs_breakdown": true}