feat: added verification for the ssh keys #42
1 changed files with 4 additions and 13 deletions
|
@ -440,12 +440,6 @@ pub mod ssh {
|
||||||
email: String,
|
email: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
|
||||||
struct RequestResult {
|
|
||||||
auth: String,
|
|
||||||
keys: Vec<String>,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn request(mut req: Request<State>) -> tide::Result {
|
pub async fn request(mut req: Request<State>) -> tide::Result {
|
||||||
let RequestChallenge {
|
let RequestChallenge {
|
||||||
user,
|
user,
|
||||||
|
@ -459,7 +453,7 @@ pub mod ssh {
|
||||||
}
|
}
|
||||||
|
|
||||||
let config = &req.state().config;
|
let config = &req.state().config;
|
||||||
|
|
||||||
// check if <root>/<user>/.ssh/authorized_keys exists
|
// check if <root>/<user>/.ssh/authorized_keys exists
|
||||||
let root = &config.ssh_root;
|
let root = &config.ssh_root;
|
||||||
let path = format!("{}/{}/.ssh/authorized_keys", root, user);
|
let path = format!("{}/{}/.ssh/authorized_keys", root, user);
|
||||||
|
@ -570,12 +564,9 @@ pub mod ssh {
|
||||||
if let Ok(x) = AuthorizedKeys::read_file(path) {
|
if let Ok(x) = AuthorizedKeys::read_file(path) {
|
||||||
for entry in x {
|
for entry in x {
|
||||||
let key = entry.public_key();
|
let key = entry.public_key();
|
||||||
match key.verify("file", msg, &sig) {
|
if key.verify("file", msg, &sig).is_ok() {
|
||||||
Ok(_) => {
|
valid = true;
|
||||||
valid = true;
|
break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
Err(_) => {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue