Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions conf/openmetadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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://<extension-id>.chromiumapp.org/auth0"].
Comment on lines +454 to +456
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}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1040,12 +1040,13 @@ private OIDCTokenResponse parseTokenResponseFromHttpResponse(HTTPResponse httpRe
}

private String requireRedirectUri(String redirectUri) {
return org.openmetadata.service.security.SecurityUtil.validateRedirectUri(
redirectUri,
Set<String> 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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -653,8 +654,11 @@ private Set<String> getAdminPrincipals() {
}

private Set<String> trustedSamlRedirects() {
return org.openmetadata.service.security.SecurityUtil.trustedRedirects(
authConfig.getCallbackUrl(), samlSpCallback(), samlAuthCallback());
Set<String> trusted =
org.openmetadata.service.security.SecurityUtil.trustedRedirects(
authConfig.getCallbackUrl(), samlSpCallback(), samlAuthCallback());
trusted.addAll(listOrEmpty(authConfig.getAdditionalTrustedRedirectUris()));
return trusted;
Comment on lines +657 to +661
}

private ServiceProviderConfig samlSp() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<String> 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<String> allowedDomains)
throws Exception {
AuthenticationConfiguration authConfig = mock(AuthenticationConfiguration.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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://<extension-id>.chromiumapp.org/<path>'.",
Comment on lines +74 to +76
"type": "array",
"items": {
"type": "string"
}
},
"jwtPrincipalClaims": {
"title": "Jwt Principal Claims",
"description": "Jwt Principal Claim",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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://<extension-id>.chromiumapp.org/<path>'.
*/
additionalTrustedRedirectUris?: string[];
/**
* Authentication Authority
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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://<extension-id>.chromiumapp.org/<path>'.
*/
additionalTrustedRedirectUris?: string[];
/**
* Authentication Authority
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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://<extension-id>.chromiumapp.org/<path>'.
*/
additionalTrustedRedirectUris?: string[];
/**
* Authentication Authority
*/
Expand Down Expand Up @@ -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://<extension-id>.chromiumapp.org/<path>'.
*/
additionalTrustedRedirectUris?: string[];
/**
* Authentication Authority
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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://<extension-id>.chromiumapp.org/<path>'.
*/
additionalTrustedRedirectUris?: string[];
/**
* Authentication Authority
*/
Expand Down
Loading