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

bug(auth_v2): remove duplicate profile fetch #6871

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
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
35 changes: 11 additions & 24 deletions crates/router/src/services/authentication.rs
Original file line number Diff line number Diff line change
Expand Up @@ -680,31 +680,18 @@ where
request_headers: &HeaderMap,
state: &A,
) -> RouterResult<(AuthenticationData, AuthenticationType)> {
let (auth_data, auth_type): (AuthenticationData, AuthenticationType) = self
.0
.authenticate_and_fetch(request_headers, state)
.await?;

let profile_id = HeaderMapStruct::new(request_headers)
.get_id_type_from_header::<id_type::ProfileId>(headers::X_PROFILE_ID)?;

let key_manager_state = &(&state.session_state()).into();
let profile = state
.store()
.find_business_profile_by_profile_id(
key_manager_state,
&auth_data.key_store,
&profile_id,
)
.await
.to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;
let enable_partial_auth = state.conf().api_keys.get_inner().enable_partial_auth;

let auth_data_v2 = AuthenticationData {
merchant_account: auth_data.merchant_account,
key_store: auth_data.key_store,
profile,
};
Ok((auth_data_v2, auth_type))
match enable_partial_auth {
true => self.0.authenticate_and_fetch(request_headers, state).await,
false => {
let auth = self
.0
.authenticate_and_fetch(request_headers, state)
.await?;
Ok(auth)
}
}
Comment on lines +685 to +694
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the purpose of this match?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add a comment

}
}

Expand Down
Loading