Skip to content

Commit 9ab3f40

Browse files
authored
deprecate callback/redirect URL settings (#255)
* update protos * handle deprecated fields * mark url config as deprecated * update dependencies * mark deprecated config options * update protos * update dependencies
1 parent d03c142 commit 9ab3f40

File tree

9 files changed

+106
-148
lines changed

9 files changed

+106
-148
lines changed

Cargo.lock

Lines changed: 19 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

proto

src/config.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,19 @@ pub struct EnvConfig {
2626
pub grpc_port: u16,
2727

2828
#[arg(long, env = "DEFGUARD_PROXY_GRPC_CERT")]
29+
#[serde(skip_serializing)]
30+
#[deprecated(
31+
since = "2.0.0",
32+
note = "Certificates are automatically generated by Core CA"
33+
)]
2934
pub grpc_cert: Option<String>,
3035

3136
#[arg(long, env = "DEFGUARD_PROXY_GRPC_KEY")]
37+
#[serde(skip_serializing)]
38+
#[deprecated(
39+
since = "2.0.0",
40+
note = "Certificates are automatically generated by Core CA"
41+
)]
3242
pub grpc_key: Option<String>,
3343

3444
#[arg(long, env = "DEFGUARD_PROXY_LOG_LEVEL", default_value_t = LevelFilter::Info)]
@@ -47,6 +57,8 @@ pub struct EnvConfig {
4757
default_value = "http://localhost:8080"
4858
)]
4959
#[serde(default = "default_url")]
60+
#[serde(skip_serializing)]
61+
#[deprecated(since = "2.0.0", note = "Public URL is generated by Core instead")]
5062
pub url: Url,
5163

5264
/// Configuration file path

src/enterprise/handlers/desktop_client_mfa.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,9 @@ pub(super) async fn mfa_auth_callback(
7979
let request = ClientMfaOidcAuthenticateRequest {
8080
code: payload.code,
8181
nonce,
82-
callback_url: state.callback_url(&payload.flow_type).to_string(),
8382
state: payload.state,
83+
#[allow(deprecated)]
84+
callback_url: String::new(),
8485
};
8586

8687
debug!("Sending MFA OIDC authenticate request to core service");

src/enterprise/handlers/openid_login.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ use crate::{
1212
handlers::get_core_response,
1313
http::AppState,
1414
proto::{
15-
core_request, core_response, AuthCallbackRequest, AuthCallbackResponse, AuthInfoRequest,
16-
DeviceInfo,
15+
core_request, core_response, AuthCallbackRequest, AuthCallbackResponse, AuthFlowType,
16+
AuthInfoRequest, DeviceInfo,
1717
},
1818
};
1919

@@ -68,9 +68,15 @@ async fn auth_info(
6868
) -> Result<(PrivateCookieJar, Json<AuthInfo>), ApiError> {
6969
debug!("Getting auth info for OAuth2/OpenID login");
7070

71+
let auth_flow_type = match request_data.flow_type {
72+
FlowType::Enrollment => AuthFlowType::Enrollment as i32,
73+
FlowType::Mfa => AuthFlowType::Mfa as i32,
74+
};
7175
let request = AuthInfoRequest {
72-
redirect_url: state.callback_url(&request_data.flow_type).to_string(),
76+
#[allow(deprecated)]
77+
redirect_url: String::new(),
7378
state: request_data.state,
79+
auth_flow_type,
7480
};
7581

7682
let rx = state
@@ -158,7 +164,8 @@ async fn auth_callback(
158164
let request = AuthCallbackRequest {
159165
code: payload.code,
160166
nonce,
161-
callback_url: state.callback_url(&payload.flow_type).to_string(),
167+
#[allow(deprecated)]
168+
callback_url: String::new(),
162169
};
163170

164171
let rx = state

src/http.rs

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,11 @@ use tower_governor::{
2626
};
2727
use tower_http::trace::{self, TraceLayer};
2828
use tracing::{info_span, Level};
29-
use url::Url;
3029

3130
use crate::{
3231
assets::{index, web_asset},
3332
config::EnvConfig,
34-
enterprise::handlers::openid_login::{self, FlowType},
33+
enterprise::handlers::openid_login,
3534
error::ApiError,
3635
grpc::{Configuration, ProxyServer},
3736
handlers::{desktop_client_mfa, enrollment, password_reset, polling},
@@ -53,23 +52,6 @@ pub const GRPC_KEY_NAME: &str = "proxy_grpc_key.pem";
5352
pub(crate) struct AppState {
5453
pub(crate) grpc_server: ProxyServer,
5554
cookie_key: Arc<RwLock<Option<Key>>>,
56-
url: Url,
57-
}
58-
59-
impl AppState {
60-
/// Returns configured URL with "auth/callback" appended to the path.
61-
#[must_use]
62-
pub(crate) fn callback_url(&self, flow_type: &FlowType) -> Url {
63-
let mut url = self.url.clone();
64-
// Append "/openid/callback" to the URL.
65-
if let Ok(mut path_segments) = url.path_segments_mut() {
66-
match flow_type {
67-
FlowType::Enrollment => path_segments.extend(&["openid", "callback"]),
68-
FlowType::Mfa => path_segments.extend(&["openid", "mfa", "callback"]),
69-
};
70-
}
71-
url
72-
}
7355
}
7456

7557
impl FromRef<AppState> for Key {
@@ -354,7 +336,6 @@ pub async fn run_server(
354336
let shared_state = AppState {
355337
cookie_key,
356338
grpc_server,
357-
url: env_config.url.clone(),
358339
};
359340

360341
// Setup tower_governor rate-limiter

web/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
"@tanstack/react-form": "^1.28.3",
2121
"@tanstack/react-query": "^5.90.21",
2222
"@tanstack/react-query-devtools": "^5.91.3",
23-
"@tanstack/react-router": "^1.162.8",
24-
"@tanstack/react-router-devtools": "^1.162.8",
23+
"@tanstack/react-router": "^1.163.2",
24+
"@tanstack/react-router-devtools": "^1.163.2",
2525
"@uidotdev/usehooks": "^2.4.1",
2626
"axios": "^1.13.5",
2727
"change-case": "^5.4.4",
@@ -42,7 +42,7 @@
4242
"@biomejs/biome": "2.3.14",
4343
"@inlang/paraglide-js": "2.10.0",
4444
"@tanstack/devtools-vite": "^0.5.1",
45-
"@tanstack/router-plugin": "^1.162.8",
45+
"@tanstack/router-plugin": "^1.163.2",
4646
"@types/lodash-es": "^4.17.12",
4747
"@types/node": "^25.3.0",
4848
"@types/qs": "^6.14.0",

0 commit comments

Comments
 (0)