mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-02 21:07:58 +08:00
feat(vsaas): modify api key auth to support vsaas cases (#7593)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
@ -57,7 +57,10 @@ pub async fn customer_create(
|
||||
|state, auth: auth::AuthenticationData, req, _| {
|
||||
customers::create_customer(state, auth.merchant_account, auth.key_store, req)
|
||||
},
|
||||
&auth::HeaderAuth(auth::ApiKeyAuth),
|
||||
&auth::HeaderAuth(auth::ApiKeyAuth {
|
||||
is_connected_allowed: false,
|
||||
is_platform_allowed: false,
|
||||
}),
|
||||
api_locking::LockAction::NotApplicable,
|
||||
))
|
||||
.await
|
||||
@ -101,7 +104,10 @@ pub async fn customer_retrieve(
|
||||
customer_id,
|
||||
)
|
||||
},
|
||||
&auth::HeaderAuth(auth::ApiKeyAuth),
|
||||
&auth::HeaderAuth(auth::ApiKeyAuth {
|
||||
is_connected_allowed: false,
|
||||
is_platform_allowed: false,
|
||||
}),
|
||||
api_locking::LockAction::NotApplicable,
|
||||
))
|
||||
.await
|
||||
@ -158,7 +164,10 @@ pub async fn customer_update(
|
||||
auth.key_store,
|
||||
)
|
||||
},
|
||||
&auth::HeaderAuth(auth::ApiKeyAuth),
|
||||
&auth::HeaderAuth(auth::ApiKeyAuth {
|
||||
is_connected_allowed: false,
|
||||
is_platform_allowed: false,
|
||||
}),
|
||||
api_locking::LockAction::NotApplicable,
|
||||
))
|
||||
.await
|
||||
@ -196,7 +205,10 @@ pub async fn customer_delete(
|
||||
|state, auth: auth::AuthenticationData, customer_id, _| {
|
||||
customers::delete_customer(state, auth.merchant_account, customer_id, auth.key_store)
|
||||
},
|
||||
&auth::HeaderAuth(auth::ApiKeyAuth),
|
||||
&auth::HeaderAuth(auth::ApiKeyAuth {
|
||||
is_connected_allowed: false,
|
||||
is_platform_allowed: false,
|
||||
}),
|
||||
api_locking::LockAction::NotApplicable,
|
||||
))
|
||||
.await
|
||||
@ -242,7 +254,10 @@ pub async fn list_customer_payment_method_api(
|
||||
None,
|
||||
)
|
||||
},
|
||||
&auth::HeaderAuth(auth::ApiKeyAuth),
|
||||
&auth::HeaderAuth(auth::ApiKeyAuth {
|
||||
is_connected_allowed: false,
|
||||
is_platform_allowed: false,
|
||||
}),
|
||||
api_locking::LockAction::NotApplicable,
|
||||
))
|
||||
.await
|
||||
|
||||
@ -95,7 +95,10 @@ pub async fn payment_intents_create(
|
||||
auth.platform_merchant_account,
|
||||
)
|
||||
},
|
||||
&auth::HeaderAuth(auth::ApiKeyAuth),
|
||||
&auth::HeaderAuth(auth::ApiKeyAuth {
|
||||
is_connected_allowed: false,
|
||||
is_platform_allowed: false,
|
||||
}),
|
||||
locking_action,
|
||||
))
|
||||
.await
|
||||
@ -121,8 +124,13 @@ pub async fn payment_intents_retrieve(
|
||||
expand_captures: None,
|
||||
};
|
||||
|
||||
let api_auth = auth::ApiKeyAuth {
|
||||
is_connected_allowed: false,
|
||||
is_platform_allowed: false,
|
||||
};
|
||||
|
||||
let (auth_type, auth_flow) =
|
||||
match auth::check_client_secret_and_get_auth(req.headers(), &payload) {
|
||||
match auth::check_client_secret_and_get_auth(req.headers(), &payload, api_auth) {
|
||||
Ok(auth) => auth,
|
||||
Err(err) => return api::log_and_return_error_response(report!(err)),
|
||||
};
|
||||
@ -195,7 +203,13 @@ pub async fn payment_intents_retrieve_with_gateway_creds(
|
||||
merchant_connector_details: json_payload.merchant_connector_details.clone(),
|
||||
..Default::default()
|
||||
};
|
||||
let (auth_type, _auth_flow) = match auth::get_auth_type_and_flow(req.headers()) {
|
||||
|
||||
let api_auth = auth::ApiKeyAuth {
|
||||
is_connected_allowed: false,
|
||||
is_platform_allowed: false,
|
||||
};
|
||||
|
||||
let (auth_type, _auth_flow) = match auth::get_auth_type_and_flow(req.headers(), api_auth) {
|
||||
Ok(auth) => auth,
|
||||
Err(err) => return api::log_and_return_error_response(report!(err)),
|
||||
};
|
||||
@ -277,7 +291,12 @@ pub async fn payment_intents_update(
|
||||
|
||||
payload.payment_id = Some(api_types::PaymentIdType::PaymentIntentId(payment_id));
|
||||
|
||||
let (auth_type, auth_flow) = match auth::get_auth_type_and_flow(req.headers()) {
|
||||
let api_auth = auth::ApiKeyAuth {
|
||||
is_connected_allowed: false,
|
||||
is_platform_allowed: false,
|
||||
};
|
||||
|
||||
let (auth_type, auth_flow) = match auth::get_auth_type_and_flow(req.headers(), api_auth) {
|
||||
Ok(auth) => auth,
|
||||
Err(err) => return api::log_and_return_error_response(report!(err)),
|
||||
};
|
||||
@ -362,8 +381,13 @@ pub async fn payment_intents_confirm(
|
||||
payload.payment_id = Some(api_types::PaymentIdType::PaymentIntentId(payment_id));
|
||||
payload.confirm = Some(true);
|
||||
|
||||
let api_auth = auth::ApiKeyAuth {
|
||||
is_connected_allowed: false,
|
||||
is_platform_allowed: false,
|
||||
};
|
||||
|
||||
let (auth_type, auth_flow) =
|
||||
match auth::check_client_secret_and_get_auth(req.headers(), &payload) {
|
||||
match auth::check_client_secret_and_get_auth(req.headers(), &payload, api_auth) {
|
||||
Ok(auth) => auth,
|
||||
Err(err) => return api::log_and_return_error_response(err),
|
||||
};
|
||||
@ -480,7 +504,10 @@ pub async fn payment_intents_capture(
|
||||
auth.platform_merchant_account,
|
||||
)
|
||||
},
|
||||
&auth::HeaderAuth(auth::ApiKeyAuth),
|
||||
&auth::HeaderAuth(auth::ApiKeyAuth {
|
||||
is_connected_allowed: false,
|
||||
is_platform_allowed: false,
|
||||
}),
|
||||
locking_action,
|
||||
))
|
||||
.await
|
||||
@ -512,7 +539,12 @@ pub async fn payment_intents_cancel(
|
||||
let mut payload: payment_types::PaymentsCancelRequest = stripe_payload.into();
|
||||
payload.payment_id = payment_id;
|
||||
|
||||
let (auth_type, auth_flow) = match auth::get_auth_type_and_flow(req.headers()) {
|
||||
let api_auth = auth::ApiKeyAuth {
|
||||
is_connected_allowed: false,
|
||||
is_platform_allowed: false,
|
||||
};
|
||||
|
||||
let (auth_type, auth_flow) = match auth::get_auth_type_and_flow(req.headers(), api_auth) {
|
||||
Ok(auth) => auth,
|
||||
Err(err) => return api::log_and_return_error_response(report!(err)),
|
||||
};
|
||||
@ -591,7 +623,10 @@ pub async fn payment_intent_list(
|
||||
|state, auth: auth::AuthenticationData, req, _| {
|
||||
payments::list_payments(state, auth.merchant_account, None, auth.key_store, req)
|
||||
},
|
||||
&auth::HeaderAuth(auth::ApiKeyAuth),
|
||||
&auth::HeaderAuth(auth::ApiKeyAuth {
|
||||
is_connected_allowed: false,
|
||||
is_platform_allowed: false,
|
||||
}),
|
||||
api_locking::LockAction::NotApplicable,
|
||||
))
|
||||
.await
|
||||
|
||||
@ -52,7 +52,10 @@ pub async fn refund_create(
|
||||
|state, auth: auth::AuthenticationData, req, _| {
|
||||
refunds::refund_create_core(state, auth.merchant_account, None, auth.key_store, req)
|
||||
},
|
||||
&auth::HeaderAuth(auth::ApiKeyAuth),
|
||||
&auth::HeaderAuth(auth::ApiKeyAuth {
|
||||
is_connected_allowed: false,
|
||||
is_platform_allowed: false,
|
||||
}),
|
||||
api_locking::LockAction::NotApplicable,
|
||||
))
|
||||
.await
|
||||
@ -103,7 +106,10 @@ pub async fn refund_retrieve_with_gateway_creds(
|
||||
refunds::refund_retrieve_core_with_refund_id,
|
||||
)
|
||||
},
|
||||
&auth::HeaderAuth(auth::ApiKeyAuth),
|
||||
&auth::HeaderAuth(auth::ApiKeyAuth {
|
||||
is_connected_allowed: false,
|
||||
is_platform_allowed: false,
|
||||
}),
|
||||
api_locking::LockAction::NotApplicable,
|
||||
))
|
||||
.await
|
||||
@ -146,7 +152,10 @@ pub async fn refund_retrieve(
|
||||
refunds::refund_retrieve_core_with_refund_id,
|
||||
)
|
||||
},
|
||||
&auth::HeaderAuth(auth::ApiKeyAuth),
|
||||
&auth::HeaderAuth(auth::ApiKeyAuth {
|
||||
is_connected_allowed: false,
|
||||
is_platform_allowed: false,
|
||||
}),
|
||||
api_locking::LockAction::NotApplicable,
|
||||
))
|
||||
.await
|
||||
@ -180,7 +189,10 @@ pub async fn refund_update(
|
||||
|state, auth: auth::AuthenticationData, req, _| {
|
||||
refunds::refund_update_core(state, auth.merchant_account, req)
|
||||
},
|
||||
&auth::HeaderAuth(auth::ApiKeyAuth),
|
||||
&auth::HeaderAuth(auth::ApiKeyAuth {
|
||||
is_connected_allowed: false,
|
||||
is_platform_allowed: false,
|
||||
}),
|
||||
api_locking::LockAction::NotApplicable,
|
||||
))
|
||||
.await
|
||||
|
||||
@ -81,7 +81,10 @@ pub async fn setup_intents_create(
|
||||
auth.platform_merchant_account,
|
||||
)
|
||||
},
|
||||
&auth::HeaderAuth(auth::ApiKeyAuth),
|
||||
&auth::HeaderAuth(auth::ApiKeyAuth {
|
||||
is_connected_allowed: false,
|
||||
is_platform_allowed: false,
|
||||
}),
|
||||
api_locking::LockAction::NotApplicable,
|
||||
))
|
||||
.await
|
||||
@ -107,8 +110,13 @@ pub async fn setup_intents_retrieve(
|
||||
expand_captures: None,
|
||||
};
|
||||
|
||||
let api_auth = auth::ApiKeyAuth {
|
||||
is_connected_allowed: false,
|
||||
is_platform_allowed: false,
|
||||
};
|
||||
|
||||
let (auth_type, auth_flow) =
|
||||
match auth::check_client_secret_and_get_auth(req.headers(), &payload) {
|
||||
match auth::check_client_secret_and_get_auth(req.headers(), &payload, api_auth) {
|
||||
Ok(auth) => auth,
|
||||
Err(err) => return api::log_and_return_error_response(report!(err)),
|
||||
};
|
||||
@ -184,8 +192,13 @@ pub async fn setup_intents_update(
|
||||
};
|
||||
payload.payment_id = Some(api_types::PaymentIdType::PaymentIntentId(setup_id));
|
||||
|
||||
let api_auth = auth::ApiKeyAuth {
|
||||
is_connected_allowed: false,
|
||||
is_platform_allowed: false,
|
||||
};
|
||||
|
||||
let (auth_type, auth_flow) =
|
||||
match auth::check_client_secret_and_get_auth(req.headers(), &payload) {
|
||||
match auth::check_client_secret_and_get_auth(req.headers(), &payload, api_auth) {
|
||||
Ok(auth) => auth,
|
||||
Err(err) => return api::log_and_return_error_response(err),
|
||||
};
|
||||
@ -262,8 +275,13 @@ pub async fn setup_intents_confirm(
|
||||
payload.payment_id = Some(api_types::PaymentIdType::PaymentIntentId(setup_id));
|
||||
payload.confirm = Some(true);
|
||||
|
||||
let api_auth = auth::ApiKeyAuth {
|
||||
is_connected_allowed: false,
|
||||
is_platform_allowed: false,
|
||||
};
|
||||
|
||||
let (auth_type, auth_flow) =
|
||||
match auth::check_client_secret_and_get_auth(req.headers(), &payload) {
|
||||
match auth::check_client_secret_and_get_auth(req.headers(), &payload, api_auth) {
|
||||
Ok(auth) => auth,
|
||||
Err(err) => return api::log_and_return_error_response(err),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user