diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000..0eb087e --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,2 @@ +[build] +rustflags = ["-D", "warnings"] diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..f6f7b40 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,28 @@ +[workspace] +resolver = "2" +members = ["common", "daemon", "cli", "gui"] +# GUI excluded from default builds because it requires libgtk-4-dev + libadwaita-1-dev +# at link time. Build it explicitly with `cargo build -p ubuntu-fido-gui`. +default-members = ["common", "daemon", "cli"] + +[workspace.package] +version = "0.1.0" +edition = "2021" +license = "Apache-2.0" +authors = ["Dangerous Things "] +repository = "https://github.com/dangerousthings/ubuntu-fido" +rust-version = "1.78" + +[workspace.dependencies] +zbus = "4" +serde = { version = "1", features = ["derive"] } +serde_json = "1" +toml = "0.8" +anyhow = "1" +thiserror = "1" +tracing = "0.1" +tracing-subscriber = { version = "0.3", features = ["env-filter"] } +tokio = { version = "1", features = ["full"] } +clap = { version = "4", features = ["derive"] } +ctap-hid-fido2 = "3" +nix = { version = "0.28", features = ["user", "process", "fs"] } diff --git a/common/Cargo.toml b/common/Cargo.toml new file mode 100644 index 0000000..9b448a6 --- /dev/null +++ b/common/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "ubuntu-fido-common" +version.workspace = true +edition.workspace = true +license.workspace = true + +[dependencies] +serde = { workspace = true } +toml = { workspace = true } +thiserror = { workspace = true } + +[dev-dependencies] +serde_json = { workspace = true } diff --git a/common/src/lib.rs b/common/src/lib.rs new file mode 100644 index 0000000..505cbef --- /dev/null +++ b/common/src/lib.rs @@ -0,0 +1,2 @@ +pub mod policy; +pub mod types; diff --git a/common/src/policy.rs b/common/src/policy.rs new file mode 100644 index 0000000..8768f20 --- /dev/null +++ b/common/src/policy.rs @@ -0,0 +1 @@ +// Policy parsing implemented in Phase 2. diff --git a/common/src/types.rs b/common/src/types.rs new file mode 100644 index 0000000..ad091d2 --- /dev/null +++ b/common/src/types.rs @@ -0,0 +1,35 @@ +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] +#[serde(rename_all = "lowercase")] +pub enum Mode { + Disabled, + Optional, + Required, +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)] +#[serde(rename_all = "lowercase")] +pub enum Method { + Fido2, + Totp, +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn mode_serializes_to_lowercase() { + let m = Mode::Required; + let s = serde_json::to_string(&m).unwrap(); + assert_eq!(s, "\"required\""); + } + + #[test] + fn method_serializes_to_lowercase() { + let m = Method::Fido2; + let s = serde_json::to_string(&m).unwrap(); + assert_eq!(s, "\"fido2\""); + } +} diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..85f3606 --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,4 @@ +[toolchain] +channel = "stable" +components = ["rustfmt", "clippy"] +profile = "minimal"