diff options
author | Yigit Sever | 2021-04-14 18:06:06 +0300 |
---|---|---|
committer | Yigit Sever | 2021-04-14 19:12:51 +0300 |
commit | 5c99a0e971b0eae07589a6727faa219123973b56 (patch) | |
tree | 7cb77db9597d6f6fa14563e73506eb2cb695d043 | |
parent | d081eb803cb94aec8122e56ffe7a3256bf4c314c (diff) | |
download | gradecoin-5c99a0e971b0eae07589a6727faa219123973b56.tar.gz gradecoin-5c99a0e971b0eae07589a6727faa219123973b56.tar.bz2 gradecoin-5c99a0e971b0eae07589a6727faa219123973b56.zip |
[WIP] Rough authentication process done
-rw-r--r-- | src/handlers.rs | 11 |
1 files changed, 11 insertions, 0 deletions
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( | |||
152 | return Ok(warp::reply::with_status(res_json, StatusCode::BAD_REQUEST)); | 152 | return Ok(warp::reply::with_status(res_json, StatusCode::BAD_REQUEST)); |
153 | } | 153 | } |
154 | 154 | ||
155 | // We're using this as the validator | ||
156 | // I hate myself | ||
157 | if let Err(_) = DecodingKey::from_rsa_pem(request.public_key.as_bytes()) { | ||
158 | let res_json = warp::reply::json(&GradeCoinResponse { | ||
159 | res: ResponseType::Error, | ||
160 | message: "The supplied RSA public key is not in valid PEM format".to_owned(), | ||
161 | }); | ||
162 | |||
163 | return Ok(warp::reply::with_status(res_json, StatusCode::BAD_REQUEST)); | ||
164 | } | ||
165 | |||
155 | let fingerprint = format!("{:x}", Sha256::digest(&request.public_key.as_bytes())); | 166 | let fingerprint = format!("{:x}", Sha256::digest(&request.public_key.as_bytes())); |
156 | 167 | ||
157 | let new_user = User { | 168 | let new_user = User { |