From 85b29df4208b83c1949032db56c8d76e8c76b705 Mon Sep 17 00:00:00 2001 From: alpaylan Date: Wed, 14 Apr 2021 16:36:42 +0300 Subject: embed user passwds to the code structs. --- src/handlers.rs | 2 +- src/schema.rs | 41 +++++++++++++++++++++++++++++++++-------- 2 files changed, 34 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/handlers.rs b/src/handlers.rs index e34abbe..b9df931 100644 --- a/src/handlers.rs +++ b/src/handlers.rs @@ -39,7 +39,7 @@ pub async fn authenticate_user( debug!("POST request to /register, authenticate_user"); let provided_id = request.student_id.clone(); - let priv_student_id = match MetuId::new(request.student_id) { + let priv_student_id = match MetuId::new(request.student_id, request.passwd) { Some(id) => id, None => { let res_json = warp::reply::json(&GradeCoinResponse { diff --git a/src/schema.rs b/src/schema.rs index 55e46c0..65150c1 100644 --- a/src/schema.rs +++ b/src/schema.rs @@ -132,22 +132,47 @@ pub struct User { #[derive(Serialize, Deserialize, Debug, PartialEq)] pub struct MetuId { id: String, + passwd: String, } // TODO: this will arrive encrypted <13-04-21, yigit> // #[derive(Serialize, Deserialize, Debug, PartialEq)] pub struct AuthRequest { pub student_id: String, + pub passwd: String, pub public_key: String, } lazy_static! { - static ref OUR_STUDENTS: HashSet<&'static str> = { + static ref OUR_STUDENTS: HashSet<(&'static str, &'static str)> = { [ - "e254275", "e223687", "e211024", "e209888", "e223725", "e209362", "e209898", "e230995", - "e223743", "e223747", "e223749", "e223751", "e188126", "e209913", "e203608", "e233013", - "e216982", "e217185", "e223780", "e194931", "e223783", "e254550", "e217203", "e217477", - "e223786", "e231060", "e223795", + ("e254275", "DtNX1qk4YF4saRH"), + ("e223687", "cvFEs4XLjuGBD1v"), + ("e211024", "voQAcxiKJmEXYRT"), + ("e209888", "O75dli6AQtz2tUi"), + ("e223725", "xXuTD3Y4tyrv2Jz"), + ("e209362", "N7wGm5XU5zVWOWu"), + ("e209898", "aKBFfB8fZMq8pVn"), + ("e230995", "TgcHGlqeFhQGx42"), + ("e223743", "YVWVSWuIHplJk9C"), + ("e223747", "8LAeHrsjnwXh59Q"), + ("e223749", "HMFeJqVOzwCPHbc"), + ("e223751", "NjMsxmtmy2VOwMW"), + ("e188126", "QibuPdV2gXfsVJW"), + ("e209913", "kMxJvl2vHSWCy4A"), + ("e203608", "mfkkR0MWurk6Rp1"), + ("e233013", "GCqHxdOaDj2pWXx"), + ("e216982", "2Z0xmgCStnj5qg5"), + ("e217185", "BcaZNlzlhPph7A3"), + ("e223780", "2KvVxKUQaA9H4sn"), + ("e194931", "hsC0Wb8PQ5vzwdQ"), + ("e223783", "ETUJA3kt1QYvJai"), + ("e254550", "rPRjX0A4NefvKWi"), + ("e217203", "lN3IWhGyCrGfkk5"), + ("e217477", "O9xlMaa7LanC82w"), + ("e223786", "UxI6czykJfp9T9N"), + ("e231060", "VJgziofQQPCoisH"), + ("e223795", "pmcTCKox99NFsqp"), ] .iter() .cloned() @@ -162,9 +187,9 @@ impl fmt::Display for MetuId { } impl MetuId { - pub fn new(id: String) -> Option { - if OUR_STUDENTS.contains(&*id) { - Some(MetuId { id: id }) + pub fn new(id: String, pwd: String) -> Option { + if OUR_STUDENTS.contains(&(&*id, &*pwd)) { + Some(MetuId { id: id, passwd: pwd }) } else { None } -- cgit v1.2.3-70-g09d2