From e849d5d4c2532cd71ee999269e9d6d984626ab2c Mon Sep 17 00:00:00 2001 From: Dax Raad Date: Thu, 19 Sep 2024 14:19:08 -0400 Subject: [PATCH] auth: fix oauth callback --- sdk/js/src/auth/adapter/github.ts | 19 ++----------------- sdk/js/src/auth/adapter/oauth.ts | 2 +- sdk/js/src/auth/handler.ts | 1 - 3 files changed, 3 insertions(+), 19 deletions(-) diff --git a/sdk/js/src/auth/adapter/github.ts b/sdk/js/src/auth/adapter/github.ts index 70c114810..487d1affc 100644 --- a/sdk/js/src/auth/adapter/github.ts +++ b/sdk/js/src/auth/adapter/github.ts @@ -1,6 +1,5 @@ import { Issuer } from "openid-client"; import { OauthAdapter, OauthBasicConfig } from "./oauth.js"; -import { OidcAdapter, OidcBasicConfig } from "./oidc.js"; const issuer = new Issuer({ issuer: "https://github.com", @@ -8,26 +7,12 @@ const issuer = new Issuer({ token_endpoint: "https://github.com/login/oauth/access_token", }); -type Config = - | ({ - mode: "oauth"; - } & OauthBasicConfig) - | ({ - mode: "oidc"; - } & OidcBasicConfig); - +type Config = OauthBasicConfig; export const GithubAdapter = /* @__PURE__ */ (config: Config) => { - if (config.mode === "oauth") { - return OauthAdapter({ - issuer, - ...config, - }); - } - return OidcAdapter({ + return OauthAdapter({ issuer, - scope: "openid email profile", ...config, }); }; diff --git a/sdk/js/src/auth/adapter/oauth.ts b/sdk/js/src/auth/adapter/oauth.ts index fc62e0ebc..6e0366297 100644 --- a/sdk/js/src/auth/adapter/oauth.ts +++ b/sdk/js/src/auth/adapter/oauth.ts @@ -96,7 +96,7 @@ export const OauthAdapter = }); // response_mode=form_post - routes.get("/callback", async (c) => { + routes.post("/callback", async (c) => { const [callback, client] = getClient(c); const form = await c.req.formData(); if (form.get("error")) { diff --git a/sdk/js/src/auth/handler.ts b/sdk/js/src/auth/handler.ts index e16917866..ae7d788b6 100644 --- a/sdk/js/src/auth/handler.ts +++ b/sdk/js/src/auth/handler.ts @@ -317,7 +317,6 @@ export function AuthHandler< app.all("/*", async (c) => { return c.notFound(); }); - console.log(app.routes); return app; }