-
Notifications
You must be signed in to change notification settings - Fork 993
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 into feat/dc-rc-o…
…g-gen-mw-p2 * 'main' of github.com:redwoodjs/redwood: feat(og-gen): Adds package and vite plugin for dynamic og generation (#10439) chore(deps): bump browserify-sign from 4.2.1 to 4.2.3 (#10446) chore(deps): bump tar from 6.1.11 to 6.2.1 in /docs (#10438) chore(deps): update dependency firebase to v10.11.0 (#10366) 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)
- Loading branch information
Showing
22 changed files
with
684 additions
and
387 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,12 @@ | ||
- feat: [Auth] Common AuthProvider & use* changes for middleware auth #10420 by @dac09 and @dthyresson | ||
|
||
* First step of supporting Auth using middleware | ||
* Ensure backwards compatibility with non-SSR auth | ||
|
||
### Breaking Change | ||
|
||
Removes `skipFetchCurrentUser` which was used by the no longer existing nHost auth provider, but could potentially have been used by custom auth. | ||
|
||
|
||
|
||
|
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 @@ | ||
- feat(og-gen): Adds package and vite plugin for dynamic og generation (#10439) by @dac09 |
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,2 @@ | ||
- fix(auth): Handle when authorization header is lowercased (#10442) by @dac09 | ||
Handles when 'authorization' header is lowercased, and adds some extra tests. |
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
70 changes: 70 additions & 0 deletions
70
packages/api/src/auth/__tests__/parseAuthorizationHeader.test.ts
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,70 @@ | ||
import type { APIGatewayProxyEvent } from 'aws-lambda' | ||
import { test, expect, describe } from 'vitest' | ||
|
||
import { parseAuthorizationHeader } from '../index' | ||
|
||
describe('parseAuthorizationHeader', () => { | ||
test('throws error if Authorization header is not valid', () => { | ||
const invalidHeaders = [ | ||
undefined, | ||
null, | ||
'', | ||
'Bearer', | ||
'Bearer ', | ||
'Bearer token with spaces', | ||
'Token', | ||
'Token ', | ||
'Token token with spaces', | ||
] | ||
|
||
invalidHeaders.forEach((header) => { | ||
expect(() => | ||
// @ts-expect-error That's what we're testing | ||
parseAuthorizationHeader({ headers: { Authorization: header } }), | ||
).toThrowError('The `Authorization` header is not valid.') | ||
}) | ||
}) | ||
|
||
test('returns the schema and token from valid Authorization header', () => { | ||
const validHeaders = [ | ||
'Bearer token', | ||
'Bearer 12345', | ||
'Token token', | ||
'Token 12345', | ||
] | ||
|
||
validHeaders.forEach((header) => { | ||
// We only care about the headers in the event | ||
const result = parseAuthorizationHeader({ | ||
headers: { Authorization: header }, | ||
} as unknown as APIGatewayProxyEvent) | ||
|
||
expect(result).toEqual({ | ||
schema: header.split(' ')[0], | ||
token: header.split(' ')[1], | ||
}) | ||
}) | ||
}) | ||
|
||
test('Handles different lower-casing of the authorization header', () => { | ||
const result = parseAuthorizationHeader({ | ||
headers: { authorization: 'Bearer bazinga' }, | ||
} as unknown as APIGatewayProxyEvent) | ||
|
||
expect(result).toEqual({ | ||
schema: 'Bearer', | ||
token: 'bazinga', | ||
}) | ||
}) | ||
|
||
test('Handles different capital-casing of the Authorization header', () => { | ||
const result = parseAuthorizationHeader({ | ||
headers: { Authorization: 'Bearer bazinga' }, | ||
} as unknown as APIGatewayProxyEvent) | ||
|
||
expect(result).toEqual({ | ||
schema: 'Bearer', | ||
token: 'bazinga', | ||
}) | ||
}) | ||
}) |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
!src/__fixtures__/**/dist |
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,3 @@ | ||
import { build } from '@redwoodjs/framework-tools' | ||
|
||
await build() |
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,3 @@ | ||
/* eslint-env node */ | ||
|
||
module.exports = require('../dist/vite-plugin-ogimage-gen.js').default |
Oops, something went wrong.