diff options
author | Yigit Sever | 2021-04-16 05:47:08 +0300 |
---|---|---|
committer | Yigit Sever | 2021-04-16 05:47:08 +0300 |
commit | b7cd484a869600e181dd06522befbfd091a7a488 (patch) | |
tree | a6176a72a7b8adc3b1ae9bed73adc8a7b1f3674f /src/handlers.rs | |
parent | f46572b5befc3fc1af6e33d8e8b61f47e1c18058 (diff) | |
download | gradecoin-b7cd484a869600e181dd06522befbfd091a7a488.tar.gz gradecoin-b7cd484a869600e181dd06522befbfd091a7a488.tar.bz2 gradecoin-b7cd484a869600e181dd06522befbfd091a7a488.zip |
Almost passsing auth
Diffstat (limited to 'src/handlers.rs')
-rw-r--r-- | src/handlers.rs | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/handlers.rs b/src/handlers.rs index 376d079..2401c0d 100644 --- a/src/handlers.rs +++ b/src/handlers.rs | |||
@@ -139,8 +139,9 @@ pub async fn authenticate_user( | |||
139 | } | 139 | } |
140 | }; | 140 | }; |
141 | 141 | ||
142 | // TODO: request iv is coming with base64 encoding <16-04-21, yigit> // | 142 | let byte_iv = base64::decode(&request.iv).unwrap(); |
143 | let cipher = match Aes128Cbc::new_var(&temp_key, &request.iv.as_bytes()) { | 143 | |
144 | let cipher = match Aes128Cbc::new_var(&temp_key, &byte_iv) { | ||
144 | Ok(c) => c, | 145 | Ok(c) => c, |
145 | Err(err) => { | 146 | Err(err) => { |
146 | debug!( | 147 | debug!( |
@@ -175,17 +176,19 @@ pub async fn authenticate_user( | |||
175 | } | 176 | } |
176 | }; | 177 | }; |
177 | 178 | ||
179 | println!(">>>{:?}<<<", auth_packet); | ||
180 | |||
178 | let auth_plaintext = match cipher.decrypt_vec(&auth_packet) { | 181 | let auth_plaintext = match cipher.decrypt_vec(&auth_packet) { |
179 | Ok(p) => p, | 182 | Ok(p) => p, |
180 | Err(err) => { | 183 | Err(err) => { |
181 | debug!( | 184 | println!( |
182 | "Base64 decoded auth request did not decrypt correctly {:?} {}", | 185 | "Base64 decoded auth request did not decrypt correctly {:?} {}", |
183 | &auth_packet, err | 186 | &auth_packet, err |
184 | ); | 187 | ); |
185 | 188 | ||
186 | let res_json = warp::reply::json(&GradeCoinResponse { | 189 | let res_json = warp::reply::json(&GradeCoinResponse { |
187 | res: ResponseType::Error, | 190 | res: ResponseType::Error, |
188 | message: "The Bas64 decoded auth request did not decrypt correctly".to_owned(), | 191 | message: "The Base64 decoded auth request did not decrypt correctly".to_owned(), |
189 | }); | 192 | }); |
190 | 193 | ||
191 | return Ok(warp::reply::with_status(res_json, StatusCode::BAD_REQUEST)); | 194 | return Ok(warp::reply::with_status(res_json, StatusCode::BAD_REQUEST)); |
@@ -608,7 +611,8 @@ pub async fn authorized_propose_transaction( | |||
608 | // this transaction was already checked for correctness at custom_filters, we can panic here if | 611 | // this transaction was already checked for correctness at custom_filters, we can panic here if |
609 | // it has been changed since | 612 | // it has been changed since |
610 | 613 | ||
611 | let hashed_transaction = Md5::digest((&serde_json::to_string(&new_transaction).unwrap()).as_ref()); | 614 | let hashed_transaction = |
615 | Md5::digest((&serde_json::to_string(&new_transaction).unwrap()).as_ref()); | ||
612 | if token_payload.claims.tha != format!("{:x}", hashed_transaction) { | 616 | if token_payload.claims.tha != format!("{:x}", hashed_transaction) { |
613 | println!( | 617 | println!( |
614 | "the hash of the request {:x} did not match the hash given in jwt {:?}", | 618 | "the hash of the request {:x} did not match the hash given in jwt {:?}", |