rusackas commented on code in PR #45204:
URL: https://github.com/apache/superset/pull/45204#discussion_r4246199265


##########
superset-frontend/packages/superset-ui-core/src/connection/SupersetClientClass.ts:
##########
@@ -149,15 +149,27 @@ export default class SupersetClientClass {
     return this.fetchCSRFToken();
   }
 
+  /**
+   * Submit a hidden form via POST.
+   * @param endpointOrConfig - an endpoint (resolved against the app root), or
+   * an object with either an `endpoint` or an already absolute `url`, which
+   * is used as is.
+   * @param payload - form fields
+   * @param target - form target, defaults to a new tab
+   */
   async postForm(
-    endpoint: string,
+    endpointOrConfig: string | { endpoint?: string; url?: string },
     payload: Record<string, any>,
     target = '_blank',
   ) {
-    if (endpoint) {
+    const { endpoint, url } =
+      typeof endpointOrConfig === 'string'
+        ? { endpoint: endpointOrConfig, url: undefined }
+        : endpointOrConfig;
+    if (endpoint || url) {
       await this.ensureAuth();
       const hiddenForm = document.createElement('form');
-      hiddenForm.action = sanitizeUrl(this.getUrl({ endpoint }));
+      hiddenForm.action = sanitizeUrl(this.getUrl({ endpoint, url }));

Review Comment:
   Good catch. postForm now throws unless the url is same-origin (page origin 
or the client host), before any tokens go into the form. Added a test for the 
cross-origin case. Haven't been able to run jest locally here, so CI will tell.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to