-
Notifications
You must be signed in to change notification settings - Fork 1k
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
feat(server-auth): dbAuth 3/3 - handle login, logout, signup, etc. requests if forwarded from middleware #10457
feat(server-auth): dbAuth 3/3 - handle login, logout, signup, etc. requests if forwarded from middleware #10457
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dac09 Confirmed login, logout, signup and currentUser work in classic GraphQL app.
Both session and auth-provider cookies are set ... and cleared on logout.
See the change the the test import in packages/auth-providers/dbAuth/api/src/__tests__/buildDbAuthResponse.test.ts
but LGTM and approved to
@@ -0,0 +1,69 @@ | |||
import { describe, it, expect } from 'vitest' | |||
|
|||
import { buildDbAuthResponse } from '/Users/dac09/Code/redwood/packages/auth-providers/dbAuth/api/src/shared' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dac09 This test fails locally as it points to a local package with your "dac" path.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dac09 Changing to "import { buildDbAuthResponse } from '../shared'" fixes test run. I'll post the change
@@ -0,0 +1,69 @@ | |||
import { describe, it, expect } from 'vitest' | |||
|
|||
import { buildDbAuthResponse } from '/Users/dac09/Code/redwood/packages/auth-providers/dbAuth/api/src/shared' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import { buildDbAuthResponse } from '/Users/dac09/Code/redwood/packages/auth-providers/dbAuth/api/src/shared' | |
import { buildDbAuthResponse } from '../shared' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I committed the change FYI
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
…-dbauth-middleware * 'main' of github.com:redwoodjs/redwood: chore(location): Accept URL-like object (#10467) fix(router): Remove barrel exports from router.tsx (#10464) chore(dbauth-mw): Refactor web side dbAuth creation (#10460) chore(router): Prevent circular dependency for namedRoutes (#10463) chore(router): route-validators: Better types and clean up comments (#10462) feat(server-auth): dbAuth 3/3 - handle login, logout, signup, etc. requests if forwarded from middleware (#10457) docs(router): Document new NavLink className replacement behavior (#10401) chore(refactor): Split the router out into smaller logical units (#10434) feat(server-auth): Part 1/3: dbAuth middleware support (web side changes) (#10444) chore(auth): Build: Put ESM at the root, and CJS in /cjs (#10458) fix(ssr): Successfully serve static assets like `favicon.png` (#10455) chore(deps): update chore (#10367) (docs) Fix useCache headers and links (#10451) chore: remove aws-lambda (#10450) chore(deps): update dependency typescript to v5.4.5 (#10452) feat(og-gen): Update implementation of useLocation | Update App template (#10441) feat(og-gen): Adds package and vite plugin for dynamic og generation (#10439)
…g-gen-mw-p2 * 'main' of github.com:redwoodjs/redwood: chore(dbauth-mw): Refactor web side dbAuth creation (#10460) chore(router): Prevent circular dependency for namedRoutes (#10463) chore(router): route-validators: Better types and clean up comments (#10462) feat(server-auth): dbAuth 3/3 - handle login, logout, signup, etc. requests if forwarded from middleware (#10457) docs(router): Document new NavLink className replacement behavior (#10401) chore(refactor): Split the router out into smaller logical units (#10434) feat(server-auth): Part 1/3: dbAuth middleware support (web side changes) (#10444) chore(auth): Build: Put ESM at the root, and CJS in /cjs (#10458) fix(ssr): Successfully serve static assets like `favicon.png` (#10455) chore(deps): update chore (#10367) (docs) Fix useCache headers and links (#10451) chore: remove aws-lambda (#10450) chore(deps): update dependency typescript to v5.4.5 (#10452)
* 'main' of github.com:redwoodjs/redwood: Revert "chore(location): Accept URL-like object" (redwoodjs#10473) RSC: Be consistent about inlining rollup input (redwoodjs#10472) chore(paths): Remove outdated comment (redwoodjs#10471) feat(server-auth): Update getAuthenticationContext to support cookies and tokens both (redwoodjs#10465) chore(location): Accept URL-like object (redwoodjs#10467) fix(router): Remove barrel exports from router.tsx (redwoodjs#10464) chore(dbauth-mw): Refactor web side dbAuth creation (redwoodjs#10460) chore(router): Prevent circular dependency for namedRoutes (redwoodjs#10463) chore(router): route-validators: Better types and clean up comments (redwoodjs#10462) feat(server-auth): dbAuth 3/3 - handle login, logout, signup, etc. requests if forwarded from middleware (redwoodjs#10457) docs(router): Document new NavLink className replacement behavior (redwoodjs#10401) chore(refactor): Split the router out into smaller logical units (redwoodjs#10434) feat(server-auth): Part 1/3: dbAuth middleware support (web side changes) (redwoodjs#10444) chore(auth): Build: Put ESM at the root, and CJS in /cjs (redwoodjs#10458) fix(ssr): Successfully serve static assets like `favicon.png` (redwoodjs#10455) chore(deps): update chore (redwoodjs#10367) (docs) Fix useCache headers and links (redwoodjs#10451) chore: remove aws-lambda (redwoodjs#10450) chore(deps): update dependency typescript to v5.4.5 (redwoodjs#10452)
Closes #10448
This PR updates the DbAuthHandler class to handle requests forwarded from middleware, so it can generate responses for login, logout, signup, etc. These are POST requests - it used to be to the
/auth
function, but now they will be captured by dbAuth middleware and forwarded onto DbAuthHandler.High level changes:
Headers
class in each of the "method" responses. This allows us to set multi-value headers like Set-Cookie. A simple object would not. See typeAuthMethodOutput
buildResponse
into a testable function and adds test. ForSet-Cookie
headers we return an array of strings.In the middleware here's the code I had for the final conversion:
Tasks