Retry auth if failed to obtain the auth cookie

This commit is contained in:
Kevin Yue 2024-02-07 19:33:58 +08:00
parent c408482c55
commit 3736189308

View File

@ -413,7 +413,19 @@ fn read_auth_data(main_resource: &WebResource, auth_result_tx: mpsc::UnboundedSe
} }
Err(AuthDataError::NotFound) => { Err(AuthDataError::NotFound) => {
info!("No auth data found in headers, trying to read from body..."); info!("No auth data found in headers, trying to read from body...");
let url = main_resource.uri().unwrap_or("".into());
let is_acs_endpoint = url.contains("/SAML20/SP/ACS");
read_auth_data_from_body(main_resource, move |auth_result| { read_auth_data_from_body(main_resource, move |auth_result| {
// If the endpoint is `/SAML20/SP/ACS` and no auth data found in body, it should be considered as invalid
let auth_result = auth_result.map_err(|err| {
if matches!(err, AuthDataError::NotFound) && is_acs_endpoint {
AuthDataError::Invalid
} else {
err
}
});
send_auth_result(&auth_result_tx, auth_result) send_auth_result(&auth_result_tx, auth_result)
}); });
} }