Skip to content

Commit 6d6f503

Browse files
committed
Refactor OIDC redirect URL cookie retrieval to streamline logic and improve error handling
1 parent f9d477f commit 6d6f503

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

src/webserver/oidc.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -806,16 +806,12 @@ fn get_nonce_from_cookie(request: &ServiceRequest) -> anyhow::Result<Nonce> {
806806
fn get_redirect_url_cookie(
807807
request: &ServiceRequest,
808808
csrf_token: &CsrfToken,
809-
) -> Result<Cookie<'static>, anyhow::Error> {
810-
let cookie_name = format!(
811-
"{}{}",
812-
SQLPAGE_REDIRECT_URL_COOKIE_PREFIX,
813-
csrf_token.secret()
814-
);
815-
let cookie = request
809+
) -> anyhow::Result<Cookie<'static>> {
810+
let state = csrf_token.secret();
811+
let cookie_name = format!("{SQLPAGE_REDIRECT_URL_COOKIE_PREFIX}{state}");
812+
request
816813
.cookie(&cookie_name)
817-
.with_context(|| format!("No {cookie_name} cookie found"))?;
818-
Ok(cookie)
814+
.with_context(|| format!("No {cookie_name} cookie found"))
819815
}
820816

821817
/// Given an audience, verify if it is trusted. The `client_id` is always trusted, independently of this function.

0 commit comments

Comments
 (0)