mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-01 19:42:27 +08:00
chore: enable partial auth as a feature flag (#5711)
This commit is contained in:
@ -9,7 +9,7 @@ readme = "README.md"
|
||||
license.workspace = true
|
||||
|
||||
[features]
|
||||
default = ["kv_store", "stripe", "oltp", "olap", "accounts_cache", "dummy_connector", "payouts", "payout_retry", "retry", "frm", "tls", "v1"]
|
||||
default = ["kv_store", "stripe", "oltp", "olap", "accounts_cache", "dummy_connector", "payouts", "payout_retry", "retry", "frm", "tls", "v1", "partial-auth"]
|
||||
olap = ["hyperswitch_domain_models/olap", "storage_impl/olap", "scheduler/olap", "api_models/olap", "dep:analytics"]
|
||||
tls = ["actix-web/rustls-0_22"]
|
||||
email = ["external_services/email", "scheduler/email", "olap"]
|
||||
|
||||
@ -11225,6 +11225,9 @@ impl Default for super::settings::ApiKeys {
|
||||
// context used for blake3
|
||||
#[cfg(feature = "partial-auth")]
|
||||
checksum_auth_context: String::new().into(),
|
||||
|
||||
#[cfg(feature = "partial-auth")]
|
||||
enable_partial_auth: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -123,6 +123,9 @@ impl SecretsHandler for settings::ApiKeys {
|
||||
.get_secret(api_keys.checksum_auth_key.clone())
|
||||
.await?;
|
||||
|
||||
#[cfg(feature = "partial-auth")]
|
||||
let enable_partial_auth = api_keys.enable_partial_auth;
|
||||
|
||||
Ok(value.transition_state(|_| Self {
|
||||
hash_key,
|
||||
#[cfg(feature = "email")]
|
||||
@ -132,6 +135,8 @@ impl SecretsHandler for settings::ApiKeys {
|
||||
checksum_auth_key,
|
||||
#[cfg(feature = "partial-auth")]
|
||||
checksum_auth_context,
|
||||
#[cfg(feature = "partial-auth")]
|
||||
enable_partial_auth,
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
@ -669,6 +669,9 @@ pub struct ApiKeys {
|
||||
|
||||
#[cfg(feature = "partial-auth")]
|
||||
pub checksum_auth_key: Secret<String>,
|
||||
|
||||
#[cfg(feature = "partial-auth")]
|
||||
pub enable_partial_auth: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Clone, Default)]
|
||||
|
||||
@ -443,6 +443,14 @@ where
|
||||
request_headers: &HeaderMap,
|
||||
state: &A,
|
||||
) -> RouterResult<(AuthenticationData, AuthenticationType)> {
|
||||
let enable_partial_auth = state.conf().api_keys.get_inner().enable_partial_auth;
|
||||
|
||||
// This is a early return if partial auth is disabled
|
||||
// Preventing the need to go through the header extraction process
|
||||
if !enable_partial_auth {
|
||||
return self.0.authenticate_and_fetch(request_headers, state).await;
|
||||
}
|
||||
|
||||
let report_failure = || {
|
||||
metrics::PARTIAL_AUTH_FAILURE.add(&metrics::CONTEXT, 1, &[]);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user