Add Cargo workspace + common crate with Mode and Method types
This commit is contained in:
2
.cargo/config.toml
Normal file
2
.cargo/config.toml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
[build]
|
||||||
|
rustflags = ["-D", "warnings"]
|
||||||
28
Cargo.toml
Normal file
28
Cargo.toml
Normal file
@@ -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 <ops@dangerousthings.com>"]
|
||||||
|
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"] }
|
||||||
13
common/Cargo.toml
Normal file
13
common/Cargo.toml
Normal file
@@ -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 }
|
||||||
2
common/src/lib.rs
Normal file
2
common/src/lib.rs
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
pub mod policy;
|
||||||
|
pub mod types;
|
||||||
1
common/src/policy.rs
Normal file
1
common/src/policy.rs
Normal file
@@ -0,0 +1 @@
|
|||||||
|
// Policy parsing implemented in Phase 2.
|
||||||
35
common/src/types.rs
Normal file
35
common/src/types.rs
Normal file
@@ -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\"");
|
||||||
|
}
|
||||||
|
}
|
||||||
4
rust-toolchain.toml
Normal file
4
rust-toolchain.toml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
[toolchain]
|
||||||
|
channel = "stable"
|
||||||
|
components = ["rustfmt", "clippy"]
|
||||||
|
profile = "minimal"
|
||||||
Reference in New Issue
Block a user