Skip to content

Commit

Permalink
Fixed SSO not respecting the OS' trusted TLS CAs (#1233)
Browse files Browse the repository at this point in the history
Co-authored-by: Eugene <[email protected]>
  • Loading branch information
kakawait and Eugeny authored Feb 4, 2025
1 parent 376b897 commit 40e49a2
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 134 deletions.
133 changes: 23 additions & 110 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion warpgate-protocol-http/src/api/sso_provider_detail.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ impl Api {
return_url.set_path("@warpgate/api/sso/return");
debug!("Return URL: {}", &return_url);

let client = SsoClient::new(provider_config.provider.clone());
let client = SsoClient::new(provider_config.provider.clone())?;

let sso_req = client.start_login(return_url.to_string()).await?;

Expand Down
2 changes: 1 addition & 1 deletion warpgate-protocol-http/src/api/sso_provider_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ impl Api {
return Ok(StartSloResponse::NotFound);
};

let client = SsoClient::new(provider_config.provider.clone());
let client = SsoClient::new(provider_config.provider.clone())?;
let logout_url = client.logout(state.token, return_url).await?;

logout(session, session_middleware.lock().await.deref_mut());
Expand Down
6 changes: 5 additions & 1 deletion warpgate-sso/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ bytes.workspace = true
thiserror = "1.0"
tokio = { version = "1.20", features = ["tracing", "macros"] }
tracing.workspace = true
openidconnect = { version = "3.5", features = ["reqwest", "rustls-tls", "accept-string-booleans"] }
openidconnect = { version = "4.0", features = [
"reqwest",
"rustls-tls",
"accept-string-booleans",
] }
serde.workspace = true
serde_json.workspace = true
once_cell = "1.17"
Expand Down
10 changes: 9 additions & 1 deletion warpgate-sso/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use std::error::Error;

use openidconnect::{ClaimsVerificationError, SigningError};
use openidconnect::{
reqwest, ClaimsVerificationError, ConfigurationError, SignatureVerificationError, SigningError,
};

#[derive(thiserror::Error, Debug)]
pub enum SsoError {
Expand All @@ -20,10 +22,16 @@ pub enum SsoError {
ClaimsVerification(#[from] ClaimsVerificationError),
#[error("signing error: {0}")]
Signing(#[from] SigningError),
#[error("reqwest: {0}")]
Reqwest(#[from] reqwest::Error),
#[error("I/O: {0}")]
Io(#[from] std::io::Error),
#[error("JWT error: {0}")]
Jwt(#[from] jsonwebtoken::errors::Error),
#[error("signature verification: {0}")]
SignatureVerification(#[from] SignatureVerificationError),
#[error("configuration: {0}")]
Configuration(#[from] ConfigurationError),
#[error("the OIDC provider doesn't support RP-initiated logout")]
LogoutNotSupported,
#[error(transparent)]
Expand Down
3 changes: 1 addition & 2 deletions warpgate-sso/src/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ impl SsoLoginRequest {
}

pub async fn verify_code(self, code: String) -> Result<SsoLoginResponse, SsoError> {
//
let result = SsoClient::new(self.config)
let result = SsoClient::new(self.config)?
.finish_login(self.pkce_verifier, self.redirect_url, &self.nonce, code)
.await?;

Expand Down
Loading

0 comments on commit 40e49a2

Please sign in to comment.