forked from redwoodjs/redwood
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:redwoodjs/redwood
* '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)
- Loading branch information
Showing
127 changed files
with
2,104 additions
and
1,296 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
- feat(server-auth): Part 1/3: dbAuth middleware support (web side changes) (#10444) by @dac09 | ||
Adds ability to `createMiddlewareAuth` in dbAuth client which: | ||
1. Updates the dbAuth web client to speak to middleware instead of graphql | ||
2. Implements fetching current user from middleware |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
- feat(server-auth): dbAuth 3/3 - handle login, logout, signup, etc. requests if forwarded from middleware (#10457) by @dac09 | ||
|
||
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:** | ||
- use the `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 type `AuthMethodOutput` | ||
- extracts `buildResponse` into a testable function and adds test. For `Set-Cookie` headers we return an array of strings. | ||
|
||
In the middleware here's the code I had for the final conversion: | ||
```ts | ||
if (AUTHHANDLER_REQUEST) { | ||
const output = await dbAuthHandler(req) | ||
|
||
const finalHeaders = new Headers() | ||
Object.entries(output.headers).forEach(([key, value]) => { | ||
if (Array.isArray(value)) { | ||
value.forEach((v) => finalHeaders.append(key, v)) | ||
} else { | ||
finalHeaders.append(key, value) | ||
} | ||
}) | ||
|
||
return new MiddlewareResponse(output.body, { | ||
headers: finalHeaders, | ||
status: output.statusCode, | ||
}) | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
- chore(dbauth-mw): Refactor web side dbAuth creation (#10460) by @dac09 | ||
|
||
This PR changes how the webside auth is initialised, by removing the `createMiddlewareAuth` function, instead it just detects it internally. | ||
|
||
For dbAuth this is what it will looks like: | ||
|
||
```js:web/src/auth.ts | ||
import { | ||
createDbAuthClient, | ||
createAuth, | ||
} from '@redwoodjs/auth-dbauth-web' | ||
|
||
const dbAuthClient = createDbAuthClient({ | ||
middleware: true, | ||
}) | ||
|
||
// Internally we know to use the middleware version of the client | ||
// because middleware is set to true above! | ||
export const { AuthProvider, useAuth } = createAuth(dbAuthClient) | ||
|
||
``` | ||
|
||
For other auth providers we are going to export a similar looking function: | ||
|
||
```js | ||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
- fix(router): Remove barrel exports from router.tsx (#10464) by @Tobbe | ||
|
||
We were using both `index.ts` and `router.tsx` as barrel export files. We | ||
should move away from barrel exports at some point, and we definitely don't | ||
need two files doing it in the same package. Everything that was exported from | ||
`router.tsx` is already exported by other files (except `Router` itself). So I | ||
updated the code to import from there directly instead. | ||
|
||
This is a breaking change for anyone who does | ||
`import ... from '@redwoodjs/router/dist/router'` in their project. Which | ||
hopefully isn't very many. | ||
- The quick fix is to find the original export and pull from there instead | ||
- The real fix is to talk to us on the core team and see if we can provide an | ||
official way of solving it instead of relying on internal implementation | ||
details 🙂 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
- feat(server-auth): Update getAuthenticationContext to support cookies and tokens both (#10465) by @dac09 | ||
|
||
**1. Updates `getAuthenticationContext` to parse the cookie header and pass it to authDecoder.** | ||
|
||
Note that the authentication context itself does not pull out the token from cookies, because with some providers (e.g. supabase) - we don't know the name of the cookie. This is left to the authDecoder implementation. | ||
|
||
The return type from this function is actually just a deserialized cookie header i.e. | ||
`cookie: auth-provider=one; session=xx/yy/zz; somethingElse=bsbs` => `{ 'auth-provider': 'one', session: 'xx/yy/zz', somethingElse: 'bsbs'` | ||
|
||
**2. Retains support for header/token based auth** | ||
See test on line 259 of `packages/api/src/auth/__tests__/getAuthenticationContext.test.ts`. If a the `authorization` and `auth-provider` headers are passed in the request (as we do for SPA based auth) - then cookies will take precedence. | ||
|
||
The end result is that graphql requests will now work with middleware-based auth providers! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,7 +38,7 @@ | |
"devDependencies": { | ||
"@docusaurus/module-type-aliases": "3.1.1", | ||
"@docusaurus/tsconfig": "3.1.1", | ||
"typescript": "5.4.3" | ||
"typescript": "5.4.5" | ||
}, | ||
"packageManager": "[email protected]" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.