diff --git a/app-service/Dockerfile b/app-service/Dockerfile index 23441cc26..7c647dc7f 100644 --- a/app-service/Dockerfile +++ b/app-service/Dockerfile @@ -1,8 +1,8 @@ # Start with image that has the Rust toolchain installed -FROM rust:1.90-alpine AS chef +FROM rust:1.91-alpine AS chef USER root # Add cargo-chef to cache dependencies -RUN apk add --no-cache musl-dev & cargo install cargo-chef +RUN apk add --no-cache musl-dev && cargo install cargo-chef --locked WORKDIR /app FROM chef AS planner diff --git a/auth-service/Dockerfile b/auth-service/Dockerfile index 8dac2d5aa..e40355abd 100644 --- a/auth-service/Dockerfile +++ b/auth-service/Dockerfile @@ -1,8 +1,8 @@ # Start with image that has the Rust toolchain installed -FROM rust:1.90-alpine AS chef +FROM rust:1.91-alpine AS chef USER root # Add cargo-chef to cache dependencies -RUN apk add --no-cache musl-dev & cargo install cargo-chef +RUN apk add --no-cache musl-dev && cargo install cargo-chef --locked WORKDIR /app FROM chef AS planner diff --git a/auth-service/src/routes/login.rs b/auth-service/src/routes/login.rs index 770834608..775665646 100644 --- a/auth-service/src/routes/login.rs +++ b/auth-service/src/routes/login.rs @@ -12,36 +12,36 @@ pub async fn login( State(state): State, jar: CookieJar, Json(request): Json, -) -> (CookieJar, Result) { +) -> Result<(CookieJar, impl IntoResponse), AuthAPIError> { let password = match Password::parse(request.password) { Ok(password) => password, - Err(_) => return (jar, Err(AuthAPIError::InvalidCredentials)), + Err(_) => return Err(AuthAPIError::InvalidCredentials), }; let email = match Email::parse(request.email) { Ok(email) => email, - Err(_) => return (jar, Err(AuthAPIError::InvalidCredentials)), + Err(_) => return Err(AuthAPIError::InvalidCredentials), }; let user_store = &state.user_store.read().await; if user_store.validate_user(&email, &password).await.is_err() { - return (jar, Err(AuthAPIError::IncorrectCredentials)); + return Err(AuthAPIError::IncorrectCredentials); } let user = match user_store.get_user(&email).await { Ok(user) => user, - Err(_) => return (jar, Err(AuthAPIError::IncorrectCredentials)), + Err(_) => return Err(AuthAPIError::IncorrectCredentials), }; let auth_cookie = match generate_auth_cookie(&user.email) { Ok(cookie) => cookie, - Err(_) => return (jar, Err(AuthAPIError::UnexpectedError)), + Err(_) => return Err(AuthAPIError::UnexpectedError), }; let updated_jar = jar.add(auth_cookie); - (updated_jar, Ok(StatusCode::OK.into_response())) + Ok((updated_jar, StatusCode::OK.into_response())) } #[derive(Deserialize)] diff --git a/auth-service/src/routes/logout.rs b/auth-service/src/routes/logout.rs index 66de33789..9b1d4b5c0 100644 --- a/auth-service/src/routes/logout.rs +++ b/auth-service/src/routes/logout.rs @@ -10,17 +10,17 @@ use crate::{ pub async fn logout( State(state): State, jar: CookieJar, -) -> (CookieJar, Result) { +) -> Result<(CookieJar, impl IntoResponse), AuthAPIError> { let cookie = match jar.get(JWT_COOKIE_NAME) { Some(cookie) => cookie, - None => return (jar, Err(AuthAPIError::MissingToken)), + None => return Err(AuthAPIError::MissingToken), }; // Validate token let token = cookie.value().to_owned(); let _ = match validate_token(&token, state.banned_token_store.clone()).await { Ok(claims) => claims, - Err(_) => return (jar, Err(AuthAPIError::InvalidToken)), + Err(_) => return Err(AuthAPIError::InvalidToken), }; // Add token to banned list @@ -32,11 +32,11 @@ pub async fn logout( .await .is_err() { - return (jar, Err(AuthAPIError::UnexpectedError)); + return Err(AuthAPIError::UnexpectedError); } // Remove jwt cookie let jar = jar.remove(cookie::Cookie::from(JWT_COOKIE_NAME)); - (jar, Ok(StatusCode::OK)) + Ok((jar, StatusCode::OK)) }