-
Notifications
You must be signed in to change notification settings - Fork 4.2k
feat(connector_cloning): Create API for cloning connectors between merchants and profiles. #7949
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces the Connector Cloning feature along with a new API endpoint and supporting configuration changes as well as associated updates to internal authorization and permission mappings. In addition, new error variants for cloning operations and updates in user role and configuration modules have been included.
- New API endpoint (/user/clone_connector) and associated models for cloning connectors between merchants and profiles.
- Updates to authorization logic and permission groups to support internal operations.
- Extended configuration settings to include a whitelist for clone connector operations.
Reviewed Changes
Copilot reviewed 26 out of 26 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
crates/router/src/services/authorization/permission_groups.rs | Added support for InternalManage and updated mapping logic in several permission group functions. |
crates/router/src/services/authorization/info.rs | Refactored functions to return Options for group descriptions, especially for internal groups. |
crates/router/src/routes/user.rs | Introduced the clone_connector endpoint in the user module. |
crates/router/src/routes/payments.rs | Updated permission from ProfileAccountWrite to ProfilePaymentRead in payment capture. |
crates/router/src/routes/lock_utils.rs | Mapped Flow::CloneConnector to the correct API-level locking identifier. |
crates/router/src/core/user.rs | Added core logic to support the new clone_connector flow including whitelist validation and connector creation. |
crates/router/src/configs/settings.rs | Introduced CloneConnectorWhitelistConfig and updated settings to include new whitelist options. |
crates/common_utils/src/consts.rs and crates/common_enums/src/enums.rs | Added new constants and enum variants for internal demo roles and internal connector related operations. |
crates/api_models/src/user.rs | Added new API models for cloning connectors and updated internal user creation model to support role_id. |
Comments suppressed due to low confidence (6)
crates/router/src/services/authorization/permission_groups.rs:160
- [nitpick] Consider replacing the chained use of 'is_empty().not().then_some(...)' with a more explicit if/else statement for improved readability.
descriptions_map.is_empty().not().then_some(descriptions_map)
crates/router/src/services/authorization/info.rs:23
- Ensure that all call-sites of 'get_group_description' properly handle a 'None' return value for internal groups (e.g. InternalManage) to avoid unintended behavior.
fn get_group_description(group: PermissionGroup) -> Option<&'static str> {
crates/router/src/routes/payments.rs:3075
- Verify that updating the permission from 'ProfileAccountWrite' to 'ProfilePaymentRead' accurately reflects the intended access control changes for payment capture operations.
permission: Permission::ProfilePaymentRead,
crates/router/src/routes/lock_utils.rs:291
- Confirm that mapping 'Flow::CloneConnector' to 'Self::User' in the locking mechanism is correct and meets the intended security and concurrency requirements.
| Flow::CloneConnector => Self::User,
crates/router/src/configs/settings.rs:162
- Verify that the custom deserializers 'deserialize_merchant_ids' and 'deserialize_hashset' are properly handling the comma‐separated configuration values for merchant IDs and connector names.
pub struct CloneConnectorWhitelistConfig {
crates/common_enums/src/enums.rs:7217
- Double-check that the new 'InternalManage' variant (and related 'Internal' and 'InternalConnector' variants) is fully integrated with existing permission logic without conflicts.
InternalManage,
3023974
4d1ca18
52a55f8
Type of Change
Description
This branch primarily introduces the Connector Cloning feature. Key changes include:
CloneConnectorRequest
,CloneConnectorSource
,CloneConnectorDestination
) and a new API endpoint (/user/clone_connector
).clone_connector
function incrates/router/src/core/user.rs
to handle the cloning process, supported by a helper functionbuild_cloned_connector_create_request
incrates/router/src/utils/user.rs
.clone_connector_whitelist
configuration section insettings.rs
and added it to example/deployment config files (config.example.toml
,development.toml
, etc.) to control which merchants and connectors are allowed for cloning.InternalManage
), parent group (Internal
), and resource (InternalConnector
).internal_demo
) possibly for demonstrating or testing the clone feature.get_group_authorization_info
,get_parent_group_description
,get_resource_name
) to handle internal groups/resources gracefully (returningNone
for user-facing descriptions).InternalManage
to custom roles.role_id
field toCreateInternalUserRequest
.Additional Changes
clone_connector_whitelist
section).config/config.example.toml
config/deployments/env_specific.toml
config/development.toml
config/docker_compose.toml
crates/router/src/configs/settings.rs
Motivation and Context
Closes juspay/hyperswitch-control-center#2921
How did you test it?
Checklist
cargo +nightly fmt --all
cargo clippy