middleware icon indicating copy to clipboard operation
middleware copied to clipboard

Enhance Robustness of auth-js Middleware

Open catnaut opened this issue 1 year ago • 5 comments

index.ts:

  • Refactored getSession based on https://github.com/nextauthjs/next-auth/blob/main/packages/frameworks-express/src/index.ts for improved alignment.
  • Replaced redundant Env handling with @auth/core's setEnvDefaults for cleaner configuration.
    • fix #741
  • Removed redundant configuration checks already handled in @auth/core.
  • fix #817

docs:

  • In the default example, use basePath as it aligns with v5 behavior where the host is inferred from request headers. Setting AUTH_URL is only necessary if a custom base path is needed.(https://authjs.dev/getting-started/deployment#auth_url)

This is my first attempt at backend development, and I would really appreciate a thorough review and any suggestions. I’m still learning and want to make sure everything is implemented correctly. Thank you for your help!

catnaut avatar Nov 09 '24 18:11 catnaut

šŸ¦‹ Changeset detected

Latest commit: a149c1ec303a04d3110a3d8c02849a50eb21bc5f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@hono/auth-js Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

changeset-bot[bot] avatar Nov 09 '24 18:11 changeset-bot[bot]

Hi @catnaut

Is this ready for review?

yusukebe avatar Nov 12 '24 19:11 yusukebe

@yusukebe

Yup, it's all set and ready for your review! 😊

catnaut avatar Nov 13 '24 13:11 catnaut

@catnaut Thanks!

Hi @divyam234, Sorry to bother you. Can you review this?

yusukebe avatar Nov 13 '24 19:11 yusukebe

@catnaut Usually handling of x-forwarded headers is handled at webserver like nginx or caddy so that it's not tampered with in first place for nextjs its already handled by vercel so current solution is valid for next-auth . Also setting AUTH_URL completley bypasses it. It should not be removed instead we can mention in doc how to mitigate it if people are not using webserver but I doubt that if anyone is deploying any application without webserver in production.

divyam234 avatar Nov 14 '24 03:11 divyam234