aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authoralpaylan2021-04-14 16:36:42 +0300
committeralpaylan2021-04-14 16:36:42 +0300
commit85b29df4208b83c1949032db56c8d76e8c76b705 (patch)
tree5c44f069e0e5de7044e0ac26c4c2a4fffceec6ec /src
parent3bb302ccef77af5650a088c7030563ba84d1552c (diff)
downloadgradecoin-85b29df4208b83c1949032db56c8d76e8c76b705.tar.gz
gradecoin-85b29df4208b83c1949032db56c8d76e8c76b705.tar.bz2
gradecoin-85b29df4208b83c1949032db56c8d76e8c76b705.zip
embed user passwds to the code structs.
Diffstat (limited to 'src')
-rw-r--r--src/handlers.rs2
-rw-r--r--src/schema.rs41
2 files changed, 34 insertions, 9 deletions
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(
39 debug!("POST request to /register, authenticate_user"); 39 debug!("POST request to /register, authenticate_user");
40 let provided_id = request.student_id.clone(); 40 let provided_id = request.student_id.clone();
41 41
42 let priv_student_id = match MetuId::new(request.student_id) { 42 let priv_student_id = match MetuId::new(request.student_id, request.passwd) {
43 Some(id) => id, 43 Some(id) => id,
44 None => { 44 None => {
45 let res_json = warp::reply::json(&GradeCoinResponse { 45 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 {
132#[derive(Serialize, Deserialize, Debug, PartialEq)] 132#[derive(Serialize, Deserialize, Debug, PartialEq)]
133pub struct MetuId { 133pub struct MetuId {
134 id: String, 134 id: String,
135 passwd: String,
135} 136}
136 137
137// TODO: this will arrive encrypted <13-04-21, yigit> // 138// TODO: this will arrive encrypted <13-04-21, yigit> //
138#[derive(Serialize, Deserialize, Debug, PartialEq)] 139#[derive(Serialize, Deserialize, Debug, PartialEq)]
139pub struct AuthRequest { 140pub struct AuthRequest {
140 pub student_id: String, 141 pub student_id: String,
142 pub passwd: String,
141 pub public_key: String, 143 pub public_key: String,
142} 144}
143 145
144lazy_static! { 146lazy_static! {
145 static ref OUR_STUDENTS: HashSet<&'static str> = { 147 static ref OUR_STUDENTS: HashSet<(&'static str, &'static str)> = {
146 [ 148 [
147 "e254275", "e223687", "e211024", "e209888", "e223725", "e209362", "e209898", "e230995", 149 ("e254275", "DtNX1qk4YF4saRH"),
148 "e223743", "e223747", "e223749", "e223751", "e188126", "e209913", "e203608", "e233013", 150 ("e223687", "cvFEs4XLjuGBD1v"),
149 "e216982", "e217185", "e223780", "e194931", "e223783", "e254550", "e217203", "e217477", 151 ("e211024", "voQAcxiKJmEXYRT"),
150 "e223786", "e231060", "e223795", 152 ("e209888", "O75dli6AQtz2tUi"),
153 ("e223725", "xXuTD3Y4tyrv2Jz"),
154 ("e209362", "N7wGm5XU5zVWOWu"),
155 ("e209898", "aKBFfB8fZMq8pVn"),
156 ("e230995", "TgcHGlqeFhQGx42"),
157 ("e223743", "YVWVSWuIHplJk9C"),
158 ("e223747", "8LAeHrsjnwXh59Q"),
159 ("e223749", "HMFeJqVOzwCPHbc"),
160 ("e223751", "NjMsxmtmy2VOwMW"),
161 ("e188126", "QibuPdV2gXfsVJW"),
162 ("e209913", "kMxJvl2vHSWCy4A"),
163 ("e203608", "mfkkR0MWurk6Rp1"),
164 ("e233013", "GCqHxdOaDj2pWXx"),
165 ("e216982", "2Z0xmgCStnj5qg5"),
166 ("e217185", "BcaZNlzlhPph7A3"),
167 ("e223780", "2KvVxKUQaA9H4sn"),
168 ("e194931", "hsC0Wb8PQ5vzwdQ"),
169 ("e223783", "ETUJA3kt1QYvJai"),
170 ("e254550", "rPRjX0A4NefvKWi"),
171 ("e217203", "lN3IWhGyCrGfkk5"),
172 ("e217477", "O9xlMaa7LanC82w"),
173 ("e223786", "UxI6czykJfp9T9N"),
174 ("e231060", "VJgziofQQPCoisH"),
175 ("e223795", "pmcTCKox99NFsqp"),
151 ] 176 ]
152 .iter() 177 .iter()
153 .cloned() 178 .cloned()
@@ -162,9 +187,9 @@ impl fmt::Display for MetuId {
162} 187}
163 188
164impl MetuId { 189impl MetuId {
165 pub fn new(id: String) -> Option<Self> { 190 pub fn new(id: String, pwd: String) -> Option<Self> {
166 if OUR_STUDENTS.contains(&*id) { 191 if OUR_STUDENTS.contains(&(&*id, &*pwd)) {
167 Some(MetuId { id: id }) 192 Some(MetuId { id: id, passwd: pwd })
168 } else { 193 } else {
169 None 194 None
170 } 195 }