Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

feat(permissions): add hidden webhook and api-key permission groups (#12272)

Kanika Bansal6f8eea972d77
diff --git a/crates/common_enums/src/enums.rs b/crates/common_enums/src/enums.rs
index 37fe2d5fa7..580c7dc2f3 100644
--- a/crates/common_enums/src/enums.rs
+++ b/crates/common_enums/src/enums.rs
@@ -9594,6 +9594,10 @@ pub enum PermissionGroup {
UsersManage,
AccountView,
AccountManage,
+ WebhooksView,
+ WebhooksManage,
+ ApiKeysView,
+ ApiKeysManage,
InternalManage,
ThemeView,
ThemeManage,
@@ -9617,6 +9621,8 @@ pub enum ParentGroup {
Analytics,
Users,
Account,
+ Webhook,
+ ApiKeys,
Internal,
Theme,
ReconSources,
diff --git a/crates/router/src/services/authorization/info.rs b/crates/router/src/services/authorization/info.rs
index 37bd924fd0..d5d569e796 100644
--- a/crates/router/src/services/authorization/info.rs
+++ b/crates/router/src/services/authorization/info.rs
@@ -43,6 +43,11 @@ fn get_group_description(group: PermissionGroup) -> Option<&'static str> {
PermissionGroup::UsersManage => Some("Manage and invite Users to the Team"),
PermissionGroup::AccountView => Some("View Merchant Details"),
PermissionGroup::AccountManage => Some("Create, modify and delete Merchant Details like api keys, webhooks, etc"),
+ // Omits these from the authorization-info response; hidden until the role backfill
+ PermissionGroup::WebhooksView => None,
+ PermissionGroup::WebhooksManage => None,
+ PermissionGroup::ApiKeysView => None,
+ PermissionGroup::ApiKeysManage => None,
PermissionGroup::ThemeView => Some("View Themes"),
PermissionGroup::ThemeManage => Some("Manage Themes"),
PermissionGroup::InternalManage => None, // Internal group, no user-facing description
@@ -65,6 +70,9 @@ pub fn get_parent_group_description(group: ParentGroup) -> Option<&'static str>
ParentGroup::Analytics => Some("View Analytics"),
ParentGroup::Users => Some("Manage and invite Users to the Team"),
ParentGroup::Account => Some("Create, modify and delete Merchant Details like api keys, webhooks, etc"),
+ // Omits these from the authorization-info response; hidden until the role backfill
+ ParentGroup::Webhook => None,
+ ParentGroup::ApiKeys => None,
ParentGroup::Theme => Some("Manage and view themes for the organization"),
ParentGroup::Internal => None, // Internal group, no user-facing description
ParentGroup::ReconSources => Some("Recon ingestion and transformation pipelines"),
diff --git a/crates/router/src/services/authorization/permission_groups.rs b/crates/router/src/services/authorization/permission_groups.rs
index 295d505db9..1b4ec4c993 100644
--- a/crates/router/src/services/authorization/permission_groups.rs
+++ b/crates/router/src/services/authorization/permission_groups.rs
@@ -23,6 +23,8 @@ impl PermissionGroupExt for PermissionGroup {
| Self::AnalyticsView
| Self::UsersView
| Self::AccountView
+ | Self::WebhooksView
+ | Self::ApiKeysView
| Self::ThemeView
| Self::ReconSourcesView
| Self::ReconTransactionsView
@@ -34,6 +36,8 @@ impl PermissionGroupExt for PermissionGroup {
| Self::WorkflowsManage
| Self::UsersManage
| Self::AccountManage
+ | Self::WebhooksManage
+ | Self::ApiKeysManage
| Self::InternalManage
| Self::ThemeManage
| Self::ReconSourcesManage
@@ -51,6 +55,8 @@ impl PermissionGroupExt for PermissionGroup {
Self::AnalyticsView => ParentGroup::Analytics,
Self::UsersView | Self::UsersManage => ParentGroup::Users,
Self::AccountView | Self::AccountManage => ParentGroup::Account,
+ Self::WebhooksView | Self::WebhooksManage => ParentGroup::Webhook,
+ Self::ApiKeysView | Self::ApiKeysManage => ParentGroup::ApiKeys,
Self::ThemeView | Self::ThemeManage => ParentGroup::Theme,
Self::InternalManage => ParentGroup::Internal,
@@ -96,6 +102,14 @@ impl PermissionGroupExt for PermissionGroup {
Self::AccountView => vec![Self::AccountView],
Self::AccountManage => vec![Self::AccountView, Self::AccountManage],
+ Self::WebhooksView => vec![Self::WebhooksView, Self::AccountView],
+ Self::WebhooksManage => {
+ vec![Self::WebhooksView, Self::WebhooksManage, Self::AccountView]
+ }
+
+ Self::ApiKeysView => vec![Self::ApiKeysView, Self::AccountView],
+ Self::ApiKeysManage => vec![Self::ApiKeysView, Self::ApiKeysManage, Self::AccountView],
+
Self::InternalManage => vec![Self::InternalManage],
Self::ThemeView => vec![Self::ThemeView, Self::AccountView],
Self::ThemeManage => vec![Self::ThemeManage, Self::AccountView],
@@ -153,6 +167,10 @@ impl PermissionGroupExt for PermissionGroup {
| Self::AnalyticsView
| Self::AccountView
| Self::AccountManage
+ | Self::WebhooksView
+ | Self::WebhooksManage
+ | Self::ApiKeysView
+ | Self::ApiKeysManage
| Self::InternalManage
| Self::ThemeView
| Self::ThemeManage => RoleProductCategory::Orchestration,
@@ -188,6 +206,8 @@ impl ParentGroupExt for ParentGroup {
Self::Analytics => ANALYTICS.to_vec(),
Self::Users => USERS.to_vec(),
Self::Account => ACCOUNT.to_vec(),
+ Self::Webhook => WEBHOOK.to_vec(),
+ Self::ApiKeys => API_KEYS.to_vec(),
Self::Internal => INTERNAL.to_vec(),
Self::Theme => THEME.to_vec(),
Self::ReconSources => RECON_SOURCES.to_vec(),
@@ -260,6 +280,10 @@ pub static USERS: [Resource; 2] = [Resource::User, Resource::Account];
pub static ACCOUNT: [Resource; 3] = [Resource::Account, Resource::ApiKey, Resource::WebhookEvent];
+pub static WEBHOOK: [Resource; 1] = [Resource::WebhookEvent];
+
+pub static API_KEYS: [Resource; 1] = [Resource::ApiKey];
+
pub static INTERNAL: [Resource; 1] = [Resource::InternalConnector];
pub static THEME: [Resource; 1] = [Resource::Theme];