Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add resources and granular permission groups for reconciliation #6591

Open
wants to merge 22 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
2ea3f1c
feat: add resources and granular permission groups for reconciliation
kashif-m Nov 18, 2024
ae879e5
chore: run formatter
hyperswitch-bot[bot] Nov 19, 2024
a933120
refactor: move acl generation to RoleInfo impls
kashif-m Nov 19, 2024
8665245
chore: run formatter
hyperswitch-bot[bot] Nov 19, 2024
fea2cb8
refactor: remove redundant code
kashif-m Nov 19, 2024
aabe7ea
refactor: add parent groups for recon resources
kashif-m Nov 19, 2024
5b81836
chore: run formatter
hyperswitch-bot[bot] Nov 19, 2024
2eeaaa7
refactor: update resource permissions and assign default permission g…
kashif-m Nov 19, 2024
9d5dd00
refactor: update predefined VIEW_ONLY roles
kashif-m Nov 19, 2024
772e409
Merge remote-tracking branch 'origin/main' into 6524-recon-permissions
kashif-m Nov 19, 2024
30077f7
refactor(recon): use non optional profile_id in recon token
kashif-m Nov 19, 2024
849eb92
chore: run formatter
hyperswitch-bot[bot] Nov 20, 2024
09a29e4
refactor(recon): resolve comments
kashif-m Nov 20, 2024
49c6802
chore: run formatter
hyperswitch-bot[bot] Nov 20, 2024
4858d6e
refactor(recon): clippy fixes
kashif-m Nov 20, 2024
dbe8f6b
chore: run formatter
hyperswitch-bot[bot] Nov 20, 2024
02c7b0d
chore: resolve comments
kashif-m Nov 20, 2024
66bbc6c
refactor: update predefined roles
kashif-m Nov 21, 2024
98221a3
chore: add view roles
kashif-m Nov 21, 2024
2adabf2
refactor: resolve comments
kashif-m Nov 22, 2024
82c4acf
chore: fix clippy
kashif-m Nov 22, 2024
3d66ca7
chore: run formatter
hyperswitch-bot[bot] Nov 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions crates/api_models/src/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -447,3 +447,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 @@ -2796,9 +2796,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 @@ -2808,7 +2814,8 @@ pub enum ParentGroup {
Workflows,
Analytics,
Users,
Recon,
ReconOps,
ReconReports,
Account,
}

Expand All @@ -2831,7 +2838,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
Loading