-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
fix(auth_methods): Add checks for duplicate auth_method
in create API
#5161
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.
LGTM
pub async fn construct_public_and_private_db_configs( | ||
auth_config: &user_api::AuthConfig, | ||
encryption_key: &[u8], | ||
) -> UserResult<(Option<Encryption>, Option<serde_json::Value>)> { |
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.
why (Option<T1>,Option<T2>)
why not Option<(T1,T2)>
if public and private config are coupled ?
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.
In DB, both are optional, so a case where when one is optional and other is not comes then, we will have to change this everywhere.
crates/router/src/utils/user.rs
Outdated
public_config, | ||
} => { | ||
let private_config_value = serde_json::to_value(private_config.clone()) | ||
.change_context(UserErrors::AuthConfigParsingError) |
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.
why is this 400
? isnt invalid value caught at api level ?
or someone can pass api model validation (serde) but still provide invalid json ?
crates/router/src/utils/user.rs
Outdated
), | ||
)) | ||
} | ||
_ => Ok((None, None)), |
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.
lets match each value here, so that new enum breaks the code at compile time
crates/router/src/utils/user.rs
Outdated
pub fn parse_oidc_public_config( | ||
public_config: Option<serde_json::Value>, | ||
) -> UserResult<Option<user_api::OpenIdConnectPublicConfig>> { | ||
public_config | ||
.map(|config| { | ||
serde_json::from_value::<user_api::OpenIdConnectPublicConfig>(config) | ||
.change_context(UserErrors::InternalServerError) | ||
.attach_printable("Unable to parse OpenIdConnectPublicConfig") | ||
}) | ||
.transpose() | ||
} |
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.
this can be generic instead exclusively for OpenIdConnectPublicConfig
.
…ror-handling-in-cypress * 'main' of github.com:juspay/hyperswitch: fix(auth_methods): Add checks for duplicate `auth_method` in create API (#5161) chore(version): 2024.07.02.0 fix(router): rename the browser name header to `x-browser-name` (#5162) fix(router): mark retry payment as failure if `connector_tokenization` fails (#5114) fix(connector): [Paypal] dispute webhook deserialization failure (#5111) feat(analytics): Add v2 payment analytics (payment-intents analytics) (#5150) feat(globalsearch): Implement tag-based filters in global search (#5151) refactor(connector): Add amount conversion framework to iatapay along with amount conversion code to connector template (#4866) feat(payment_link): add multiple custom css support in business level (#5137) feat(connector): [Bambora Apac] Template for integration (#5062) feat(tls): add support for https in actix web (#5089) chore(ci): fix ci tests failing by removing them (#5167) chore(version): 2024.07.01.0 chore(postman): update Postman collection files ci(postman): log request id for user tests (#5159) chore(euclid_wasm): make field domain optional wasm (#5154)
Type of Change
Description
Currently create will accept and insert auth methods with same type and name, which shouldn't be possible. This PR fixes that.
Additional Changes
Motivation and Context
Closes #5160.
How did you test it?
If this API is hit with same
auth_type
andname
inpublic_config
, then the API will throw the following error.Checklist
cargo +nightly fmt --all
cargo clippy