Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V2 - oauth2 upgrade #110

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

V2 - oauth2 upgrade #110

wants to merge 3 commits into from

Conversation

atomicpages
Copy link

@atomicpages atomicpages commented Jul 14, 2024

Bumped remix-auth-oauth2 to v2 which caused breaking changes in this package. The shape of the verify response has changed and appending non-standard custom query string params doesn't appear to be working:

test("should allow additional search params", async () => {
  const strategy = new Auth0Strategy(
    {
      domain: "test.fake.auth0.com",
      clientID: "CLIENT_ID",
      clientSecret: "CLIENT_SECRET",
      callbackURL: "https://example.app/callback",
    },
    verify,
  );

  const request = new Request("https://example.app/auth/auth0?test=1");

  try {
    await strategy.authenticate(request, sessionStorage, BASE_OPTIONS);
  } catch (error) {
    if (!(error instanceof Response)) throw error;
    const location = error.headers.get("Location");

    if (!location) throw new Error("No redirect header");

    const redirectUrl = new URL(location);

    // FAILS
    expect(redirectUrl.searchParams.get("test")).toBe("1");
  }
});

https://github.com/sergiodxa/remix-auth-oauth2/blob/e35cd155b8f8ffdbb0f1047f1101f6493d2757f5/src/index.ts#L138 is no longer pulling custom url params

p.s. this contains commits from #109 as well

@@ -10,6 +10,7 @@ const config: Config.InitialOptions = {
resetMocks: false,
setupFilesAfterEnv: ["<rootDir>/config/jest/setup.ts"],
testMatch: ["<rootDir>/test/**/*.test.ts"],
transformIgnorePatterns: ["/node_modules/(?!remix-auth-oauth2)/"],
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

v2 is ESM so we need to transpile

Comment on lines +94 to +99
authorizationEndpoint: `https://${options.domain}/authorize`,
tokenEndpoint: `https://${options.domain}/oauth/token`,
tokenRevocationEndpoint: `https://${options.domain}/oauth/revoke`,
clientId: options.clientID,
clientSecret: options.clientSecret,
callbackURL: options.callbackURL,
redirectURI: options.callbackURL,
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New keys to support v2 config changes

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

General CI cleanup. Save CI minutes by running all checks before build

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant