10
0
Fork 0
mirror of https://github.com/ZeusWPI/ZNS.git synced 2024-11-21 21:41: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 diesel::PgConnection;
use reqwest::header::ACCEPT;
use crate::{ use crate::{
config::Config, config::Config,
@ -34,11 +35,15 @@ pub async fn authenticate(
} }
async fn validate_ssh(username: &String, sig: &Sig) -> Result<bool, reqwest::Error> { async fn validate_ssh(username: &String, sig: &Sig) -> Result<bool, reqwest::Error> {
Ok(reqwest::get(format!( let client = reqwest::Client::new();
"{}/users/keys/{}", Ok(client
.get(format!(
"{}/users/{}/keys",
Config::get().zauth_url, Config::get().zauth_url,
username username
)) ))
.header(ACCEPT, "application/json")
.send()
.await? .await?
.json::<Vec<String>>() .json::<Vec<String>>()
.await? .await?

View file

@ -71,7 +71,9 @@ impl<'a> Reader<'a> {
message: String::from("Seeking into the future is not allowed!!"), message: String::from("Seeking into the future is not allowed!!"),
}) })
} else { } 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 response
} }
Err(e) => { Err(e) => {
println!("{:#?}", message);
eprintln!("{}", e.to_string()); eprintln!("{}", e.to_string());
message.set_response(e.rcode()); message.set_response(e.rcode());
message message