Skip to content

Commit

Permalink
feat: add resources and granular permission groups for reconciliation (
Browse files Browse the repository at this point in the history
…#6591)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
  • Loading branch information
kashif-m and hyperswitch-bot[bot] authored Dec 4, 2024
1 parent 35f963c commit fa21ef8
Show file tree
Hide file tree
Showing 18 changed files with 442 additions and 172 deletions.
17 changes: 17 additions & 0 deletions crates/api_models/src/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -446,3 +446,20 @@ pub enum StripeChargeType {
pub fn convert_frm_connector(connector_name: &str) -> Option<FrmConnectors> {
FrmConnectors::from_str(connector_name).ok()
}

#[derive(Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, serde::Serialize, Hash)]
pub enum ReconPermissionScope {
#[serde(rename = "R")]
Read = 0,
#[serde(rename = "RW")]
Write = 1,
}

impl From<PermissionScope> for ReconPermissionScope {
fn from(scope: PermissionScope) -> Self {
match scope {
PermissionScope::Read => Self::Read,
PermissionScope::Write => Self::Write,
}
}
}
13 changes: 12 additions & 1 deletion crates/api_models/src/events/recon.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
use common_utils::events::{ApiEventMetric, ApiEventsType};
use masking::PeekInterface;

use crate::recon::{ReconStatusResponse, ReconTokenResponse, ReconUpdateMerchantRequest};
use crate::recon::{
ReconStatusResponse, ReconTokenResponse, ReconUpdateMerchantRequest, VerifyTokenResponse,
};

impl ApiEventMetric for ReconUpdateMerchantRequest {
fn get_api_event_type(&self) -> Option<ApiEventsType> {
Expand All @@ -19,3 +22,11 @@ impl ApiEventMetric for ReconStatusResponse {
Some(ApiEventsType::Recon)
}
}

impl ApiEventMetric for VerifyTokenResponse {
fn get_api_event_type(&self) -> Option<ApiEventsType> {
Some(ApiEventsType::User {
user_id: self.user_email.peek().to_string(),
})
}
}
13 changes: 0 additions & 13 deletions crates/api_models/src/events/user.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
use common_utils::events::{ApiEventMetric, ApiEventsType};
#[cfg(feature = "recon")]
use masking::PeekInterface;

#[cfg(feature = "dummy_connector")]
use crate::user::sample_data::SampleDataRequest;
#[cfg(feature = "recon")]
use crate::user::VerifyTokenResponse;
use crate::user::{
dashboard_metadata::{
GetMetaDataRequest, GetMetaDataResponse, GetMultipleMetaDataPayload, SetMetaDataRequest,
Expand All @@ -23,15 +19,6 @@ use crate::user::{
VerifyTotpRequest,
};

#[cfg(feature = "recon")]
impl ApiEventMetric for VerifyTokenResponse {
fn get_api_event_type(&self) -> Option<ApiEventsType> {
Some(ApiEventsType::User {
user_id: self.user_email.peek().to_string(),
})
}
}

common_utils::impl_api_event_type!(
Miscellaneous,
(
Expand Down
10 changes: 9 additions & 1 deletion crates/api_models/src/recon.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use common_utils::pii;
use common_utils::{id_type, pii};
use masking::Secret;

use crate::enums;
Expand All @@ -18,3 +18,11 @@ pub struct ReconTokenResponse {
pub struct ReconStatusResponse {
pub recon_status: enums::ReconStatus,
}

#[derive(serde::Serialize, Debug)]
pub struct VerifyTokenResponse {
pub merchant_id: id_type::MerchantId,
pub user_email: pii::Email,
#[serde(skip_serializing_if = "Option::is_none")]
pub acl: Option<String>,
}
7 changes: 0 additions & 7 deletions crates/api_models/src/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,6 @@ pub struct SendVerifyEmailRequest {
pub email: pii::Email,
}

#[cfg(feature = "recon")]
#[derive(serde::Serialize, Debug)]
pub struct VerifyTokenResponse {
pub merchant_id: id_type::MerchantId,
pub user_email: pii::Email,
}

#[derive(Debug, serde::Deserialize, serde::Serialize)]
pub struct UpdateUserAccountDetailsRequest {
pub name: Option<Secret<String>>,
Expand Down
19 changes: 16 additions & 3 deletions crates/common_enums/src/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2819,9 +2819,15 @@ pub enum PermissionGroup {
MerchantDetailsManage,
// TODO: To be deprecated, make sure DB is migrated before removing
OrganizationManage,
ReconOps,
AccountView,
AccountManage,
ReconReportsView,
ReconReportsManage,
ReconOpsView,
// Alias is added for backward compatibility with database
// TODO: Remove alias post migration
#[serde(alias = "recon_ops")]
ReconOpsManage,
}

#[derive(Clone, Debug, serde::Serialize, PartialEq, Eq, Hash, strum::EnumIter)]
Expand All @@ -2831,7 +2837,8 @@ pub enum ParentGroup {
Workflows,
Analytics,
Users,
Recon,
ReconOps,
ReconReports,
Account,
}

Expand All @@ -2854,7 +2861,13 @@ pub enum Resource {
WebhookEvent,
Payout,
Report,
Recon,
ReconToken,
ReconFiles,
ReconAndSettlementAnalytics,
ReconUpload,
ReconReports,
RunRecon,
ReconConfig,
}

#[derive(Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, serde::Serialize, Hash)]
Expand Down
Loading

0 comments on commit fa21ef8

Please sign in to comment.