delegate certificate init to ggemini wrapper, add structs for some, tuple entities, move match_priority to gemini impl area

This commit is contained in:
yggverse 2024-11-27 21:40:44 +02:00
parent 36f07aa773
commit 053c078e11
6 changed files with 53 additions and 29 deletions

View file

@ -2,11 +2,13 @@ mod auth;
mod certificate;
mod database;
mod error;
mod identity;
mod memory;
use auth::Auth;
use database::Database;
pub use error::Error;
use identity::Identity;
use memory::Memory;
@ -106,6 +108,24 @@ impl Gemini {
Ok(())
}
/// Get `pem` record match `request`
/// * [Client certificates specification](https://geminiprotocol.net/docs/protocol-specification.gmi#client-certificates)
/// * this function work with memory cache collected (not database)
pub fn match_priority(&self, request: &str) -> Option<Identity> {
if let Some(auth) = self.auth.memory.match_priority(request) {
match self.memory.get(auth.profile_identity_gemini_id) {
Ok(pem) => {
return Some(Identity {
scope: auth.scope,
pem,
})
}
Err(reason) => todo!("{:?}", reason.to_string()),
}
}
None
}
}
// Tools