Compare commits

...

3 Commits

Author SHA1 Message Date
Chuck Butkus
aca425faa1 Add some logging 2025-05-07 20:12:10 -04:00
Chuck Butkus
4d036e21ca Fix auth URL 2025-04-27 21:59:17 -04:00
Chuck Butkus
287bd90222 Fix localhost url 2025-04-27 18:00:35 -04:00
2 changed files with 12 additions and 3 deletions

View File

@@ -6,10 +6,17 @@
*/
export const generateAuthUrl = (identityProvider: string, requestUrl: URL) => {
const redirectUri = `${requestUrl.origin}/oauth/keycloak/callback`;
const authUrl = requestUrl.hostname
let authUrl = requestUrl.hostname
.replace(/(^|\.)staging\.all-hands\.dev$/, "$1auth.staging.all-hands.dev")
.replace(/(^|\.)app\.all-hands\.dev$/, "auth.app.all-hands.dev")
.replace(/(^|\.)localhost$/, "auth.staging.all-hands.dev");
.replace(/(^|\.)localhost$/, "localhost:8080");
// If no replacements matched, prepend "auth." (excluding localhost)
if (authUrl === requestUrl.hostname && requestUrl.hostname !== "localhost") {
authUrl = `auth.${requestUrl.hostname}`;
}
const scope = "openid email profile"; // OAuth scope - not user-facing
return `https://${authUrl}/realms/allhands/protocol/openid-connect/auth?client_id=allhands&kc_idp_hint=${identityProvider}&response_type=code&redirect_uri=${encodeURIComponent(redirectUri)}&scope=${encodeURIComponent(scope)}`;
const isLocalhost = requestUrl.hostname === "localhost";
const protocol = isLocalhost ? "http" : "https";
return `${protocol}://${authUrl}/realms/testing/protocol/openid-connect/auth?client_id=testing&kc_idp_hint=${identityProvider}&response_type=code&redirect_uri=${encodeURIComponent(redirectUri)}&scope=${encodeURIComponent(scope)}`;
};

View File

@@ -4,6 +4,7 @@ from typing import Any
import httpx
from tenacity import retry, retry_if_exception, stop_after_attempt, wait_exponential
from openhands.core.logger import openhands_logger as logger
from openhands.utils.http_session import HttpSession
from openhands.utils.tenacity_stop import stop_if_should_exit
@@ -41,6 +42,7 @@ def send_request(
timeout: int = 10,
**kwargs: Any,
) -> httpx.Response:
logger.info(f'sending {method} request to {url} with args {kwargs}')
response = session.request(method, url, timeout=timeout, **kwargs)
try:
response.raise_for_status()