Skip to content

Commit 7c9b773

Browse files
Bill LeoutsakosBill Leoutsakos
authored andcommitted
fix(snowflake): submit OAuth connection form explicitly
1 parent 0a4e770 commit 7c9b773

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

apps/sim/app/api/auth/snowflake/authorize/route.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ describe('Snowflake authorize route', () => {
5555
expect(html).toContain('name="accountUrl"')
5656
expect(html).toContain('name="accountLocator"')
5757
expect(html).toContain('name="clientId"')
58+
expect(html).toContain('action="/api/auth/snowflake/authorize"')
59+
expect(html).toContain('onsubmit="handleSubmit(event)"')
60+
expect(html).toContain('new URLSearchParams(new FormData(form))')
61+
expect(html).toContain(`name="returnUrl" value="${BASE_URL}/workspace/ws-1"`)
62+
expect(html).toContain('name="workspaceId" value="ws-1"')
5863
})
5964

6065
it('creates a workspace draft and redirects with state and S256 PKCE', async () => {

apps/sim/app/api/auth/snowflake/authorize/route.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ function renderConnectionForm(params: { returnUrl?: string; workspaceId?: string
6868
<main>
6969
<h1>Connect Snowflake</h1>
7070
<p>Enter the values from the Snowflake security integration configured for Sim.</p>
71-
<form method="get">
71+
<form method="get" action="/api/auth/snowflake/authorize" onsubmit="handleSubmit(event)">
7272
${hiddenReturnUrl}
7373
${hiddenWorkspaceId}
7474
<input type="hidden" name="providerId" value="snowflake" />
@@ -82,6 +82,14 @@ function renderConnectionForm(params: { returnUrl?: string; workspaceId?: string
8282
</form>
8383
<small>These values identify your Snowflake account and OAuth integration. Sim does not ask for the integration client secret.</small>
8484
</main>
85+
<script>
86+
function handleSubmit(event) {
87+
event.preventDefault();
88+
const form = event.currentTarget;
89+
const query = new URLSearchParams(new FormData(form));
90+
window.location.href = form.action + '?' + query.toString();
91+
}
92+
</script>
8593
</body>
8694
</html>`
8795
}

0 commit comments

Comments
 (0)