From 96aaf276be4c5153632b2664bd1fbbab82c48a6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20W=C3=B3jcik?= Date: Thu, 28 Dec 2023 09:28:00 +0100 Subject: [PATCH 1/7] fix typo --- src/grpc/enrollment.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/grpc/enrollment.rs b/src/grpc/enrollment.rs index 5b055e2d5..e3a19781b 100644 --- a/src/grpc/enrollment.rs +++ b/src/grpc/enrollment.rs @@ -376,7 +376,7 @@ impl enrollment_service_server::EnrollmentService for EnrollmentServer { Some(&ip_address), device_info.as_deref(), ) - .map_err(|_| Status::internal("Failed to render new device added tempalte"))?; + .map_err(|_| Status::internal("Failed to render new device added template"))?; let response = DeviceConfigResponse { device: Some(device.into()), configs: configs.into_iter().map(Into::into).collect(), From 3cd398e4139df456f884559e673e1b62eeae14f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20W=C3=B3jcik?= Date: Thu, 28 Dec 2023 10:22:14 +0100 Subject: [PATCH 2/7] include additional instance info in enrollment response --- src/db/models/device.rs | 4 ++++ src/grpc/enrollment.rs | 37 ++++++++++++++++++++++++++----------- 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/src/db/models/device.rs b/src/db/models/device.rs index eb66adc18..4cdcfa170 100644 --- a/src/db/models/device.rs +++ b/src/db/models/device.rs @@ -26,6 +26,8 @@ pub struct DeviceConfig { pub(crate) allowed_ips: Vec, pub(crate) pubkey: String, pub(crate) dns: Option, + pub(crate) mfa_enabled: bool, + pub(crate) keepalive_interval: i32, } #[derive(Clone, Deserialize, Model, Serialize, Debug)] @@ -550,6 +552,8 @@ impl Device { allowed_ips: network.allowed_ips, pubkey: network.pubkey, dns: network.dns, + mfa_enabled: network.mfa_enabled, + keepalive_interval: network.keepalive_interval, }); } } diff --git a/src/grpc/enrollment.rs b/src/grpc/enrollment.rs index e3a19781b..0cf64e6e6 100644 --- a/src/grpc/enrollment.rs +++ b/src/grpc/enrollment.rs @@ -15,6 +15,7 @@ use crate::{ ldap::utils::ldap_add_user, mail::Mail, templates::{self, TemplateLocation}, + SERVER_CONFIG, }; use ipnetwork::IpNetwork; use reqwest::Url; @@ -42,28 +43,35 @@ pub struct EnrollmentServer { ldap_feature_active: bool, } -struct Instance { +struct InstanceInfo { id: uuid::Uuid, name: String, url: Url, + proxy_url: Url, + username: String, } -impl Instance { - pub fn new(settings: Settings, url: Url) -> Self { - Instance { +impl InstanceInfo { + pub fn new>(settings: Settings, username: S) -> Self { + let config = SERVER_CONFIG.get().expect("defguard config not found"); + InstanceInfo { id: settings.uuid, name: settings.instance_name, - url, + url: config.url.clone(), + proxy_url: config.enrollment_url.clone(), + username: username.into(), } } } -impl From for proto::InstanceInfo { - fn from(instance: Instance) -> Self { +impl From for proto::InstanceInfo { + fn from(instance: InstanceInfo) -> Self { Self { name: instance.name, id: instance.id.to_string(), url: instance.url.to_string(), + proxy_url: instance.proxy_url.to_string(), + username: instance.username, } } } @@ -163,6 +171,9 @@ impl enrollment_service_server::EnrollmentService for EnrollmentServer { Status::internal("unexpected error") })?; + let vpn_setup_optional = settings.enrollment_vpn_step_optional; + let instance_info = InstanceInfo::new(settings, &user.username); + let user_info = InitialUserInfo::from_user(&self.pool, user) .await .map_err(|_| { @@ -179,8 +190,8 @@ impl enrollment_service_server::EnrollmentService for EnrollmentServer { final_page_content: enrollment .get_welcome_page_content(&mut transaction) .await?, - vpn_setup_optional: settings.enrollment_vpn_step_optional, - instance: Some(Instance::new(settings, self.config.url.clone()).into()), + vpn_setup_optional, + instance: Some(instance_info.into()), }; transaction.commit().await.map_err(|_| { @@ -380,7 +391,7 @@ impl enrollment_service_server::EnrollmentService for EnrollmentServer { let response = DeviceConfigResponse { device: Some(device.into()), configs: configs.into_iter().map(Into::into).collect(), - instance: Some(Instance::new(settings, self.config.url.clone()).into()), + instance: Some(InstanceInfo::new(settings, self.config.url.clone()).into()), }; Ok(Response::new(response)) @@ -446,6 +457,8 @@ impl enrollment_service_server::EnrollmentService for EnrollmentServer { pubkey: network.pubkey, allowed_ips, dns: network.dns, + mfa_enabled: network.mfa_enabled, + keepalive_interval: network.keepalive_interval, }; configs.push(config); } @@ -454,7 +467,7 @@ impl enrollment_service_server::EnrollmentService for EnrollmentServer { let response = DeviceConfigResponse { device: Some(device.into()), configs, - instance: Some(Instance::new(settings, self.config.url.clone()).into()), + instance: Some(InstanceInfo::new(settings, self.config.url.clone()).into()), }; Ok(Response::new(response)) @@ -508,6 +521,8 @@ impl From for ProtoDeviceConfig { pubkey: config.pubkey, allowed_ips, dns: config.dns, + mfa_enabled: config.mfa_enabled, + keepalive_interval: config.keepalive_interval, } } } From 54585cdc43f29a5bca27c63ca60f2441f8f46d2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20W=C3=B3jcik?= Date: Tue, 2 Jan 2024 08:06:15 +0100 Subject: [PATCH 3/7] update dependencies --- Cargo.lock | 168 +++++++++++++++++++++++++++-------------------------- 1 file changed, 85 insertions(+), 83 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fbcd2fe2f..4506cb661 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -54,9 +54,9 @@ dependencies = [ [[package]] name = "ahash" -version = "0.8.6" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91429305e9f0a25f6205c5b8e0d2db09e0708a7a6df0f42212bb56c32c8ac97a" +checksum = "77c3a9648d43b9cd48db467b3f87fdd6e146bcc88ab0180006cef2179fe11d01" dependencies = [ "cfg-if", "getrandom", @@ -145,9 +145,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.77" +version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9d19de80eff169429ac1e9f48fffb163916b448a44e8e046186232046d9e1f9" +checksum = "080e9890a082662b09c1ad45f567faeeb47f22b5fb23895fbe1e651e718e25ca" [[package]] name = "argon2" @@ -225,18 +225,18 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.46", ] [[package]] name = "async-trait" -version = "0.1.75" +version = "0.1.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdf6721fb0140e4f897002dd086c06f6c27775df19cfe1fccb21181a48fd2c98" +checksum = "c980ee35e870bd1a4d2c8294d4c04d0499e67bca1e4b5cefcc693c2fa00caea9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.46", ] [[package]] @@ -306,12 +306,12 @@ dependencies = [ [[package]] name = "axum" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "202651474fe73c62d9e0a56c6133f7a0ff1dc1c8cf7a5b03381af2a26553ac9d" +checksum = "d09dbe0e490df5da9d69b36dca48a76635288a82f92eca90024883a56202026d" dependencies = [ "async-trait", - "axum-core 0.4.1", + "axum-core 0.4.2", "bytes", "futures-util", "http 1.0.0", @@ -335,6 +335,7 @@ dependencies = [ "tower", "tower-layer", "tower-service", + "tracing", ] [[package]] @@ -343,7 +344,7 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0f5ffe4637708b326c621d5494ab6c91dcf62ee440fa6ee967d289315a9c6f81" dependencies = [ - "axum 0.7.2", + "axum 0.7.3", "forwarded-header-value", "serde", ] @@ -367,9 +368,9 @@ dependencies = [ [[package]] name = "axum-core" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77cb22c689c44d4c07b0ab44ebc25d69d8ae601a2f28fb8d672d344178fa17aa" +checksum = "e87c8503f93e6d144ee5690907ba22db7ba79ab001a932ab99034f0fe836b3df" dependencies = [ "async-trait", "bytes", @@ -383,16 +384,17 @@ dependencies = [ "sync_wrapper", "tower-layer", "tower-service", + "tracing", ] [[package]] name = "axum-extra" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "523ae92256049a3b02d3bb4df80152386cd97ddba0c8c5077619bdc8c4b1859b" +checksum = "881348a37b079994894b6e5e46edcc4b8a60e1c0333669a65b810abeed780598" dependencies = [ - "axum 0.7.2", - "axum-core 0.4.1", + "axum 0.7.3", + "axum-core 0.4.2", "bytes", "cookie 0.18.0", "futures-util", @@ -520,9 +522,9 @@ dependencies = [ [[package]] name = "bstr" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "542f33a8835a0884b006a0c3df3dadd99c0c3f296ed26c2fdc8028e01ad6230c" +checksum = "c48f0051a4b4c5e0b6d365cd04af53aeaa209e3cc15ec2cdb69e73cc87fbd0dc" dependencies = [ "memchr", "serde", @@ -587,9 +589,9 @@ dependencies = [ [[package]] name = "chrono-tz" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e23185c0e21df6ed832a12e2bda87c7d1def6842881fb634a8511ced741b0d76" +checksum = "91d7b79e99bfaa0d47da0687c43aa3b7381938a62ad3a6498599039321f660b7" dependencies = [ "chrono", "chrono-tz-build", @@ -638,9 +640,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.11" +version = "4.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfaff671f6b22ca62406885ece523383b9b64022e341e53e009a62ebc47a45f2" +checksum = "dcfab8ba68f3668e89f6ff60f5b205cea56aa7b769451a59f34b8682f51c056d" dependencies = [ "clap_builder", "clap_derive", @@ -648,9 +650,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.11" +version = "4.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a216b506622bb1d316cd51328dce24e07bdff4a6128a47c7e7fad11878d5adbb" +checksum = "fb7fb5e4e979aec3be7791562fcba452f94ad85e954da024396433e0e25a79e9" dependencies = [ "anstream", "anstyle", @@ -667,7 +669,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.46", ] [[package]] @@ -940,7 +942,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.46", ] [[package]] @@ -964,7 +966,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.43", + "syn 2.0.46", ] [[package]] @@ -975,7 +977,7 @@ checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" dependencies = [ "darling_core", "quote", - "syn 2.0.43", + "syn 2.0.46", ] [[package]] @@ -990,7 +992,7 @@ version = "0.8.0" dependencies = [ "anyhow", "argon2", - "axum 0.7.2", + "axum 0.7.3", "axum-client-ip", "axum-extra", "base64 0.21.5", @@ -1076,9 +1078,9 @@ dependencies = [ [[package]] name = "deranged" -version = "0.3.10" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8eb30d70a07a3b04884d2677f06bec33509dc67ca60d92949e5535352d3191dc" +checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" dependencies = [ "powerfmt", "serde", @@ -1123,7 +1125,7 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.46", ] [[package]] @@ -1528,7 +1530,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.46", ] [[package]] @@ -1988,9 +1990,9 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.58" +version = "0.1.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8326b86b6cff230b97d0d312a6c40a60726df3332e721f72a1b035f451663b20" +checksum = "b6a67363e2aa4443928ce15e57ebae94fd8949958fd1223c4cfc0cd473ad7539" dependencies = [ "android_system_properties", "core-foundation-sys", @@ -2395,9 +2397,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.6.4" +version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" +checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" [[package]] name = "mime" @@ -2446,7 +2448,7 @@ name = "model_derive" version = "0.1.2" dependencies = [ "quote", - "syn 2.0.43", + "syn 2.0.46", ] [[package]] @@ -2597,7 +2599,7 @@ dependencies = [ "proc-macro-crate 2.0.1", "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.46", ] [[package]] @@ -2729,7 +2731,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.46", ] [[package]] @@ -2941,7 +2943,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.46", ] [[package]] @@ -3020,7 +3022,7 @@ checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" dependencies = [ "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.46", ] [[package]] @@ -3064,9 +3066,9 @@ checksum = "69d3587f8a9e599cc7ec2c00e331f71c4e69a5f9a4b8a6efd5b07466b9736f9a" [[package]] name = "platforms" -version = "3.2.0" +version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14e6ab3f592e6fb464fc9712d8d6e6912de6473954635fd76a589d832cffcbb0" +checksum = "626dec3cac7cc0e1577a2ec3fc496277ec2baa084bebad95bb6fdbfae235f84c" [[package]] name = "polyval" @@ -3094,12 +3096,12 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "prettyplease" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae005bd773ab59b4725093fd7df83fd7892f7d8eafb48dbd7de6e024e4215f9d" +checksum = "a41cf62165e97c7f814d2221421dbb9afcbcdb0a88068e5ea206e19951c2cbb5" dependencies = [ "proc-macro2", - "syn 2.0.43", + "syn 2.0.46", ] [[package]] @@ -3171,9 +3173,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.71" +version = "1.0.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75cb1540fadbd5b8fbccc4dddad2734eba435053f725621c070711a14bb5f4b8" +checksum = "2de98502f212cfcea8d0bb305bd0f49d7ebdd75b64ba0a68f937d888f4e0d6db" dependencies = [ "unicode-ident", ] @@ -3221,7 +3223,7 @@ dependencies = [ "prost", "prost-types", "regex", - "syn 2.0.43", + "syn 2.0.46", "tempfile", "which", ] @@ -3236,7 +3238,7 @@ dependencies = [ "itertools 0.11.0", "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.46", ] [[package]] @@ -3287,9 +3289,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.33" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" dependencies = [ "proc-macro2", ] @@ -3812,14 +3814,14 @@ checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.46", ] [[package]] name = "serde_json" -version = "1.0.108" +version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" +checksum = "cb0652c533506ad7a2e353cce269330d6afd8bdfb6d75e0ace5b35aacbd7b9e9" dependencies = [ "itoa", "ryu", @@ -3894,7 +3896,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.46", ] [[package]] @@ -4321,7 +4323,7 @@ checksum = "f14a349c27ebe59faba22f933c9c734d428da7231e88a247e9d8c61eea964ddb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.46", ] [[package]] @@ -4343,7 +4345,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.43", + "syn 2.0.46", ] [[package]] @@ -4365,9 +4367,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.43" +version = "2.0.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee659fb5f3d355364e1f3e5bc10fb82068efbf824a1e9d1c9504244a6469ad53" +checksum = "89456b690ff72fddcecf231caedbe615c59480c93358a93dfae7fc29e3ebbf0e" dependencies = [ "proc-macro2", "quote", @@ -4421,15 +4423,15 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "tempfile" -version = "3.8.1" +version = "3.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ef1adac450ad7f4b3c28589471ade84f25f731a7a0fe30d71dfa9f60fd808e5" +checksum = "01ce4141aa927a6d1bd34a041795abd0db1cccba5d5f24b009f694bdf3a1f3fa" dependencies = [ "cfg-if", "fastrand", "redox_syscall", "rustix", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -4456,22 +4458,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.52" +version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83a48fd946b02c0a526b2e9481c8e2a17755e47039164a86c4070446e3a4614d" +checksum = "d54378c645627613241d077a3a79db965db602882668f9136ac42af9ecb730ad" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.52" +version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7fbe9b594d6568a6a1443250a7e67d80b74e1e96f6d1715e1e21cc1888291d3" +checksum = "fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471" dependencies = [ "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.46", ] [[package]] @@ -4573,7 +4575,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.46", ] [[package]] @@ -4691,7 +4693,7 @@ dependencies = [ "proc-macro2", "prost-build", "quote", - "syn 2.0.43", + "syn 2.0.46", ] [[package]] @@ -4771,7 +4773,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.46", ] [[package]] @@ -5087,7 +5089,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.46", "wasm-bindgen-shared", ] @@ -5121,7 +5123,7 @@ checksum = "f0eb82fcb7930ae6219a7ecfd55b217f5f0893484b7a13022ebb2b2bf20b5283" dependencies = [ "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.46", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -5281,11 +5283,11 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "windows-core" -version = "0.51.1" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1f8cf84f35d2db49a46868f947758c7a1138116f7fac3bc844f43ade1292e64" +checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows-targets 0.48.5", + "windows-targets 0.52.0", ] [[package]] @@ -5422,9 +5424,9 @@ checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" [[package]] name = "winnow" -version = "0.5.30" +version = "0.5.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b5c3db89721d50d0e2a673f5043fc4722f76dcc352d7b1ab8b8288bed4ed2c5" +checksum = "97a4882e6b134d6c28953a387571f1acdd3496830d5e36c5e3a1075580ea641c" dependencies = [ "memchr", ] @@ -5504,7 +5506,7 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.46", ] [[package]] @@ -5524,5 +5526,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.46", ] From a6ef31f7dd7dde9cc5c6a0ba4ac1969610c14499 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20W=C3=B3jcik?= Date: Tue, 2 Jan 2024 09:50:30 +0100 Subject: [PATCH 4/7] fix username --- src/grpc/enrollment.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/grpc/enrollment.rs b/src/grpc/enrollment.rs index 0cf64e6e6..075c6e2f9 100644 --- a/src/grpc/enrollment.rs +++ b/src/grpc/enrollment.rs @@ -391,7 +391,7 @@ impl enrollment_service_server::EnrollmentService for EnrollmentServer { let response = DeviceConfigResponse { device: Some(device.into()), configs: configs.into_iter().map(Into::into).collect(), - instance: Some(InstanceInfo::new(settings, self.config.url.clone()).into()), + instance: Some(InstanceInfo::new(settings, &user.username).into()), }; Ok(Response::new(response)) @@ -403,7 +403,10 @@ impl enrollment_service_server::EnrollmentService for EnrollmentServer { &self, request: Request, ) -> Result, Status> { - let _enrollment = self.validate_session(&request).await?; + let enrollment = self.validate_session(&request).await?; + + // get enrollment user + let user = enrollment.fetch_user(&self.pool).await?; let request = request.into_inner(); Device::validate_pubkey(&request.pubkey).map_err(|_| { @@ -467,7 +470,7 @@ impl enrollment_service_server::EnrollmentService for EnrollmentServer { let response = DeviceConfigResponse { device: Some(device.into()), configs, - instance: Some(InstanceInfo::new(settings, self.config.url.clone()).into()), + instance: Some(InstanceInfo::new(settings, &user.username).into()), }; Ok(Response::new(response)) From 7d7e524c62ab69d1fc79fd120ad806356c2fac40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20W=C3=B3jcik?= Date: Tue, 2 Jan 2024 10:38:39 +0100 Subject: [PATCH 5/7] update protos --- proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proto b/proto index 44b0593cd..9f5c90266 160000 --- a/proto +++ b/proto @@ -1 +1 @@ -Subproject commit 44b0593cdd8a0b7cf44386cf6097add59ef79781 +Subproject commit 9f5c90266c9d3449c38197b72e8a9d8a56f12cfd From 404f36df2237719395f59fd19cc8f41b55c9fab4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20W=C3=B3jcik?= Date: Tue, 2 Jan 2024 11:19:50 +0100 Subject: [PATCH 6/7] update query data --- ...72929d6a612846acf4a5489c36a04cb57de59.json | 22 ------------------- ...ab52c14293fa64d260db812c89ed43a5a7cc8.json | 15 ------------- 2 files changed, 37 deletions(-) delete mode 100644 .sqlx/query-0ad599ef120ecc02b030bd1276172929d6a612846acf4a5489c36a04cb57de59.json delete mode 100644 .sqlx/query-1bb3c8ecbd6500717d639678e08ab52c14293fa64d260db812c89ed43a5a7cc8.json diff --git a/.sqlx/query-0ad599ef120ecc02b030bd1276172929d6a612846acf4a5489c36a04cb57de59.json b/.sqlx/query-0ad599ef120ecc02b030bd1276172929d6a612846acf4a5489c36a04cb57de59.json deleted file mode 100644 index ce67e4293..000000000 --- a/.sqlx/query-0ad599ef120ecc02b030bd1276172929d6a612846acf4a5489c36a04cb57de59.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "SELECT recovery_codes FROM \"user\" WHERE id = $1", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "recovery_codes", - "type_info": "TextArray" - } - ], - "parameters": { - "Left": [ - "Int8" - ] - }, - "nullable": [ - false - ] - }, - "hash": "0ad599ef120ecc02b030bd1276172929d6a612846acf4a5489c36a04cb57de59" -} diff --git a/.sqlx/query-1bb3c8ecbd6500717d639678e08ab52c14293fa64d260db812c89ed43a5a7cc8.json b/.sqlx/query-1bb3c8ecbd6500717d639678e08ab52c14293fa64d260db812c89ed43a5a7cc8.json deleted file mode 100644 index 8d314a5fa..000000000 --- a/.sqlx/query-1bb3c8ecbd6500717d639678e08ab52c14293fa64d260db812c89ed43a5a7cc8.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "UPDATE session SET expires = $1 WHERE id = $2", - "describe": { - "columns": [], - "parameters": { - "Left": [ - "Timestamp", - "Text" - ] - }, - "nullable": [] - }, - "hash": "1bb3c8ecbd6500717d639678e08ab52c14293fa64d260db812c89ed43a5a7cc8" -} From ea35384f49f8a77da3ce7df84bbc9b33acaffa13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20W=C3=B3jcik?= Date: Tue, 2 Jan 2024 11:20:11 +0100 Subject: [PATCH 7/7] update query data --- ...72929d6a612846acf4a5489c36a04cb57de59.json | 22 +++++++++++++++++++ ...ab52c14293fa64d260db812c89ed43a5a7cc8.json | 15 +++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 .sqlx/query-0ad599ef120ecc02b030bd1276172929d6a612846acf4a5489c36a04cb57de59.json create mode 100644 .sqlx/query-1bb3c8ecbd6500717d639678e08ab52c14293fa64d260db812c89ed43a5a7cc8.json diff --git a/.sqlx/query-0ad599ef120ecc02b030bd1276172929d6a612846acf4a5489c36a04cb57de59.json b/.sqlx/query-0ad599ef120ecc02b030bd1276172929d6a612846acf4a5489c36a04cb57de59.json new file mode 100644 index 000000000..ce67e4293 --- /dev/null +++ b/.sqlx/query-0ad599ef120ecc02b030bd1276172929d6a612846acf4a5489c36a04cb57de59.json @@ -0,0 +1,22 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT recovery_codes FROM \"user\" WHERE id = $1", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "recovery_codes", + "type_info": "TextArray" + } + ], + "parameters": { + "Left": [ + "Int8" + ] + }, + "nullable": [ + false + ] + }, + "hash": "0ad599ef120ecc02b030bd1276172929d6a612846acf4a5489c36a04cb57de59" +} diff --git a/.sqlx/query-1bb3c8ecbd6500717d639678e08ab52c14293fa64d260db812c89ed43a5a7cc8.json b/.sqlx/query-1bb3c8ecbd6500717d639678e08ab52c14293fa64d260db812c89ed43a5a7cc8.json new file mode 100644 index 000000000..8d314a5fa --- /dev/null +++ b/.sqlx/query-1bb3c8ecbd6500717d639678e08ab52c14293fa64d260db812c89ed43a5a7cc8.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE session SET expires = $1 WHERE id = $2", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Timestamp", + "Text" + ] + }, + "nullable": [] + }, + "hash": "1bb3c8ecbd6500717d639678e08ab52c14293fa64d260db812c89ed43a5a7cc8" +}