Skip to content

Commit

Permalink
Merge branch 'main' of github.com:redwoodjs/redwood into feat/vite-ssr
Browse files Browse the repository at this point in the history
* 'main' of github.com:redwoodjs/redwood: (21 commits)
  chore(deps): update dependency @types/uuid to v9.0.1 (redwoodjs#7680)
  chore(deps): update dependency @replayio/playwright to v0.3.23 (redwoodjs#7677)
  chore(deps): update dependency @npmcli/arborist to v6.2.3 (redwoodjs#7675)
  chore(deps): update dependency @envelop/types to v3.0.2 (redwoodjs#7674)
  chore: add codemod for clerk fix in v4.2.0 (redwoodjs#7676)
  chore(deps): update dependency @clerk/types to v3.28.1 (redwoodjs#7652)
  chore(deps): update dependency @envelop/testing to v5.0.6 (redwoodjs#7673)
  Update directives.md (redwoodjs#7670)
  fix(deps): update dependency vscode-languageserver-types to v3.17.3 (redwoodjs#7636)
  Fix `yarn rw exec` to set nonzero exit code on error (redwoodjs#7660)
  fix(deps): update dependency core-js to v3.28.0 (redwoodjs#7666)
  fix(deps): update dependency @clerk/clerk-sdk-node to v4.7.4 (redwoodjs#7663)
  fix(deps): update dependency vite to v4.1.3 (redwoodjs#7664)
  fix(deps): update dependency @fastify/url-data to v5.3.1 (redwoodjs#7665)
  fix(deps): update dependency yargs to v17.7.1 (redwoodjs#7667)
  fix(clerk): Remove privateMetadata property from getCurrentUser (redwoodjs#7668)
  chore(deps): update dependency esbuild to v0.17.10 (redwoodjs#7662)
  chore(deps): bump setup of Chakra UI to V2 (redwoodjs#7649)
  Forms: Export EmptyAsValue (redwoodjs#7656)
  Update useRequireAuth docs to v4 auth (redwoodjs#7646)
  ...
  • Loading branch information
dac09 committed Feb 27, 2023
2 parents e067bd3 + da0bc32 commit 808107b
Show file tree
Hide file tree
Showing 58 changed files with 680 additions and 325 deletions.
2 changes: 1 addition & 1 deletion docs/docs/directives.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ type user {

and if the `currentUser` is an `ADMIN`, then skip the masking transform and simply return the original resolved field value:

```jsx title="./api/directives/maskedEmail.directive.js"
```jsx title="./api/src/directives/maskedEmail.directive.js"
import { createTransformerDirective, TransformerDirectiveFunc } from '@redwoodjs/graphql-server'

export const schema = gql`
Expand Down
19 changes: 8 additions & 11 deletions docs/docs/serverless-functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -742,13 +742,16 @@ The `useRequireAuth` wrapper configures your handler's `context` so that you can

- import `useRequireAuth` from `@redwoodjs/graphql-server`
- import your app's custom `getCurrentUser` and the `isAuthenticated` check from `src/lib/auth`
- import your auth provider's `authDecoder`
- implement your serverless function as you would, but do not `export` it (see `myHandler` below).
- pass your implementation and `getCurrentUser` to the `useRequireAuth` wrapper and export its return
- pass your implementation, `getCurrentUser` and `authDecoder` to the `useRequireAuth` wrapper and export its return
- check if the user `isAuthenticated()` and, if not, handle the unauthenticated case by returning a `401` status code (for example)

```tsx
import type { APIGatewayEvent, Context } from 'aws-lambda'

// highlight-next-line
import { authDecoder } from '@redwoodjs/auth-dbauth-api'
// highlight-next-line
import { useRequireAuth } from '@redwoodjs/graphql-server'

Expand All @@ -772,20 +775,21 @@ const myHandler = async (event: APIGatewayEvent, context: Context) => {
data: 'myHandler function',
}),
}
// highlight-start
} else {
// highlight-start
logger.error('Access to myHandler was denied')

return {
statusCode: 401,
}
// highlight-end
}
// highlight-end
}

export const handler = useRequireAuth({
handlerFn: myHandler,
getCurrentUser,
authDecoder,
})
```

Expand All @@ -805,17 +809,10 @@ As there is no login flow when using functions, the `useRequireAuth` check assum

In your request, you must include the following headers:

- the auth provider type that your application is using
- the auth provider type that your application is using, e.g. `dbAuth`
- the Bearer token (JWT access token)
- if using dbAuth, then also the dbAuth Cookie

You can find the auth provider type as the `type` attribute set on the `AuthProvider`:

```jsx
<AuthProvider client={netlifyIdentity} type="netlify">
<AuthProvider client={supabaseClient} type="supabase">
```

For example:

```bash
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/tutorial/chapter6/the-redwood-way.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export default {
</TabItem>
<TabItem value="ts" label="TypeScript">

```tsx title="web/src/components/Comment/Comment.stories.txs"
```tsx title="web/src/components/Comment/Comment.stories.tsx"
import Comment from './Comment'

export const generated = () => {
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"vscode-languageserver": "6.1.1",
"vscode-languageserver-protocol": "3.15.3",
"vscode-languageserver-textdocument": "1.0.8",
"vscode-languageserver-types": "3.17.2"
"vscode-languageserver-types": "3.17.3"
},
"devDependencies": {
"@actions/core": "1.10.0",
Expand All @@ -49,10 +49,10 @@
"@babel/preset-react": "7.18.6",
"@babel/preset-typescript": "7.18.6",
"@babel/runtime-corejs3": "7.20.13",
"@npmcli/arborist": "6.2.2",
"@npmcli/arborist": "6.2.3",
"@nrwl/nx-cloud": "15.0.3",
"@playwright/test": "1.30.0",
"@replayio/playwright": "0.3.21",
"@replayio/playwright": "0.3.23",
"@testing-library/jest-dom": "5.16.5",
"@testing-library/react": "13.4.0",
"@testing-library/user-event": "14.4.3",
Expand All @@ -70,7 +70,7 @@
"babel-plugin-auto-import": "1.1.0",
"babel-plugin-remove-code": "0.0.6",
"boxen": "5.1.2",
"core-js": "3.27.2",
"core-js": "3.28.0",
"cypress": "12.5.1",
"cypress-wait-until": "1.7.2",
"eslint": "8.34.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/api-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@
"@babel/runtime-corejs3": "7.20.13",
"@fastify/http-proxy": "8.4.0",
"@fastify/static": "6.9.0",
"@fastify/url-data": "5.2.0",
"@fastify/url-data": "5.3.1",
"ansi-colors": "4.1.3",
"chalk": "4.1.2",
"chokidar": "3.5.3",
"core-js": "3.27.2",
"core-js": "3.28.0",
"fast-json-parse": "1.0.3",
"fastify": "4.13.0",
"fastify-raw-body": "4.2.0",
Expand All @@ -45,7 +45,7 @@
"pretty-ms": "7.0.1",
"qs": "6.11.0",
"split2": "4.1.0",
"yargs": "17.6.2"
"yargs": "17.7.1"
},
"devDependencies": {
"@babel/cli": "7.20.7",
Expand Down
2 changes: 1 addition & 1 deletion packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"@babel/runtime-corejs3": "7.20.13",
"@prisma/client": "4.10.1",
"@whatwg-node/fetch": "0.8.1",
"core-js": "3.27.2",
"core-js": "3.28.0",
"humanize-string": "2.1.0",
"jsonwebtoken": "9.0.0",
"pascalcase": "1.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-providers/auth0/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
},
"dependencies": {
"@babel/runtime-corejs3": "7.20.13",
"core-js": "3.27.2",
"core-js": "3.28.0",
"jsonwebtoken": "9.0.0",
"jwks-rsa": "3.0.1"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-providers/auth0/setup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"dependencies": {
"@babel/runtime-corejs3": "7.20.13",
"@redwoodjs/cli-helpers": "4.0.0",
"core-js": "3.27.2"
"core-js": "3.28.0"
},
"devDependencies": {
"@babel/cli": "7.20.7",
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-providers/auth0/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"dependencies": {
"@babel/runtime-corejs3": "7.20.13",
"@redwoodjs/auth": "4.0.0",
"core-js": "3.27.2"
"core-js": "3.28.0"
},
"devDependencies": {
"@auth0/auth0-spa-js": "1.22.6",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
},
"dependencies": {
"@babel/runtime-corejs3": "7.20.13",
"core-js": "3.27.2",
"core-js": "3.28.0",
"jsonwebtoken": "9.0.0",
"jwks-rsa": "3.0.1"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"dependencies": {
"@babel/runtime-corejs3": "7.20.13",
"@redwoodjs/cli-helpers": "4.0.0",
"core-js": "3.27.2"
"core-js": "3.28.0"
},
"devDependencies": {
"@babel/cli": "7.20.7",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"dependencies": {
"@babel/runtime-corejs3": "7.20.13",
"@redwoodjs/auth": "4.0.0",
"core-js": "3.27.2"
"core-js": "3.28.0"
},
"devDependencies": {
"@azure/msal-browser": "2.33.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/auth-providers/clerk/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
},
"dependencies": {
"@babel/runtime-corejs3": "7.20.13",
"@clerk/clerk-sdk-node": "4.7.3",
"core-js": "3.27.2"
"@clerk/clerk-sdk-node": "4.7.4",
"core-js": "3.28.0"
},
"devDependencies": {
"@babel/cli": "7.20.7",
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-providers/clerk/setup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"dependencies": {
"@babel/runtime-corejs3": "7.20.13",
"@redwoodjs/cli-helpers": "4.0.0",
"core-js": "3.27.2"
"core-js": "3.28.0"
},
"devDependencies": {
"@babel/cli": "7.20.7",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,14 @@ export const getCurrentUser = async (

const { roles } = parseJWT({ decoded })

// Remove privateMetadata property from CurrentUser as it should not be accessible on the web
const { privateMetadata, ...userWithoutPrivateMetadata } = decoded

if (roles) {
return { ...decoded, roles }
return { ...userWithoutPrivateMetadata, roles }
}

return { ...decoded }
return { ...userWithoutPrivateMetadata }
}

/**
Expand Down
4 changes: 2 additions & 2 deletions packages/auth-providers/clerk/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
"dependencies": {
"@babel/runtime-corejs3": "7.20.13",
"@redwoodjs/auth": "4.0.0",
"core-js": "3.27.2"
"core-js": "3.28.0"
},
"devDependencies": {
"@babel/cli": "7.20.7",
"@babel/core": "7.20.12",
"@clerk/clerk-react": "4.11.3",
"@clerk/types": "3.27.0",
"@clerk/types": "3.28.1",
"@types/react": "18.0.28",
"jest": "29.4.2",
"react": "18.2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-providers/custom/setup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"dependencies": {
"@babel/runtime-corejs3": "7.20.13",
"@redwoodjs/cli-helpers": "4.0.0",
"core-js": "3.27.2"
"core-js": "3.28.0"
},
"devDependencies": {
"@babel/cli": "7.20.7",
Expand Down
4 changes: 2 additions & 2 deletions packages/auth-providers/dbAuth/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"dependencies": {
"@babel/runtime-corejs3": "7.20.13",
"base64url": "3.0.1",
"core-js": "3.27.2",
"core-js": "3.28.0",
"crypto-js": "4.1.1",
"md5": "2.3.0",
"uuid": "9.0.0"
Expand All @@ -36,7 +36,7 @@
"@simplewebauthn/server": "6.2.2",
"@types/crypto-js": "4.1.1",
"@types/md5": "2.3.2",
"@types/uuid": "9.0.0",
"@types/uuid": "9.0.1",
"jest": "29.4.2",
"typescript": "4.9.5"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-providers/dbAuth/setup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"@babel/runtime-corejs3": "7.20.13",
"@redwoodjs/cli-helpers": "4.0.0",
"@simplewebauthn/browser": "6.2.2",
"core-js": "3.27.2",
"core-js": "3.28.0",
"prompts": "2.4.2",
"secure-random-password": "0.2.3",
"terminal-link": "2.1.1"
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-providers/dbAuth/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"@babel/runtime-corejs3": "7.20.13",
"@redwoodjs/auth": "4.0.0",
"@simplewebauthn/browser": "6.2.2",
"core-js": "3.27.2"
"core-js": "3.28.0"
},
"devDependencies": {
"@babel/cli": "7.20.7",
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-providers/firebase/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
},
"dependencies": {
"@babel/runtime-corejs3": "7.20.13",
"core-js": "3.27.2",
"core-js": "3.28.0",
"firebase-admin": "10.3.0"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-providers/firebase/setup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"dependencies": {
"@babel/runtime-corejs3": "7.20.13",
"@redwoodjs/cli-helpers": "4.0.0",
"core-js": "3.27.2"
"core-js": "3.28.0"
},
"devDependencies": {
"@babel/cli": "7.20.7",
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-providers/firebase/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"dependencies": {
"@babel/runtime-corejs3": "7.20.13",
"@redwoodjs/auth": "4.0.0",
"core-js": "3.27.2"
"core-js": "3.28.0"
},
"devDependencies": {
"@babel/cli": "7.20.7",
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-providers/netlify/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
},
"dependencies": {
"@babel/runtime-corejs3": "7.20.13",
"core-js": "3.27.2",
"core-js": "3.28.0",
"jsonwebtoken": "9.0.0"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-providers/netlify/setup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"dependencies": {
"@babel/runtime-corejs3": "7.20.13",
"@redwoodjs/cli-helpers": "4.0.0",
"core-js": "3.27.2"
"core-js": "3.28.0"
},
"devDependencies": {
"@babel/cli": "7.20.7",
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-providers/netlify/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"dependencies": {
"@babel/runtime-corejs3": "7.20.13",
"@redwoodjs/auth": "4.0.0",
"core-js": "3.27.2"
"core-js": "3.28.0"
},
"devDependencies": {
"@babel/cli": "7.20.7",
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-providers/supabase/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
},
"dependencies": {
"@babel/runtime-corejs3": "7.20.13",
"core-js": "3.27.2",
"core-js": "3.28.0",
"jsonwebtoken": "9.0.0"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-providers/supabase/setup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"dependencies": {
"@babel/runtime-corejs3": "7.20.13",
"@redwoodjs/cli-helpers": "4.0.0",
"core-js": "3.27.2"
"core-js": "3.28.0"
},
"devDependencies": {
"@babel/cli": "7.20.7",
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-providers/supabase/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
},
"dependencies": {
"@babel/runtime-corejs3": "7.20.13",
"core-js": "3.27.2"
"core-js": "3.28.0"
},
"devDependencies": {
"@babel/cli": "7.20.7",
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-providers/supertokens/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
},
"dependencies": {
"@babel/runtime-corejs3": "7.20.13",
"core-js": "3.27.2",
"core-js": "3.28.0",
"jsonwebtoken": "9.0.0",
"jwks-rsa": "3.0.1"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-providers/supertokens/setup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"dependencies": {
"@babel/runtime-corejs3": "7.20.13",
"@redwoodjs/cli-helpers": "4.0.0",
"core-js": "3.27.2"
"core-js": "3.28.0"
},
"devDependencies": {
"@babel/cli": "7.20.7",
Expand Down
Loading

0 comments on commit 808107b

Please sign in to comment.