From 1aa401e22a63418ae3161381143ca88f40a271fe Mon Sep 17 00:00:00 2001 From: mohitdeuex Date: Tue, 21 Jul 2026 18:26:27 +0530 Subject: [PATCH 1/2] Fixes #5183: allow configurable trusted redirect URIs for browser-extension login PR #26314 added an exact-match redirect-URI allowlist to /api/v1/auth/login built only from callbackUrl and the server's /auth/callback and /mcp/callback. Browser-extension logins redirect to https://.chromiumapp.org/, which cannot be registered anywhere, so login returned 400 "Redirect URI must exactly match a trusted redirect URI". Add an optional authenticationConfiguration.additionalTrustedRedirectUris list and merge it into the allowlist in both the OIDC (requireRedirectUri) and SAML (trustedSamlRedirects) handlers. Exact-match semantics are preserved, so this does not reopen the open-redirect hole; wildcard host matching was intentionally avoided as it would let any extension receive a token. Defaults to empty, so existing deployments are unchanged and must opt in. Co-Authored-By: Claude Opus 4.8 (1M context) --- conf/openmetadata.yaml | 4 ++ .../AuthenticationCodeFlowHandler.java | 7 ++- .../security/auth/SamlAuthServletHandler.java | 8 ++- .../AuthenticationCodeFlowHandlerTest.java | 56 +++++++++++++++++++ .../authenticationConfiguration.json | 8 +++ .../authenticationConfiguration.ts | 7 +++ 6 files changed, 85 insertions(+), 5 deletions(-) diff --git a/conf/openmetadata.yaml b/conf/openmetadata.yaml index a2c0ed1d84d4..9b9321d65371 100644 --- a/conf/openmetadata.yaml +++ b/conf/openmetadata.yaml @@ -451,6 +451,10 @@ authenticationConfiguration: clientId: ${AUTHENTICATION_CLIENT_ID:-""} # For SSO: Set to your OAuth callback URL (e.g., "https://yourhost/api/v1/callback") callbackUrl: ${AUTHENTICATION_CALLBACK_URL:-""} + # Additional redirect URIs allowed for the login flow (beyond callbackUrl and the server callbacks). + # Each entry must exactly match the requested redirect URI. Use for browser-extension logins, + # e.g. ["https://.chromiumapp.org/auth0"]. + additionalTrustedRedirectUris: ${AUTHENTICATION_ADDITIONAL_TRUSTED_REDIRECT_URIS:-[]} jwtPrincipalClaims: ${AUTHENTICATION_JWT_PRINCIPAL_CLAIMS:-[email,preferred_username,sub]} jwtPrincipalClaimsMapping: ${AUTHENTICATION_JWT_PRINCIPAL_CLAIMS_MAPPING:-[]} enableSelfSignup : ${AUTHENTICATION_ENABLE_SELF_SIGNUP:-true} diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/security/AuthenticationCodeFlowHandler.java b/openmetadata-service/src/main/java/org/openmetadata/service/security/AuthenticationCodeFlowHandler.java index 6eb51efa2c4d..8a3a7d64f941 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/security/AuthenticationCodeFlowHandler.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/security/AuthenticationCodeFlowHandler.java @@ -1040,12 +1040,13 @@ private OIDCTokenResponse parseTokenResponseFromHttpResponse(HTTPResponse httpRe } private String requireRedirectUri(String redirectUri) { - return org.openmetadata.service.security.SecurityUtil.validateRedirectUri( - redirectUri, + Set trusted = trustedRedirects( authenticationConfiguration.getCallbackUrl(), serverUrl + "/auth/callback", - serverUrl + "/mcp/callback")); + serverUrl + "/mcp/callback"); + trusted.addAll(listOrEmpty(authenticationConfiguration.getAdditionalTrustedRedirectUris())); + return org.openmetadata.service.security.SecurityUtil.validateRedirectUri(redirectUri, trusted); } private User getSessionUser(UserSession session) { diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/security/auth/SamlAuthServletHandler.java b/openmetadata-service/src/main/java/org/openmetadata/service/security/auth/SamlAuthServletHandler.java index ab775a969302..4aff017f5dd4 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/security/auth/SamlAuthServletHandler.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/security/auth/SamlAuthServletHandler.java @@ -1,5 +1,6 @@ package org.openmetadata.service.security.auth; +import static org.openmetadata.common.utils.CommonUtil.listOrEmpty; import static org.openmetadata.common.utils.CommonUtil.nullOrEmpty; import static org.openmetadata.service.security.SecurityUtil.extractDisplayNameFromClaims; import static org.openmetadata.service.security.SecurityUtil.writeErrorResponse; @@ -653,8 +654,11 @@ private Set getAdminPrincipals() { } private Set trustedSamlRedirects() { - return org.openmetadata.service.security.SecurityUtil.trustedRedirects( - authConfig.getCallbackUrl(), samlSpCallback(), samlAuthCallback()); + Set trusted = + org.openmetadata.service.security.SecurityUtil.trustedRedirects( + authConfig.getCallbackUrl(), samlSpCallback(), samlAuthCallback()); + trusted.addAll(listOrEmpty(authConfig.getAdditionalTrustedRedirectUris())); + return trusted; } private ServiceProviderConfig samlSp() { diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/security/AuthenticationCodeFlowHandlerTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/security/AuthenticationCodeFlowHandlerTest.java index db6ee73ca2b3..96afffa6f454 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/security/AuthenticationCodeFlowHandlerTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/security/AuthenticationCodeFlowHandlerTest.java @@ -22,6 +22,7 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Optional; import java.util.Set; @@ -410,6 +411,61 @@ void getOrCreateOidcUser_selfSignup_rejectsDisallowedEmailDomain() throws Except } } + @Test + void requireRedirectUri_allowsConfiguredBrowserExtensionRedirect() throws Exception { + String extensionRedirect = "https://ndjnpiadedlmgddlpeklbnobebkpkdgb.chromiumapp.org/auth0"; + AuthenticationCodeFlowHandler handler = + createRedirectHandler("https://app.example.com", "", List.of(extensionRedirect)); + + assertEquals(extensionRedirect, invokeRequireRedirectUri(handler, extensionRedirect)); + } + + @Test + void requireRedirectUri_rejectsUnconfiguredBrowserExtensionRedirect() throws Exception { + AuthenticationCodeFlowHandler handler = + createRedirectHandler("https://app.example.com", "", List.of()); + + IllegalArgumentException thrown = + assertThrows( + IllegalArgumentException.class, + () -> invokeRequireRedirectUri(handler, "https://evil.chromiumapp.org/auth0")); + + assertEquals("Redirect URI must exactly match a trusted redirect URI", thrown.getMessage()); + } + + private AuthenticationCodeFlowHandler createRedirectHandler( + String serverUrl, String callbackUrl, List additionalTrustedRedirectUris) + throws Exception { + AuthenticationConfiguration authConfig = mock(AuthenticationConfiguration.class); + when(authConfig.getCallbackUrl()).thenReturn(callbackUrl); + when(authConfig.getAdditionalTrustedRedirectUris()).thenReturn(additionalTrustedRedirectUris); + + AuthenticationCodeFlowHandler handler = + (AuthenticationCodeFlowHandler) + getUnsafe().allocateInstance(AuthenticationCodeFlowHandler.class); + setField(handler, "authenticationConfiguration", authConfig); + setField(handler, "serverUrl", serverUrl); + return handler; + } + + private String invokeRequireRedirectUri(AuthenticationCodeFlowHandler handler, String redirectUri) + throws Exception { + Method method = + AuthenticationCodeFlowHandler.class.getDeclaredMethod("requireRedirectUri", String.class); + method.setAccessible(true); + String result; + try { + result = (String) method.invoke(handler, redirectUri); + } catch (InvocationTargetException e) { + Throwable cause = e.getCause(); + if (cause instanceof RuntimeException runtimeException) { + throw runtimeException; + } + throw e; + } + return result; + } + private AuthenticationCodeFlowHandler createSelfSignupHandler(Set allowedDomains) throws Exception { AuthenticationConfiguration authConfig = mock(AuthenticationConfiguration.class); diff --git a/openmetadata-spec/src/main/resources/json/schema/configuration/authenticationConfiguration.json b/openmetadata-spec/src/main/resources/json/schema/configuration/authenticationConfiguration.json index fa8a7ef0050f..503d22843c2f 100644 --- a/openmetadata-spec/src/main/resources/json/schema/configuration/authenticationConfiguration.json +++ b/openmetadata-spec/src/main/resources/json/schema/configuration/authenticationConfiguration.json @@ -71,6 +71,14 @@ "description": "Callback URL", "type": "string" }, + "additionalTrustedRedirectUris": { + "title": "Additional Trusted Redirect URIs", + "description": "Additional redirect URIs allowed for the login flow, beyond the callback URL and the server's own callbacks. Each entry must exactly match the requested redirect URI (scheme, host, port, path, query). Use this to allow browser-extension login redirects such as 'https://.chromiumapp.org/'.", + "type": "array", + "items": { + "type": "string" + } + }, "jwtPrincipalClaims": { "title": "Jwt Principal Claims", "description": "Jwt Principal Claim", diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/configuration/authenticationConfiguration.ts b/openmetadata-ui/src/main/resources/ui/src/generated/configuration/authenticationConfiguration.ts index 9ebdef959802..d3f4e0b7c4dd 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/configuration/authenticationConfiguration.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/configuration/authenticationConfiguration.ts @@ -14,6 +14,13 @@ * This schema defines the Authentication Configuration. */ export interface AuthenticationConfiguration { + /** + * Additional redirect URIs allowed for the login flow, beyond the callback URL and the + * server's own callbacks. Each entry must exactly match the requested redirect URI (scheme, + * host, port, path, query). Use this to allow browser-extension login redirects such as + * 'https://.chromiumapp.org/'. + */ + additionalTrustedRedirectUris?: string[]; /** * Authentication Authority */ From 1af9a7e0bbeb45d4ec3947f5b748e592b2eabde5 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 21 Jul 2026 13:03:02 +0000 Subject: [PATCH 2/2] Update generated TypeScript types --- .../configuration/securityConfiguration.ts | 7 +++++++ .../ui/src/generated/settings/settings.ts | 14 ++++++++++++++ .../src/generated/system/testLoginTokenRequest.ts | 12 ++++++++++++ 3 files changed, 33 insertions(+) diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/configuration/securityConfiguration.ts b/openmetadata-ui/src/main/resources/ui/src/generated/configuration/securityConfiguration.ts index 9ae2df62f75f..1cc7eb9e9676 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/configuration/securityConfiguration.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/configuration/securityConfiguration.ts @@ -30,6 +30,13 @@ export interface SecurityConfiguration { * This schema defines the Authentication Configuration. */ export interface AuthenticationConfiguration { + /** + * Additional redirect URIs allowed for the login flow, beyond the callback URL and the + * server's own callbacks. Each entry must exactly match the requested redirect URI (scheme, + * host, port, path, query). Use this to allow browser-extension login redirects such as + * 'https://.chromiumapp.org/'. + */ + additionalTrustedRedirectUris?: string[]; /** * Authentication Authority */ diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/settings/settings.ts b/openmetadata-ui/src/main/resources/ui/src/generated/settings/settings.ts index 6478f669916f..f32fa30a82f7 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/settings/settings.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/settings/settings.ts @@ -178,6 +178,13 @@ export interface PipelineServiceClientConfiguration { * ignore, validate. */ verifySSL?: VerifySSL; + /** + * Additional redirect URIs allowed for the login flow, beyond the callback URL and the + * server's own callbacks. Each entry must exactly match the requested redirect URI (scheme, + * host, port, path, query). Use this to allow browser-extension login redirects such as + * 'https://.chromiumapp.org/'. + */ + additionalTrustedRedirectUris?: string[]; /** * Authentication Authority */ @@ -1200,6 +1207,13 @@ export enum AuthProvider { * Authentication configuration */ export interface AuthenticationConfiguration { + /** + * Additional redirect URIs allowed for the login flow, beyond the callback URL and the + * server's own callbacks. Each entry must exactly match the requested redirect URI (scheme, + * host, port, path, query). Use this to allow browser-extension login redirects such as + * 'https://.chromiumapp.org/'. + */ + additionalTrustedRedirectUris?: string[]; /** * Authentication Authority */ diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/system/testLoginTokenRequest.ts b/openmetadata-ui/src/main/resources/ui/src/generated/system/testLoginTokenRequest.ts index 9641c8a89241..d21ae0d5e054 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/system/testLoginTokenRequest.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/system/testLoginTokenRequest.ts @@ -49,6 +49,13 @@ export interface SecurityConfiguration { * This schema defines the Authentication Configuration. */ export interface AuthenticationConfiguration { + /** + * Additional redirect URIs allowed for the login flow, beyond the callback URL and the + * server's own callbacks. Each entry must exactly match the requested redirect URI (scheme, + * host, port, path, query). Use this to allow browser-extension login redirects such as + * 'https://.chromiumapp.org/'. + */ + additionalTrustedRedirectUris?: string[]; /** * Authentication Authority */ @@ -207,6 +214,11 @@ export interface LDAPConfiguration { * Port of the server */ port: number; + /** + * Enable transitive group membership resolution for Active Directory nested groups using + * LDAP_MATCHING_RULE_IN_CHAIN. + */ + recursiveGroupMembership?: boolean; /** * Admin role name */