feat: support GOOSE_OAUTH_CALLBACK_PORT for stable OAuth redirect_uri (#9209)
Signed-off-by: Douwe Osinga <douwe@squareup.com> Co-authored-by: Douwe Osinga <douwe@squareup.com>
This commit is contained in:
@@ -76,7 +76,11 @@ pub async fn oauth_flow(
|
||||
.route("/oauth_callback", get(handler))
|
||||
.with_state(app_state);
|
||||
|
||||
let addr = SocketAddr::from(([127, 0, 0, 1], 0));
|
||||
let port: u16 = std::env::var("GOOSE_OAUTH_CALLBACK_PORT")
|
||||
.ok()
|
||||
.and_then(|p| p.parse().ok())
|
||||
.unwrap_or(0);
|
||||
let addr = SocketAddr::from(([127, 0, 0, 1], port));
|
||||
let listener = tokio::net::TcpListener::bind(addr).await?;
|
||||
let used_addr = listener.local_addr()?;
|
||||
tokio::spawn(async move {
|
||||
|
||||
@@ -341,7 +341,10 @@ impl OAuthFlow {
|
||||
|
||||
// If no port is specified (or port is explicitly 0), let the OS assign one
|
||||
// Otherwise, use the requested port
|
||||
let bind_port = requested_port.unwrap_or(0);
|
||||
let env_port: Option<u16> = std::env::var("GOOSE_OAUTH_CALLBACK_PORT")
|
||||
.ok()
|
||||
.and_then(|p| p.parse().ok());
|
||||
let bind_port = requested_port.or(env_port).unwrap_or(0);
|
||||
let addr = SocketAddr::from(([127, 0, 0, 1], bind_port));
|
||||
let listener = tokio::net::TcpListener::bind(addr).await?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user