diff options
author | Yigit Sever | 2021-04-14 18:06:06 +0300 |
---|---|---|
committer | Yigit Sever | 2021-04-14 19:12:51 +0300 |
commit | c1f9303595df9c5d99c4973cde667ef8b6620f97 (patch) | |
tree | 3a63dfc89c0c2de2fb51460022b0dfa5cc303ecc /src | |
parent | ecddd94e0baa490dbbd3562ff59eb180bddfbef3 (diff) | |
download | gradecoin-c1f9303595df9c5d99c4973cde667ef8b6620f97.tar.gz gradecoin-c1f9303595df9c5d99c4973cde667ef8b6620f97.tar.bz2 gradecoin-c1f9303595df9c5d99c4973cde667ef8b6620f97.zip |
[WIP] Rough authentication process done
Diffstat (limited to 'src')
-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 { |