Add introducers
- add the `Introducer` types - get introducers from the certificate store (and log them)
This commit is contained in:
@@ -14,10 +14,13 @@ use sequoia_directories::Home;
|
||||
use crate::{config::HuskConfig, crypto};
|
||||
use crate::types::mail_context::MailContext;
|
||||
|
||||
use crate::types::introducer::Introducer;
|
||||
|
||||
pub struct HuskContext<'hc> {
|
||||
pub policy: StandardPolicy<'hc>,
|
||||
pub cert_store: CertStore<'hc>,
|
||||
pub local_trust_root: Cert,
|
||||
pub introducers: Vec<Introducer>,
|
||||
pub mail: MailContext<'hc>,
|
||||
}
|
||||
|
||||
@@ -33,11 +36,13 @@ impl<'hc> HuskContext<'hc> {
|
||||
let policy = StandardPolicy::new();
|
||||
|
||||
let local_trust_root = crypto::get_local_trust_root(&cert_store)?;
|
||||
let introducers = crypto::get_introducers(&cert_store, &policy, local_trust_root.fingerprint());
|
||||
|
||||
Ok(HuskContext {
|
||||
policy,
|
||||
cert_store,
|
||||
local_trust_root,
|
||||
introducers,
|
||||
mail: MailContext::new(),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
//
|
||||
// husk-milter
|
||||
//
|
||||
// introducers
|
||||
//
|
||||
|
||||
use sequoia_wot as wot;
|
||||
use wot::{CertSynopsis, Certification};
|
||||
use sequoia_openpgp::{policy::StandardPolicy, Cert, KeyID};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Introducer {
|
||||
pub cert: CertSynopsis,
|
||||
pub certification: Certification,
|
||||
}
|
||||
|
||||
impl Introducer {
|
||||
|
||||
pub fn can_introduce(&self, email: &str) -> bool {
|
||||
if let Some(regexset) = self.certification.regular_expressions() {
|
||||
if regexset.matches_everything() {
|
||||
// return false, because unlimited certifications are
|
||||
// ignored.
|
||||
false
|
||||
} else {
|
||||
regexset.is_match(email)
|
||||
}
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,3 +2,4 @@ pub mod husk_context;
|
||||
pub mod mail_context;
|
||||
pub mod errors;
|
||||
pub mod recipient;
|
||||
pub mod introducer;
|
||||
|
||||
Reference in New Issue
Block a user