diff --git a/Cargo.lock b/Cargo.lock index cda6904..c76dd3f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -707,7 +707,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" dependencies = [ "libc", - "windows-sys 0.61.2", + "windows-sys 0.59.0", ] [[package]] @@ -740,7 +740,7 @@ checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" [[package]] name = "fc-common" -version = "0.1.0" +version = "0.2.0-dev" dependencies = [ "anyhow", "argon2", @@ -758,17 +758,18 @@ dependencies = [ "sha2", "sqlx", "tempfile", - "thiserror", + "thiserror 2.0.18", "tokio", "toml", "tracing", "tracing-subscriber", + "urlencoding", "uuid", ] [[package]] name = "fc-evaluator" -version = "0.1.0" +version = "0.2.0-dev" dependencies = [ "anyhow", "chrono", @@ -783,7 +784,7 @@ dependencies = [ "sha2", "sqlx", "tempfile", - "thiserror", + "thiserror 2.0.18", "tokio", "toml", "tracing", @@ -793,7 +794,7 @@ dependencies = [ [[package]] name = "fc-migrate-cli" -version = "0.1.0" +version = "0.2.0-dev" dependencies = [ "anyhow", "clap", @@ -804,7 +805,7 @@ dependencies = [ [[package]] name = "fc-queue-runner" -version = "0.1.0" +version = "0.2.0-dev" dependencies = [ "anyhow", "chrono", @@ -815,7 +816,7 @@ dependencies = [ "serde_json", "sqlx", "tempfile", - "thiserror", + "thiserror 2.0.18", "tokio", "tokio-util", "tracing", @@ -825,7 +826,7 @@ dependencies = [ [[package]] name = "fc-server" -version = "0.1.0" +version = "0.2.0-dev" dependencies = [ "anyhow", "askama", @@ -840,11 +841,14 @@ dependencies = [ "futures", "hex", "hmac", + "oauth2", + "reqwest", "serde", "serde_json", "sha2", "sqlx", - "thiserror", + "subtle", + "thiserror 2.0.18", "tokio", "tokio-util", "tower", @@ -1661,7 +1665,7 @@ version = "0.50.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5" dependencies = [ - "windows-sys 0.61.2", + "windows-sys 0.59.0", ] [[package]] @@ -1710,6 +1714,26 @@ dependencies = [ "libm", ] +[[package]] +name = "oauth2" +version = "5.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51e219e79014df21a225b1860a479e2dcd7cbd9130f4defd4bd0e191ea31d67d" +dependencies = [ + "base64", + "chrono", + "getrandom 0.2.17", + "http", + "rand 0.8.5", + "reqwest", + "serde", + "serde_json", + "serde_path_to_error", + "sha2", + "thiserror 1.0.69", + "url", +] + [[package]] name = "object" version = "0.37.3" @@ -1953,7 +1977,7 @@ dependencies = [ "rustc-hash", "rustls", "socket2", - "thiserror", + "thiserror 2.0.18", "tokio", "tracing", "web-time", @@ -1974,7 +1998,7 @@ dependencies = [ "rustls", "rustls-pki-types", "slab", - "thiserror", + "thiserror 2.0.18", "tinyvec", "tracing", "web-time", @@ -1991,7 +2015,7 @@ dependencies = [ "once_cell", "socket2", "tracing", - "windows-sys 0.60.2", + "windows-sys 0.59.0", ] [[package]] @@ -2233,7 +2257,7 @@ dependencies = [ "errno", "libc", "linux-raw-sys", - "windows-sys 0.61.2", + "windows-sys 0.59.0", ] [[package]] @@ -2520,7 +2544,7 @@ dependencies = [ "serde_json", "sha2", "smallvec", - "thiserror", + "thiserror 2.0.18", "tokio", "tokio-stream", "tracing", @@ -2605,7 +2629,7 @@ dependencies = [ "smallvec", "sqlx-core", "stringprep", - "thiserror", + "thiserror 2.0.18", "tracing", "uuid", "whoami", @@ -2644,7 +2668,7 @@ dependencies = [ "smallvec", "sqlx-core", "stringprep", - "thiserror", + "thiserror 2.0.18", "tracing", "uuid", "whoami", @@ -2670,7 +2694,7 @@ dependencies = [ "serde", "serde_urlencoded", "sqlx-core", - "thiserror", + "thiserror 2.0.18", "tracing", "url", "uuid", @@ -2759,7 +2783,16 @@ dependencies = [ "getrandom 0.3.4", "once_cell", "rustix", - "windows-sys 0.61.2", + "windows-sys 0.59.0", +] + +[[package]] +name = "thiserror" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" +dependencies = [ + "thiserror-impl 1.0.69", ] [[package]] @@ -2768,7 +2801,18 @@ version = "2.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4288b5bcbc7920c07a1149a35cf9590a2aa808e0bc1eafaade0b80947865fbc4" dependencies = [ - "thiserror-impl", + "thiserror-impl 2.0.18", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" +dependencies = [ + "proc-macro2", + "quote", + "syn", ] [[package]] @@ -3136,8 +3180,15 @@ dependencies = [ "idna", "percent-encoding", "serde", + "serde_derive", ] +[[package]] +name = "urlencoding" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da" + [[package]] name = "utf8_iter" version = "1.0.4" diff --git a/Cargo.toml b/Cargo.toml index cd2ae6b..9b31e39 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,7 @@ edition = "2024" license = "MPL-2.0" repository = "https://gitub.com/feel-co/fc" rust-version = "1.91.1" -version = "0.1.0" +version = "0.2.0-dev" [workspace.dependencies] # Components @@ -43,13 +43,16 @@ lettre = { version = "0.11.19", default-features = false, features = [ "smtp-transport", "builder", ] } +libc = "0.2.180" nix-nar = "0.3.1" +oauth2 = "5.0.0" regex = "1.12.3" reqwest = { version = "0.12.28", default-features = false, features = [ "json", "rustls-tls" ] } serde = { version = "1.0.228", features = [ "derive" ] } serde_json = "1.0.149" sha2 = "0.10.9" sqlx = { version = "0.8.6", features = [ "runtime-tokio-rustls", "postgres", "chrono", "uuid", "migrate" ] } +subtle = "2.6.1" tempfile = "3.24.0" thiserror = "2.0.18" tokio = { version = "1.49.0", features = [ "full" ] } @@ -59,5 +62,5 @@ tower = "0.5.3" tower-http = { version = "0.6.8", features = [ "cors", "trace", "limit", "fs", "set-header" ] } tracing = "0.1.41" tracing-subscriber = { version = "0.3.20", features = [ "env-filter", "json" ] } +urlencoding = "2.1.3" uuid = { version = "1.18.1", features = [ "v4", "serde" ] } -libc = "0.2.180" diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index d1b6792..04c92b4 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -28,4 +28,5 @@ tokio.workspace = true toml.workspace = true tracing.workspace = true tracing-subscriber.workspace = true +urlencoding.workspace = true uuid.workspace = true diff --git a/crates/common/src/config.rs b/crates/common/src/config.rs index 40f6d31..47c6e35 100644 --- a/crates/common/src/config.rs +++ b/crates/common/src/config.rs @@ -21,6 +21,8 @@ pub struct Config { pub tracing: TracingConfig, #[serde(default)] pub declarative: DeclarativeConfig, + #[serde(default)] + pub oauth: OAuthConfig, } #[derive(Debug, Clone, Serialize, Deserialize)] @@ -82,6 +84,29 @@ pub struct LogConfig { pub compress: bool, } +#[derive(Debug, Clone, Serialize, Deserialize, Default)] +#[serde(default)] +pub struct OAuthConfig { + pub github: Option, +} + +#[derive(Clone, Serialize, Deserialize)] +pub struct GitHubOAuthConfig { + pub client_id: String, + pub client_secret: String, + pub redirect_uri: String, +} + +impl std::fmt::Debug for GitHubOAuthConfig { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("GitHubOAuthConfig") + .field("client_id", &self.client_id) + .field("client_secret", &"[REDACTED]") + .field("redirect_uri", &self.redirect_uri) + .finish() + } +} + #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(default)] #[derive(Default)] @@ -90,6 +115,8 @@ pub struct NotificationsConfig { pub github_token: Option, pub gitea_url: Option, pub gitea_token: Option, + pub gitlab_url: Option, + pub gitlab_token: Option, pub email: Option, }