You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/webserver/oidc.rs
+26-14Lines changed: 26 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -40,19 +40,7 @@ impl TryFrom<&AppConfig> for OidcConfig {
40
40
"The \"oidc_client_secret\" setting is required to authenticate with the OIDC provider",
41
41
))?;
42
42
43
-
let app_host = config
44
-
.host
45
-
.as_ref()
46
-
.or_else(|| config.https_domain.as_ref())
47
-
.cloned()
48
-
.unwrap_or_else(|| {
49
-
let host = config.listen_on().to_string();
50
-
log::warn!(
51
-
"No host or https_domain provided in the configuration, using \"{}\" as the app host to build the redirect URL. This will only work locally. Disable this warning by providing a value for the \"host\" setting.",
52
-
host
53
-
);
54
-
host
55
-
});
43
+
let app_host = get_app_host(config);
56
44
57
45
Ok(Self{
58
46
issuer_url: issuer_url.clone(),
@@ -68,6 +56,31 @@ impl TryFrom<&AppConfig> for OidcConfig {
68
56
}
69
57
}
70
58
59
+
fnget_app_host(config:&AppConfig) -> String{
60
+
ifletSome(host) = &config.host{
61
+
return host.clone();
62
+
}
63
+
ifletSome(https_domain) = &config.https_domain{
64
+
return https_domain.clone();
65
+
}
66
+
67
+
let socket_addr = config.listen_on();
68
+
let ip = socket_addr.ip();
69
+
let host = if ip.is_unspecified() || ip.is_loopback(){
70
+
format!("localhost:{}", socket_addr.port())
71
+
}else{
72
+
socket_addr.to_string()
73
+
};
74
+
log::warn!(
75
+
"No host or https_domain provided in the configuration, \
76
+
using \"{}\" as the app host to build the redirect URL. \
77
+
This will only work locally. \
78
+
Disable this warning by providing a value for the \"host\" setting.",
79
+
host
80
+
);
81
+
host
82
+
}
83
+
71
84
pubstructOidcMiddleware{
72
85
pubconfig:Option<Arc<OidcConfig>>,
73
86
app_state: web::Data<AppState>,
@@ -79,7 +92,6 @@ impl OidcMiddleware {
79
92
match&config {
80
93
Ok(config) => {
81
94
log::debug!("Setting up OIDC with issuer: {}", config.issuer_url);
0 commit comments