From c1f9303595df9c5d99c4973cde667ef8b6620f97 Mon Sep 17 00:00:00 2001 From: Yigit Sever Date: Wed, 14 Apr 2021 18:06:06 +0300 Subject: [WIP] Rough authentication process done --- src/handlers.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/handlers.rs b/src/handlers.rs index 25b7098..4a1edcc 100644 --- a/src/handlers.rs +++ b/src/handlers.rs @@ -152,6 +152,17 @@ pub async fn authenticate_user( return Ok(warp::reply::with_status(res_json, StatusCode::BAD_REQUEST)); } + // We're using this as the validator + // I hate myself + if let Err(_) = DecodingKey::from_rsa_pem(request.public_key.as_bytes()) { + let res_json = warp::reply::json(&GradeCoinResponse { + res: ResponseType::Error, + message: "The supplied RSA public key is not in valid PEM format".to_owned(), + }); + + return Ok(warp::reply::with_status(res_json, StatusCode::BAD_REQUEST)); + } + let fingerprint = format!("{:x}", Sha256::digest(&request.public_key.as_bytes())); let new_user = User { -- cgit v1.2.3-70-g09d2