Updated dependencies, removed valid mail check (now done by lettre), and updated global domains file

This commit is contained in:
Daniel García
2018-10-04 00:01:04 +02:00
parent 2aabf14372
commit 7112c86471
7 changed files with 206 additions and 205 deletions
Generated
+171 -162
View File
File diff suppressed because it is too large Load Diff
+8 -9
View File
@@ -5,12 +5,12 @@ authors = ["Daniel García <dani-garcia@users.noreply.github.com>"]
[dependencies]
# Web framework for nightly with a focus on ease-of-use, expressibility, and speed.
rocket = { version = "0.3.16", features = ["tls"] }
rocket_codegen = "0.3.16"
rocket_contrib = "0.3.16"
rocket = { version = "0.3.17", features = ["tls"] }
rocket_codegen = "0.3.17"
rocket_contrib = "0.3.17"
# HTTP client
reqwest = "0.9.0"
reqwest = "0.9.2"
# multipart/form-data support
multipart = "0.15.3"
@@ -27,7 +27,7 @@ chashmap = "2.2.0"
# A generic serialization/deserialization framework
serde = "1.0.79"
serde_derive = "1.0.79"
serde_json = "1.0.28"
serde_json = "1.0.31"
# A safe, extensible ORM and Query builder
diesel = { version = "1.3.3", features = ["sqlite", "chrono", "r2d2"] }
@@ -65,13 +65,12 @@ lazy_static = "1.1.0"
# Numerical libraries
num-traits = "0.2.6"
num-derive = "0.2.2"
num-derive = "0.2.3"
# Email libraries
lettre = "0.9.0"
lettre_email = "0.9.0"
native-tls = "0.2.1"
fast_chemail = "0.9.5"
# Number encoding library
byteorder = "1.2.6"
@@ -80,8 +79,8 @@ byteorder = "1.2.6"
# Make jwt use ring 0.11, to match rocket
jsonwebtoken = { path = "libs/jsonwebtoken" }
rmp = { git = 'https://github.com/dani-garcia/msgpack-rust' }
lettre = { git = 'https://github.com/lettre/lettre', rev = 'fc91bb6ee8f9a' }
lettre_email = { git = 'https://github.com/lettre/lettre', rev = 'fc91bb6ee8f9a' }
lettre = { git = 'https://github.com/lettre/lettre', rev = 'c988b1760ad81' }
lettre_email = { git = 'https://github.com/lettre/lettre', rev = 'c988b1760ad81' }
# Version 0.1.2 from crates.io lacks a commit that fixes a certificate error
u2f = { git = 'https://github.com/wisespace-io/u2f-rs', rev = '193de35093a44' }
+1 -1
View File
@@ -1 +1 @@
nightly-2018-09-12
nightly-2018-10-03
+6 -12
View File
@@ -5,7 +5,6 @@ use db::models::*;
use api::{PasswordData, JsonResult, EmptyResult, JsonUpcase, NumberOrString};
use auth::Headers;
use fast_chemail::is_valid_email;
use mail;
use CONFIG;
@@ -329,22 +328,17 @@ struct PasswordHintData {
fn password_hint(data: JsonUpcase<PasswordHintData>, conn: DbConn) -> EmptyResult {
let data: PasswordHintData = data.into_inner().data;
if !is_valid_email(&data.Email) {
err!("This email address is not valid...");
}
let hint = match User::find_by_mail(&data.Email, &conn) {
Some(user) => user.password_hint,
None => return Ok(()),
};
let user = User::find_by_mail(&data.Email, &conn);
if user.is_none() {
return Ok(());
}
let user = user.unwrap();
if let Some(ref mail_config) = CONFIG.mail {
if let Err(e) = mail::send_password_hint(&user.email, user.password_hint, mail_config) {
if let Err(e) = mail::send_password_hint(&data.Email, hint, mail_config) {
err!(format!("There have been a problem sending the email: {}", e));
}
} else if CONFIG.show_password_hint {
if let Some(hint) = user.password_hint {
if let Some(hint) = hint {
err!(format!("Your password hint is: {}", &hint));
} else {
err!("Sorry, you have no password hint...");
+2 -1
View File
@@ -260,7 +260,8 @@
"Type": 26,
"Domains": [
"steampowered.com",
"steamcommunity.com"
"steamcommunity.com",
"steamgames.com"
],
"Excluded": false
},
+18 -19
View File
@@ -1,4 +1,3 @@
use std::error::Error;
use native_tls::{Protocol, TlsConnector};
use lettre::{Transport, SmtpTransport, SmtpClient, ClientTlsParameters, ClientSecurity};
use lettre::smtp::ConnectionReuseParameters;
@@ -9,25 +8,24 @@ use MailConfig;
fn mailer(config: &MailConfig) -> SmtpTransport {
let client_security = if config.smtp_ssl {
let mut tls_builder = TlsConnector::builder();
tls_builder.min_protocol_version(Some(Protocol::Tlsv11));
ClientSecurity::Required(
ClientTlsParameters::new(config.smtp_host.to_owned(), tls_builder.build().unwrap())
)
let tls = TlsConnector::builder()
.min_protocol_version(Some(Protocol::Tlsv11))
.build()
.unwrap();
ClientSecurity::Required(ClientTlsParameters::new(config.smtp_host.clone(), tls))
} else {
ClientSecurity::None
};
let smtp_client = SmtpClient::new(
(config.smtp_host.to_owned().as_str(), config.smtp_port),
client_security
(config.smtp_host.as_str(), config.smtp_port),
client_security,
).unwrap();
let smtp_client = match (&config.smtp_username, &config.smtp_password) {
(Some(username), Some(password)) => {
smtp_client.credentials(Credentials::new(username.to_owned(), password.to_owned()))
},
(_, _) => smtp_client,
(Some(user), Some(pass)) => smtp_client.credentials(Credentials::new(user.clone(), pass.clone())),
_ => smtp_client,
};
smtp_client
@@ -46,18 +44,19 @@ pub fn send_password_hint(address: &str, hint: Option<String>, config: &MailConf
hint))
} else {
("Sorry, you have no password hint...",
"Sorry, you have not specified any password hint...\n".to_string())
"Sorry, you have not specified any password hint...\n".into())
};
let email = EmailBuilder::new()
.to(address)
.from((config.smtp_from.to_owned(), "Bitwarden-rs"))
.from((config.smtp_from.clone(), "Bitwarden-rs"))
.subject(subject)
.body(body)
.build().unwrap();
.build()
.map_err(|e| e.to_string())?;
match mailer(config).send(email.into()) {
Ok(_) => Ok(()),
Err(e) => Err(e.description().to_string()),
}
mailer(config)
.send(email.into())
.map_err(|e| e.to_string())
.and(Ok(()))
}
-1
View File
@@ -34,7 +34,6 @@ extern crate num_traits;
extern crate lettre;
extern crate lettre_email;
extern crate native_tls;
extern crate fast_chemail;
extern crate byteorder;
use std::{path::Path, process::{exit, Command}};