Issue:
feat: change role apis to support custom roles

Resolution:
<think>
PR Context:
- Title: feat(authz): Add custom role checks in authorization
- Merged: 2024-02-21T13:59:00Z
- Files changed: 15 files
- Commits: 30 commits

Implementation approach:
## Type of Change
<!-- Put an `x` in the boxes that apply -->

- [ ] Bugfix
- [x] New feature
- [ ] Enhancement
- [ ] Refactoring
- [ ] Dependency updates
- [ ] Documentation
- [ ] CI/CD

## Description
<!-- Describe your changes in detail -->
This PR will add checks in authorization to check for custom roles.
This PR also add custom roles functionality to apis which were dealing with roles.

### Additional Changes

- [x] This PR modifies the API contract
- [ ] This PR modifie
</think>

To implement this, you'll need to modify:


**Detailed Implementation:**


**Commit 1:** feat(authz): Add custom role checks in authorization (#3719)
Co-authored-by: Apoorv Dixit <apoorv.di
Files to modify:


**crates/api_models/src/user_role.rs**
  Modify existing code

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

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

**crates/router/src/core/user_role.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/services/authentication.rs**
  Modify existing code

**crates/router/src/services/authorization.rs**
  Remove:
    - mod: pub::predefined_permissions
  Add:
    - function: pub::get_permissions
    - mod: pub::permission_groups
    - mod: pub::roles

**crates/router/src/services/authorization/permission_groups.rs**
  Add:
    - function: pub::get_permissions_vec

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

**crates/router/src/services/authorization/roles.rs**
  Add:
    - function: pub::get_role_id
    - function: pub::get_role_name
    - function: pub::get_permission_groups
    - function: pub::get_scope
    - function: pub::is_invitable
    - function: pub::is_deletable
    - function: pub::is_internal
    - function: pub::is_updatable
    - function: pub::get_permissions_set
    - function: pub::check_permission_exists
    - function: pub::get_role_info_from_role_id
    - function: private::from
    - struct: pub::RoleInfo
    - impl: impl RoleInfo
    - impl: impl From<diesel_models::role::Role> for RoleInfo
    - mod: pub::predefined_roles

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

**crates/router/src/types/domain/user.rs**
  Remove:
    - function: private::try_from
    - struct: pub::UserAndRoleJoined
    - impl: impl TryFrom<UserAndRoleJoined> for user_api::UserDetails
  Add:
    - function: private::foreign_from
    - impl: impl ForeignFrom<UserStatus> for user_role_api::UserStatus

**crates/router/src/utils/user.rs**
  Add:
    - function: pub::get_role_info_from_db

**crates/router/src/utils/user_role.rs**
  Remove:
    - function: pub::is_internal_role
    - function: pub::get_role_name_and_permission_response