feat: enhance error handling in OAuth URL building and client creation; improve tool argument sanitization
This commit is contained in:
@@ -84,7 +84,22 @@ impl OAuthManager {
|
||||
}
|
||||
|
||||
pub fn build_auth_url(&self, redirect_uri: &str, state: &str, code_challenge: &str) -> String {
|
||||
let mut url = url::Url::parse(&self.config.auth_url).unwrap_or_else(|_| url::Url::parse("https://example.com").unwrap());
|
||||
// Refuse to build a URL if `auth_url` is missing or invalid. Previously this
|
||||
// silently fell back to https://example.com, which produced a valid-looking
|
||||
// auth URL pointing at the wrong server and leaked client credentials in
|
||||
// query params. Returning an empty string signals failure to callers, who
|
||||
// can prompt the user to fix the OAuth config instead of starting a flow
|
||||
// against a wrong host.
|
||||
let mut url = match url::Url::parse(&self.config.auth_url) {
|
||||
Ok(u) if !self.config.auth_url.is_empty() => u,
|
||||
_ => {
|
||||
eprintln!(
|
||||
"warning: OAuth auth_url is missing or invalid ('{}'); aborting build_auth_url",
|
||||
self.config.auth_url
|
||||
);
|
||||
return String::new();
|
||||
}
|
||||
};
|
||||
url.query_pairs_mut()
|
||||
.append_pair("response_type", "code")
|
||||
.append_pair("client_id", &self.config.client_id)
|
||||
|
||||
Reference in New Issue
Block a user