Move backend checks to build.rs to fail fast, and updated dependencies

This commit is contained in:
Daniel García 2019-07-09 17:26:34 +02:00
parent cef38bf40b
commit 05a1137828
No known key found for this signature in database
GPG Key ID: FC8A7D14C3CD543A
9 changed files with 359 additions and 266 deletions

584
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -40,9 +40,9 @@ rmpv = "0.4.0"
chashmap = "2.2.2" chashmap = "2.2.2"
# A generic serialization/deserialization framework # A generic serialization/deserialization framework
serde = "1.0.92" serde = "1.0.94"
serde_derive = "1.0.92" serde_derive = "1.0.94"
serde_json = "1.0.39" serde_json = "1.0.40"
# Logging # Logging
log = "0.4.6" log = "0.4.6"
@ -62,7 +62,7 @@ ring = "0.14.6"
uuid = { version = "0.7.4", features = ["v4"] } uuid = { version = "0.7.4", features = ["v4"] }
# Date and time library for Rust # Date and time library for Rust
chrono = "0.4.6" chrono = "0.4.7"
# TOTP library # TOTP library
oath = "0.10.2" oath = "0.10.2"
@ -77,7 +77,7 @@ jsonwebtoken = "6.0.1"
u2f = "0.1.6" u2f = "0.1.6"
# Yubico Library # Yubico Library
yubico = { version = "0.5.1", features = ["online"], default-features = false } yubico = { version = "0.6.1", features = ["online", "online-tokio"], default-features = false }
# A `dotenv` implementation for Rust # A `dotenv` implementation for Rust
dotenv = { version = "0.14.1", default-features = false } dotenv = { version = "0.14.1", default-features = false }
@ -99,11 +99,11 @@ native-tls = "0.2.3"
quoted_printable = "0.4.1" quoted_printable = "0.4.1"
# Template library # Template library
handlebars = "1.1.0" handlebars = "2.0.0"
# For favicon extraction from main website # For favicon extraction from main website
soup = "0.4.1" soup = "0.4.1"
regex = "1.1.7" regex = "1.1.9"
# URL encoding library # URL encoding library
percent-encoding = "1.0.1" percent-encoding = "1.0.1"

View File

@ -1,6 +1,12 @@
use std::process::Command; use std::process::Command;
fn main() { fn main() {
#[cfg(all(feature = "sqlite", feature = "mysql"))]
compile_error!("Can't enable both backends");
#[cfg(not(any(feature = "sqlite", feature = "mysql")))]
compile_error!("You need to enable one DB backend. To build with previous defaults do: cargo build --features sqlite");
read_git_info().ok(); read_git_info().ok();
} }

View File

@ -22,7 +22,7 @@ RUN ls
########################## BUILD IMAGE ########################## ########################## BUILD IMAGE ##########################
# Musl build image for statically compiled binary # Musl build image for statically compiled binary
FROM clux/muslrust:nightly-2018-12-01 as build FROM clux/muslrust:nightly-2019-07-08 as build
# set mysql backend # set mysql backend
ARG DB=mysql ARG DB=mysql

View File

@ -22,7 +22,7 @@ RUN ls
########################## BUILD IMAGE ########################## ########################## BUILD IMAGE ##########################
# Musl build image for statically compiled binary # Musl build image for statically compiled binary
FROM clux/muslrust:nightly-2018-12-01 as build FROM clux/muslrust:nightly-2019-07-08 as build
# set sqlite as default for DB ARG for backward comaptibility # set sqlite as default for DB ARG for backward comaptibility
ARG DB=sqlite ARG DB=sqlite

View File

@ -1 +1 @@
nightly-2019-06-14 nightly-2019-07-09

View File

@ -563,7 +563,7 @@ pub struct YubikeyMetadata {
} }
use yubico::config::Config; use yubico::config::Config;
use yubico::Yubico; use yubico::verify;
fn parse_yubikeys(data: &EnableYubikeyData) -> Vec<String> { fn parse_yubikeys(data: &EnableYubikeyData) -> Vec<String> {
let data_keys = [&data.Key1, &data.Key2, &data.Key3, &data.Key4, &data.Key5]; let data_keys = [&data.Key1, &data.Key2, &data.Key3, &data.Key4, &data.Key5];
@ -591,12 +591,11 @@ fn get_yubico_credentials() -> Result<(String, String), Error> {
fn verify_yubikey_otp(otp: String) -> EmptyResult { fn verify_yubikey_otp(otp: String) -> EmptyResult {
let (yubico_id, yubico_secret) = get_yubico_credentials()?; let (yubico_id, yubico_secret) = get_yubico_credentials()?;
let yubico = Yubico::new();
let config = Config::default().set_client_id(yubico_id).set_key(yubico_secret); let config = Config::default().set_client_id(yubico_id).set_key(yubico_secret);
match CONFIG.yubico_server() { match CONFIG.yubico_server() {
Some(server) => yubico.verify(otp, config.set_api_hosts(vec![server])), Some(server) => verify(otp, config.set_api_hosts(vec![server])),
None => yubico.verify(otp, config), None => verify(otp, config),
} }
.map_res("Failed to verify OTP") .map_res("Failed to verify OTP")
.and(Ok(())) .and(Ok(()))

View File

@ -48,7 +48,7 @@ pub fn get_connection() -> Result<Connection, ConnectionError> {
/// Creates a back-up of the database using sqlite3 /// Creates a back-up of the database using sqlite3
pub fn backup_database() -> Result<(), Error> { pub fn backup_database() -> Result<(), Error> {
let now: DateTime<Utc> = Utc::now(); let now: DateTime<Utc> = Utc::now();
let file_date = String::from(now.format("%Y%m%d").to_string()); let file_date = now.format("%Y%m%d").to_string();
let backup_command: String = format!("{}{}{}", ".backup 'db_", file_date, ".sqlite3'"); let backup_command: String = format!("{}{}{}", ".backup 'db_", file_date, ".sqlite3'");
Command::new("sqlite3") Command::new("sqlite3")

View File

@ -45,12 +45,6 @@ fn main() {
init_logging().ok(); init_logging().ok();
} }
#[cfg(all(feature = "sqlite", feature = "mysql"))]
compile_error!("Can't enable both backends");
#[cfg(not(any(feature = "sqlite", feature = "mysql")))]
compile_error!("You need to enable one DB backend. To build with previous defaults do: cargo build --features sqlite");
check_db(); check_db();
check_rsa_keys(); check_rsa_keys();
check_web_vault(); check_web_vault();