wip: JWTAuthenticated

TODO: move into api/

fix: test

chore: move JWTAuthenticated into extract

chore: fmt
This commit is contained in:
2023-03-10 12:15:48 +01:00
parent dffbcceeba
commit f47c57c1c0
4 changed files with 115 additions and 28 deletions

View File

@@ -63,12 +63,8 @@ pub async fn read_pubkey_dir(path: impl AsRef<Path> + Debug) -> anyhow::Result<V
while let Some(entry) = dir.next_entry().await? {
//TODO: investigate why path().ends_with doesn't work
let file_name = entry.file_name().into_string().unwrap();
if !file_name.ends_with(".pub") || file_name.ends_with("-cert.pub")
{
trace!(
"skipped {:?} due to missing '.pub' extension",
entry.path()
);
if !file_name.ends_with(".pub") || file_name.ends_with("-cert.pub") {
trace!("skipped {:?} due to missing '.pub' extension", entry.path());
continue;
}
let cert = load_public_key(entry.path()).await?;
@@ -77,7 +73,6 @@ pub async fn read_pubkey_dir(path: impl AsRef<Path> + Debug) -> anyhow::Result<V
}
}
Ok(pubs)
}
fn parse_utf8(bytes: Vec<u8>) -> anyhow::Result<String> {
@@ -158,5 +153,4 @@ pub async fn load_public_key(file: impl AsRef<Path> + Debug) -> anyhow::Result<O
Ok(Some(PublicKey::from_openssh(&string_repr).with_context(
|| format!("parse {:?} as openssh public key", &file),
)?))
}

View File

@@ -1,5 +1,3 @@
use axum_extra::routing::TypedPath;
use serde::{Deserialize, Serialize};
@@ -23,7 +21,7 @@ pub struct GetCertsPubkey {
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct CertIds {
pub ids: Vec<String>
pub ids: Vec<String>,
}
#[derive(TypedPath, Deserialize)]