Browse Source

rebase fix

pull/5620/head
Guilhem Zeitoun 1 week ago
parent
commit
29d76b5451
Failed to extract signature
  1. 6
      src/config.rs
  2. 29
      src/mail.rs

6
src/config.rs

@ -886,15 +886,9 @@ make_config! {
smtp_username: String, true, option; smtp_username: String, true, option;
/// Password /// Password
smtp_password: Pass, true, option; smtp_password: Pass, true, option;
<<<<<<< HEAD
/// Dkim signature (private key). |> Private must be base64-encoded ed key or PKCS#1 format RSA key. If set, dkim_selector and dkim_domain must be set as well. /// Dkim signature (private key). |> Private must be base64-encoded ed key or PKCS#1 format RSA key. If set, dkim_selector and dkim_domain must be set as well.
dkim_signing_key: String, true, option; dkim_signing_key: String, true, option;
/// Dkim algorithm (true if RSA else ed25519) /// Dkim algorithm (true if RSA else ed25519)
=======
/// Dkim private key (type:privatekey). Private must be base64-encoded ed key or PKCS#1 format RSA key.
dkim_privatekey: String, true, option;
/// Dkim algo (true if RSA else ed25519)
>>>>>>> f829426d (Corrections on env and naming.)
dkim_use_rsa: bool, true, def, false; dkim_use_rsa: bool, true, def, false;
/// Dkim selector /// Dkim selector
dkim_selector: String, true, option; dkim_selector: String, true, option;

29
src/mail.rs

@ -15,7 +15,6 @@ use lettre::{
use percent_encoding::{NON_ALPHANUMERIC, percent_encode}; use percent_encoding::{NON_ALPHANUMERIC, percent_encode};
use crate::{ use crate::{
<<<<<<< HEAD
CONFIG, CONFIG,
api::EmptyResult, api::EmptyResult,
auth::{ auth::{
@ -25,12 +24,6 @@ use crate::{
db::models::{Device, DeviceType, EmergencyAccessId, MembershipId, OrganizationId, User, UserId}, db::models::{Device, DeviceType, EmergencyAccessId, MembershipId, OrganizationId, User, UserId},
error::Error, error::Error,
util::{get_env_str_value, upcase_first}, util::{get_env_str_value, upcase_first},
=======
CONFIG, api::EmptyResult, auth::{
encode_jwt, generate_delete_claims, generate_emergency_access_invite_claims, generate_invite_claims,
generate_verify_email_claims,
}, db::models::{Device, DeviceType, EmergencyAccessId, MembershipId, OrganizationId, User, UserId}, error::Error, util::get_env
>>>>>>> f829426d (Corrections on env and naming.)
}; };
fn sendmail_transport() -> AsyncSendmailTransport<Tokio1Executor> { fn sendmail_transport() -> AsyncSendmailTransport<Tokio1Executor> {
@ -711,7 +704,6 @@ async fn send_with_selected_transport(email: Message) -> EmptyResult {
} }
} }
pub fn check_dkim() -> Result<Option<DkimConfig>, String> { pub fn check_dkim() -> Result<Option<DkimConfig>, String> {
<<<<<<< HEAD
match ( match (
CONFIG.dkim_signing_key().and_then(|a| get_env_str_value(&a)), CONFIG.dkim_signing_key().and_then(|a| get_env_str_value(&a)),
CONFIG.dkim_domain().and_then(|a| get_env_str_value(&a)), CONFIG.dkim_domain().and_then(|a| get_env_str_value(&a)),
@ -738,27 +730,6 @@ pub fn check_dkim() -> Result<Option<DkimConfig>, String> {
_ => Err( _ => Err(
"DKIM setting is badly implemented. One config is missing or invalid (DKIM signature or DKIM infos or DKIM signing key).".to_owned(), "DKIM setting is badly implemented. One config is missing or invalid (DKIM signature or DKIM infos or DKIM signing key).".to_owned(),
), ),
=======
match (get_env::<String>("dkim_privatekey"), CONFIG.dkim_infos()) {
(Some(pk), Some(infos)) => {
let algo = if CONFIG.dkim_use_rsa() {DkimSigningAlgorithm::Rsa } else { DkimSigningAlgorithm::Ed25519 };
let (selector, domain, privatekey) = match (DkimSigningKey::new(pk.as_str(), algo), infos.split(':').collect::<Vec<&str>>()) {
(Ok(sig), split2) if split2.len() == 2 => {
let (selector, domain, sig) =
(String::from(*split2.first().unwrap()), String::from(*split2.last().unwrap()), sig);
(selector, domain, sig)
}
_ => {
return Err("DKIM issue, invalid domain, selector.".to_string());
}
};
return Ok(Some(DkimConfig::default_config(selector, domain, privatekey)));
},
(None, None) => Ok(None),
_ => {
Err("DKIM setting is badly implemented. One config is missing (DKIM signature or DKIM infos).".to_string())
}
>>>>>>> f829426d (Corrections on env and naming.)
} }
} }
async fn send_email(address: &str, subject: &str, body_html: String, body_text: String) -> EmptyResult { async fn send_email(address: &str, subject: &str, body_html: String, body_text: String) -> EmptyResult {

Loading…
Cancel
Save