Skip to content

Commit

Permalink
auth: fix oauth callback
Browse files Browse the repository at this point in the history
  • Loading branch information
thdxr committed Sep 19, 2024
1 parent c040214 commit e849d5d
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 19 deletions.
19 changes: 2 additions & 17 deletions sdk/js/src/auth/adapter/github.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,18 @@
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",
authorization_endpoint: "https://github.com/login/oauth/authorize",
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,
});
};
2 changes: 1 addition & 1 deletion sdk/js/src/auth/adapter/oauth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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")) {
Expand Down
1 change: 0 additions & 1 deletion sdk/js/src/auth/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,6 @@ export function AuthHandler<
app.all("/*", async (c) => {
return c.notFound();
});
console.log(app.routes);

return app;
}

0 comments on commit e849d5d

Please sign in to comment.