Skip to content

convert repository into a multi-crate workspace #1054

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 6 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 35 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

71 changes: 36 additions & 35 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,35 +1,44 @@
[package]
name = "defguard"
version = "1.2.4"
[workspace]
members = ["crates/*"]
resolver = "2"

[workspace.package]
edition = "2021"
license-file = "LICENSE.md"
homepage = "https://defguard.net/"
repository = "https://github.com/DefGuard/defguard"
rust-version = "1.82"

[workspace]
[workspace.dependencies]
# internal crates
defguard_core = { path = "./crates/defguard_core", version = "0.0.0" }
defguard_protos = { path = "./crates/defguard_protos", version = "0.0.0" }
defguard_web_ui = { path = "./crates/defguard_web_ui", version = "0.0.0" }
model_derive = { path = "./crates/model_derive", version = "0.0.0" }

[dependencies]
# external dependencies
anyhow = "1.0"
argon2 = { version = "0.5", features = ["std"] }
axum = "0.8"
axum-client-ip = "0.7"
axum-extra = { version = "0.10", features = ["cookie-private", "typed-header"] }
base32 = "0.5"
base64 = "0.22"
chrono = { version = "0.4", default-features = false, features = ["clock", "serde"] }
chrono = { version = "0.4", default-features = false, features = [
"clock",
"serde",
] }
clap = { version = "4.5", features = ["derive", "env"] }
dotenvy = "0.15"
humantime = "2.1"
ipnetwork = "0.20"
jsonwebkey = { version = "0.3.5", features = ["pkcs-convert"] }
jsonwebtoken = "9.3"
ldap3 = { version = "0.11", default-features = false, features = ["tls"] }
lettre = { version = "0.11", features = ["tokio1-native-tls"] }
md4 = "0.10"
mime_guess = "2.0"
model_derive = { path = "model-derive" }
openidconnect = { version = "3.5", default-features = false, optional = true, features = ["reqwest"] }
openidconnect = { version = "3.5", default-features = false, features = [
"reqwest",
] }
parse_link_header = "0.4"
paste = "1.0.15"
pgp = "0.14"
Expand All @@ -40,7 +49,6 @@ rand_core = { version = "0.6", features = ["getrandom"] }
# TODO: update reqwest when openidconnect also depends on http >= 1.0.
reqwest = { version = "0.11", features = ["json"] }
rsa = "0.9"
rust-embed = { version = "8.5", features = ["include-exclude"] }
rust-ini = "0.21"
secrecy = { version = "0.10", features = ["serde"] }
semver = "1.0"
Expand All @@ -52,53 +60,46 @@ serde_urlencoded = "0.7"
serial_test = "3.2.0"
sha-1 = "0.10"
sha256 = "1.5"
sqlx = { version = "0.8", features = ["chrono", "ipnetwork", "postgres", "runtime-tokio-native-tls", "uuid"] }
sqlx = { version = "0.8", features = [
"chrono",
"ipnetwork",
"postgres",
"runtime-tokio-native-tls",
"uuid",
] }
ssh-key = "0.6"
struct-patch = "0.8"
tera = "1.20"
thiserror = "2.0"
# match axum-extra -> cookies
time = { version = "0.3", default-features = false }
tokio = { version = "1", features = ["macros", "parking_lot", "rt-multi-thread", "sync", "time"] }
tokio = { version = "1", features = [
"macros",
"parking_lot",
"rt-multi-thread",
"sync",
"time",
] }
tokio-stream = "0.1"
tokio-util = "0.7"
tonic = { version = "0.12", features = ["gzip", "tls-native-roots"] }
tonic-health = "0.12"
totp-lite = { version = "2.0" }
tower-http = { version = "0.6", features = ["fs", "trace"] }
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
trait-variant = "0.1"
uaparser = "0.6"
# openapi
utoipa = { version = "5", features = ["axum_extras", "chrono", "uuid"] }
utoipa-swagger-ui = { version = "9", features = ["axum", "vendored"] }
uuid = { version = "1.9", features = ["v4"] }
webauthn-authenticator-rs = { version = "0.5" }
webauthn-rs = { version = "0.5", features = ["danger-allow-state-serialisation"] }
webauthn-rs = { version = "0.5", features = [
"danger-allow-state-serialisation",
] }
webauthn-rs-proto = "0.5"
x25519-dalek = { version = "2.0", features = ["static_secrets"] }

[dev-dependencies]
bytes = "1.6"
claims = "0.8"
matches = "0.1"
regex = "1.10"
reqwest = { version = "0.11", features = ["cookies", "json", "multipart", "rustls-tls", "stream"], default-features = false }
serde_qs = "0.13"
webauthn-authenticator-rs = { version = "0.5", features = ["softpasskey"] }

[build-dependencies]
prost-build = "0.13"
tonic-build = "0.12"
vergen-git2 = { version = "1.0", features = ["build"] }

[features]
default = ["openid", "wireguard", "worker"]
openid = ["dep:openidconnect"]
worker = []
wireguard = []

[profile.release]
codegen-units = 1
panic = "abort"
Expand Down
20 changes: 20 additions & 0 deletions crates/defguard/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[package]
name = "defguard"
version = "1.2.4"
edition.workspace = true
license-file.workspace = true
homepage.workspace = true
repository.workspace = true
rust-version.workspace = true

[dependencies]
# internal crates
defguard_core = { workspace = true }

# external dependencies
anyhow = { workspace = true }
dotenvy = "0.15"
secrecy = { workspace = true }
tokio = { workspace = true }
tracing = { workspace = true }
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
10 changes: 5 additions & 5 deletions src/bin/defguard.rs → crates/defguard/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::{
sync::{Arc, Mutex},
};

use defguard::{
use defguard_core::{
auth::failed_login::FailedLoginMap,
config::{Command, DefGuardConfig},
db::{
Expand All @@ -25,11 +25,9 @@ use defguard::{
};
use secrecy::ExposeSecret;
use tokio::sync::{broadcast, mpsc::unbounded_channel};
use tracing::{debug, error, info, warn};
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};

#[macro_use]
extern crate tracing;

#[tokio::main]
async fn main() -> Result<(), anyhow::Error> {
if dotenvy::from_filename(".env.local").is_err() {
Expand Down Expand Up @@ -116,7 +114,9 @@ async fn main() -> Result<(), anyhow::Error> {
set_cached_license(license);
}
Err(err) => {
warn!("There was an error while loading the license, error: {err}. The enterprise features will be disabled.");
warn!(
"There was an error while loading the license, error: {err}. The enterprise features will be disabled."
);
set_cached_license(None);
}
};
Expand Down
Loading