-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(user_role): Add APIs for user roles (#3013)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
- Loading branch information
1 parent
2e2dbe4
commit 3fa0bdf
Showing
24 changed files
with
1,207 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
use common_utils::events::{ApiEventMetric, ApiEventsType}; | ||
|
||
use crate::user_role::{ | ||
AuthorizationInfoResponse, GetRoleRequest, ListRolesResponse, RoleInfoResponse, | ||
UpdateUserRoleRequest, | ||
}; | ||
|
||
common_utils::impl_misc_api_event_type!( | ||
ListRolesResponse, | ||
RoleInfoResponse, | ||
GetRoleRequest, | ||
AuthorizationInfoResponse, | ||
UpdateUserRoleRequest | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
#[derive(Debug, serde::Serialize)] | ||
pub struct ListRolesResponse(pub Vec<RoleInfoResponse>); | ||
|
||
#[derive(Debug, serde::Serialize)] | ||
pub struct RoleInfoResponse { | ||
pub role_id: &'static str, | ||
pub permissions: Vec<Permission>, | ||
pub role_name: &'static str, | ||
} | ||
|
||
#[derive(Debug, serde::Deserialize, serde::Serialize)] | ||
pub struct GetRoleRequest { | ||
pub role_id: String, | ||
} | ||
|
||
#[derive(Debug, serde::Serialize)] | ||
pub enum Permission { | ||
PaymentRead, | ||
PaymentWrite, | ||
RefundRead, | ||
RefundWrite, | ||
ApiKeyRead, | ||
ApiKeyWrite, | ||
MerchantAccountRead, | ||
MerchantAccountWrite, | ||
MerchantConnectorAccountRead, | ||
MerchantConnectorAccountWrite, | ||
ForexRead, | ||
RoutingRead, | ||
RoutingWrite, | ||
DisputeRead, | ||
DisputeWrite, | ||
MandateRead, | ||
MandateWrite, | ||
FileRead, | ||
FileWrite, | ||
Analytics, | ||
ThreeDsDecisionManagerWrite, | ||
ThreeDsDecisionManagerRead, | ||
SurchargeDecisionManagerWrite, | ||
SurchargeDecisionManagerRead, | ||
UsersRead, | ||
UsersWrite, | ||
} | ||
|
||
#[derive(Debug, serde::Serialize)] | ||
pub enum PermissionModule { | ||
Payments, | ||
Refunds, | ||
MerchantAccount, | ||
Forex, | ||
Connectors, | ||
Routing, | ||
Analytics, | ||
Mandates, | ||
Disputes, | ||
Files, | ||
ThreeDsDecisionManager, | ||
SurchargeDecisionManager, | ||
} | ||
|
||
#[derive(Debug, serde::Serialize)] | ||
pub struct AuthorizationInfoResponse(pub Vec<ModuleInfo>); | ||
|
||
#[derive(Debug, serde::Serialize)] | ||
pub struct ModuleInfo { | ||
pub module: PermissionModule, | ||
pub description: &'static str, | ||
pub permissions: Vec<PermissionInfo>, | ||
} | ||
|
||
#[derive(Debug, serde::Serialize)] | ||
pub struct PermissionInfo { | ||
pub enum_name: Permission, | ||
pub description: &'static str, | ||
} | ||
|
||
#[derive(Debug, serde::Deserialize, serde::Serialize)] | ||
pub struct UpdateUserRoleRequest { | ||
pub user_id: String, | ||
pub role_id: String, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// User Roles | ||
pub const ROLE_ID_INTERNAL_VIEW_ONLY_USER: &str = "internal_view_only"; | ||
pub const ROLE_ID_INTERNAL_ADMIN: &str = "internal_admin"; | ||
pub const ROLE_ID_MERCHANT_ADMIN: &str = "merchant_admin"; | ||
pub const ROLE_ID_ORGANIZATION_ADMIN: &str = "org_admin"; | ||
pub const ROLE_ID_MERCHANT_VIEW_ONLY: &str = "merchant_view_only"; | ||
pub const ROLE_ID_MERCHANT_IAM_ADMIN: &str = "merchant_iam_admin"; | ||
pub const ROLE_ID_MERCHANT_DEVELOPER: &str = "merchant_developer"; | ||
pub const ROLE_ID_MERCHANT_OPERATOR: &str = "merchant_operator"; | ||
pub const ROLE_ID_MERCHANT_CUSTOMER_SUPPORT: &str = "merchant_customer_support"; | ||
pub const INTERNAL_USER_MERCHANT_ID: &str = "juspay000"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.