* add public client * implement PKCE * pass codeChallenge and codeChallengeMethod to handler * fixes for secure oauth flow * fix type error * clean up refresh token endpoint * only support S256 * fix type error * remove comment * add tests * fix type errors in route.test.ts * add missing support for refresh token * add e2e test for public client refresh tokens * allow pkce for confidential clients * fix type error * fix e2e * fix option pkce for confidential clients * e2e test improvements * fix test * remove only * add delay * fix e2e tests * remove only * don't skip pkce if codeChallenge is set * add service functions for token endpoint * use service function in refreshToken endpoint * use repository * remove return types * e2e test fixes * fix e2e test * remove .only in e2e test * remove pause * fix error responses in token endpoints * adjust tests to new error responses * fix error responses * e2e improvements * redirect on error * adjust tests * Update apps/web/modules/auth/oauth2/authorize-view.tsx Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com> --------- Co-authored-by: CarinaWolli <wollencarina@gmail.com> Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
18 lines
454 B
TypeScript
18 lines
454 B
TypeScript
import { createHash } from "crypto";
|
|
|
|
export function verifyCodeChallenge(
|
|
codeVerifier: string,
|
|
codeChallenge: string,
|
|
method: string = "S256"
|
|
): boolean {
|
|
if (method === "S256") {
|
|
const expectedChallenge = createHash("sha256").update(codeVerifier).digest("base64url");
|
|
return expectedChallenge === codeChallenge;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
export function isValidCodeChallengeMethod(method: string): boolean {
|
|
return method === "S256";
|
|
}
|