mirror of
https://github.com/stack-auth/stack.git
synced 2026-06-13 21:01:21 +08:00
fix bugs
This commit is contained in:
parent
6193bef251
commit
2191e1c023
@ -1,4 +1,5 @@
|
||||
import { encodeBase64Url } from "@stackframe/stack-shared/dist/utils/bytes";
|
||||
import { encodeBasicAuthorizationHeader } from "@stackframe/stack-shared/dist/utils/http";
|
||||
import { expect } from "vitest";
|
||||
import { it, updateCookiesFromResponse } from "../../../../../../helpers";
|
||||
import { Auth, InternalApiKey, Project, backendContext, niceBackendFetch } from "../../../../../backend-helpers";
|
||||
@ -202,7 +203,7 @@ it(`should exchange the authorization code for an admin API key that works`, asy
|
||||
redirect_uri: "http://localhost:30000/api/v2/auth/authorize",
|
||||
},
|
||||
headers: {
|
||||
"Authorization": "Basic bmVvbi1sb2NhbDpuZW9uLWxvY2FsLXNlY3JldA=="
|
||||
"Authorization": encodeBasicAuthorizationHeader("custom-local", "custom-local-secret")
|
||||
},
|
||||
});
|
||||
expect(tokenResponse).toMatchInlineSnapshot(`
|
||||
@ -256,7 +257,7 @@ it(`should not exchange the authorization code when the client secret is incorre
|
||||
redirect_uri: "http://localhost:30000/api/v2/auth/authorize",
|
||||
},
|
||||
headers: {
|
||||
"Authorization": "Basic bmVvbi1sb2NhbDpuZW9uLWxvY2FsLXNlY2JldA=="
|
||||
"Authorization": encodeBasicAuthorizationHeader("custom-local", "wrong-secret")
|
||||
},
|
||||
});
|
||||
expect(tokenResponse).toMatchInlineSnapshot(`
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import { encodeBase64Url } from "@stackframe/stack-shared/dist/utils/bytes";
|
||||
import { encodeBasicAuthorizationHeader } from "@stackframe/stack-shared/dist/utils/http";
|
||||
import { expect } from "vitest";
|
||||
import { it, updateCookiesFromResponse } from "../../../../../../helpers";
|
||||
import { Auth, InternalApiKey, Project, backendContext, niceBackendFetch } from "../../../../../backend-helpers";
|
||||
@ -202,7 +203,7 @@ it(`should exchange the authorization code for an admin API key that works`, asy
|
||||
redirect_uri: "http://localhost:30000/api/v2/auth/authorize",
|
||||
},
|
||||
headers: {
|
||||
"Authorization": "Basic bmVvbi1sb2NhbDpuZW9uLWxvY2FsLXNlY3JldA=="
|
||||
"Authorization": encodeBasicAuthorizationHeader("neon-local", "neon-local-secret")
|
||||
},
|
||||
});
|
||||
expect(tokenResponse).toMatchInlineSnapshot(`
|
||||
@ -256,7 +257,7 @@ it(`should not exchange the authorization code when the client secret is incorre
|
||||
redirect_uri: "http://localhost:30000/api/v2/auth/authorize",
|
||||
},
|
||||
headers: {
|
||||
"Authorization": "Basic bmVvbi1sb2NhbDpuZW9uLWxvY2FsLXNlY2JldA=="
|
||||
"Authorization": encodeBasicAuthorizationHeader("neon-local", "wrong-secret")
|
||||
},
|
||||
});
|
||||
expect(tokenResponse).toMatchInlineSnapshot(`
|
||||
|
||||
@ -482,6 +482,7 @@ export const basicAuthorizationHeaderSchema = yupString().test('is-basic-authori
|
||||
// Neon integration
|
||||
export const neonAuthorizationHeaderSchema = basicAuthorizationHeaderSchema.test('is-neon-authorization-header', 'Invalid client_id:client_secret values; did you use the correct values for the Neon integration?', (value) => {
|
||||
if (!value) return true;
|
||||
console.log("????????????", value, decodeBasicAuthorizationHeader(value));
|
||||
const [clientId, clientSecret] = decodeBasicAuthorizationHeader(value) ?? throwErr(`Neon authz header invalid? This should've been validated by basicAuthorizationHeaderSchema: ${value}`);
|
||||
for (const neonClientConfig of JSON.parse(process.env.STACK_INTEGRATION_CLIENTS_CONFIG || '[]')) {
|
||||
if (clientId === neonClientConfig.client_id && clientSecret === neonClientConfig.client_secret) return true;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user