10
0
Fork 0
mirror of https://github.com/ZeusWPI/ZNS.git synced 2024-11-24 14:11:10 +01:00
This commit is contained in:
Xander Bil 2024-07-08 21:25:32 +02:00
parent 5d59f1bd97
commit e99ba5c97e
No known key found for this signature in database
GPG key ID: EC9706B54A278598
3 changed files with 18 additions and 12 deletions

View file

@ -1,4 +1,5 @@
use diesel::PgConnection;
use reqwest::header::ACCEPT;
use crate::{
config::Config,
@ -34,16 +35,20 @@ pub async fn authenticate(
}
async fn validate_ssh(username: &String, sig: &Sig) -> Result<bool, reqwest::Error> {
Ok(reqwest::get(format!(
"{}/users/keys/{}",
Config::get().zauth_url,
username
))
.await?
.json::<Vec<String>>()
.await?
.iter()
.any(|key| sig.verify_ssh(&key).is_ok_and(|b| b)))
let client = reqwest::Client::new();
Ok(client
.get(format!(
"{}/users/{}/keys",
Config::get().zauth_url,
username
))
.header(ACCEPT, "application/json")
.send()
.await?
.json::<Vec<String>>()
.await?
.iter()
.any(|key| sig.verify_ssh(&key).is_ok_and(|b| b)))
}
async fn validate_dnskey(

View file

@ -71,7 +71,9 @@ impl<'a> Reader<'a> {
message: String::from("Seeking into the future is not allowed!!"),
})
} else {
Ok(Reader::new(&self.buffer[position..self.position]))
let mut reader = Reader::new(&self.buffer[0..self.position]);
reader.position = position;
Ok(reader)
}
}
}

View file

@ -50,7 +50,6 @@ async fn get_response(bytes: &[u8]) -> Message {
response
}
Err(e) => {
println!("{:#?}", message);
eprintln!("{}", e.to_string());
message.set_response(e.rcode());
message