-
Notifications
You must be signed in to change notification settings - Fork 982
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): Part 1/3: dbAuth middleware support (web side changes) #10444
Conversation
…ut graphql, using middleware
…th-mw-auth * 'main' of github.com:redwoodjs/redwood: (21 commits) fix(auth): Handle when authorization header is lowercased (#10442) Update rbac.md - code match (#10405) chore: make crwa e2e test work across branches (#10437) feat: [Auth] Common AuthProvider & use* changes for middleware auth (#10420) fix(cli): only show webpack options for dev if `bundler = "webpack"` (#10359) fix(vercel): specify build env vars as a string (#10436) fix(vercel): write `vercel.json` as a part of setup (#10355) fix(middleware): Handle POST requests in middleware router too (#10418) chore(ci): get ci running on next (#10432) RSC: Explain noExternal vite config option (#10429) chore(web): Fix .d.ts overwrite build issue (#10431) chore(web): .js imports to prep for ESM (#10430) chore(refactor): Split rwjs/forms up into several smaller logical units (#10428) chore(rsc): simplify `noExternals` config (#10220) chore(deps): Update vite to 5.2.8 (#10427) chore(auth): Convert `@redwoodjs/auth` to ESM+CJS dual build (#10417) chore(framework-tools): Warn about missing metafile (#10426) chore(test): Switch rwjs/auth over to vitest (#10423) chore(whatwg-fetch): Switch to importing instead of requiring (#10424) chore(deps): bump undici from 5.28.3 to 5.28.4 in /.github/actions/check_changesets (#10421) ...
@dthyresson removed the dbAuth handler from this PR. We just need to run a sanity check on your machine with the project. |
Add tests for middleware edition
Fix incorrect mocking
Update tests
@dthyresson welcome to do a sanity check on this, but I had a new idea that I want to run past you tomorrow! I think we can make it one less step - yesterday we added dbAuthClient.useMiddlewareAuth as a prop! Which means I think we don't need to call import {
createDbAuthClient,
- createMiddlewareAuth,
+ createAuth // just like before!
} from '@redwoodjs/auth-dbauth-web'
const dbAuthClient = createDbAuthClient({
middleware: true,
})
- export const { AuthProvider, useAuth } = createMiddlewareAuth(dbAuthClient)
+ export const { AuthProvider, useAuth } = createAuth(dbAuthClient) createAuth = (dbAuthClient) => {
if (dbAuthClient.useMiddleware) {
// do the middleware version
}
return createAuthentication(...)
} BUT..... it will make dbAuth inconsistent with the other providers, where you will still need to call |
@dthyresson and I discussed, and we are going to implement it like this suggestion: #10444 (comment) For other auth providers we are going to export a similar looking function: import { createAuth, createSupabaseAuthClient } from '@redwoodjs/auth-supabase-web'
// This function is new, and just wraps creating supabase👇
const supabaseClient = createSupabaseAuthClient({
supabaseUrl: process.env.SUPABASE_URL || '',
supabaseKey: process.env.SUPABASE_KEY || '',
middleware: true
})
export const { AuthProvider, useAuth } = createAuth(supabaseClient) This also means our users won't need to change where supabase client is imported from, for example. |
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 I confirmed that auth behaves as expected with classic GraphQL and blog tat project. LGTM.
…-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 #10445
Part 1/3: dbAuth middleware support
1. Updates dbAuthHandler to handle POST requests for login, logout, signup via the middlewaretaking this out of this PR, and going to PR separately.
2. Updates the dbAuth web client to speak to middleware instead of graphql
3. Implements fetching current user from middleware
What it does not have:
Before merging this:
- [ ] Validate webAuthN + graphql is not broken-[ ] Merge dbAuthHandler and tests again!Moved to separate PR