|
1 | 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP
|
2 | 2 |
|
| 3 | +exports[`Should add auth config when app is missing RedwoodApolloProvider Matches Auth0 Snapshot 1`] = ` |
| 4 | +"import { AuthProvider } from '@redwoodjs/auth' |
| 5 | +import { Auth0Client } from '@auth0/auth0-spa-js' |
| 6 | +import { FatalErrorBoundary, RedwoodProvider } from '@redwoodjs/web' |
| 7 | +
|
| 8 | +import FatalErrorPage from 'src/pages/FatalErrorPage' |
| 9 | +import Routes from 'src/Routes' |
| 10 | +
|
| 11 | +import './index.css' |
| 12 | +
|
| 13 | +const queryClient = {} |
| 14 | +
|
| 15 | +const auth0 = new Auth0Client({ |
| 16 | + domain: process.env.AUTH0_DOMAIN, |
| 17 | + client_id: process.env.AUTH0_CLIENT_ID, |
| 18 | + redirect_uri: process.env.AUTH0_REDIRECT_URI, |
| 19 | +
|
| 20 | + // ** NOTE ** Storing tokens in browser local storage provides persistence across page refreshes and browser tabs. |
| 21 | + // However, if an attacker can achieve running JavaScript in the SPA using a cross-site scripting (XSS) attack, |
| 22 | + // they can retrieve the tokens stored in local storage. |
| 23 | + // https://auth0.com/docs/libraries/auth0-spa-js#change-storage-options |
| 24 | + cacheLocation: 'localstorage', |
| 25 | + audience: process.env.AUTH0_AUDIENCE, |
| 26 | +
|
| 27 | + // @MARK: useRefreshTokens is required for automatically extending sessions |
| 28 | + // beyond that set in the initial JWT expiration. |
| 29 | + // |
| 30 | + // @MARK: https://auth0.com/docs/tokens/refresh-tokens |
| 31 | + // useRefreshTokens: true, |
| 32 | +}) |
| 33 | +
|
| 34 | +const App = () => ( |
| 35 | + <FatalErrorBoundary page={FatalErrorPage}> |
| 36 | + <RedwoodProvider titleTemplate=\\"%PageTitle | %AppTitle\\"> |
| 37 | + <AuthProvider client={auth0} type=\\"auth0\\"> |
| 38 | + <QueryClientProvider client={queryClient}> |
| 39 | + <RedwoodReactQueryProvider> |
| 40 | + <Routes /> |
| 41 | + </RedwoodReactQueryProvider> |
| 42 | + </QueryClientProvider> |
| 43 | + </AuthProvider> |
| 44 | + </RedwoodProvider> |
| 45 | + </FatalErrorBoundary> |
| 46 | +) |
| 47 | +
|
| 48 | +export default App |
| 49 | +" |
| 50 | +`; |
| 51 | + |
| 52 | +exports[`Should add auth config when using explicit return Matches Auth0 Snapshot 1`] = ` |
| 53 | +"import { AuthProvider } from '@redwoodjs/auth' |
| 54 | +import { Auth0Client } from '@auth0/auth0-spa-js' |
| 55 | +import { useEffect } from 'react' |
| 56 | +import { FatalErrorBoundary, RedwoodProvider } from '@redwoodjs/web' |
| 57 | +import { RedwoodApolloProvider } from '@redwoodjs/web/apollo' |
| 58 | +
|
| 59 | +import FatalErrorPage from 'src/pages/FatalErrorPage' |
| 60 | +import Routes from 'src/Routes' |
| 61 | +
|
| 62 | +import './index.css' |
| 63 | +
|
| 64 | +const auth0 = new Auth0Client({ |
| 65 | + domain: process.env.AUTH0_DOMAIN, |
| 66 | + client_id: process.env.AUTH0_CLIENT_ID, |
| 67 | + redirect_uri: process.env.AUTH0_REDIRECT_URI, |
| 68 | +
|
| 69 | + // ** NOTE ** Storing tokens in browser local storage provides persistence across page refreshes and browser tabs. |
| 70 | + // However, if an attacker can achieve running JavaScript in the SPA using a cross-site scripting (XSS) attack, |
| 71 | + // they can retrieve the tokens stored in local storage. |
| 72 | + // https://auth0.com/docs/libraries/auth0-spa-js#change-storage-options |
| 73 | + cacheLocation: 'localstorage', |
| 74 | + audience: process.env.AUTH0_AUDIENCE, |
| 75 | +
|
| 76 | + // @MARK: useRefreshTokens is required for automatically extending sessions |
| 77 | + // beyond that set in the initial JWT expiration. |
| 78 | + // |
| 79 | + // @MARK: https://auth0.com/docs/tokens/refresh-tokens |
| 80 | + // useRefreshTokens: true, |
| 81 | +}) |
| 82 | +
|
| 83 | +const App = (props) => { |
| 84 | + const { cache } = props |
| 85 | +
|
| 86 | + useEffect(() => { |
| 87 | + console.log('Running my custom useEffect hook on each render.') |
| 88 | + }) |
| 89 | +
|
| 90 | + return ( |
| 91 | + <FatalErrorBoundary page={FatalErrorPage}> |
| 92 | + <RedwoodProvider titleTemplate=\\"%PageTitle | %AppTitle\\"> |
| 93 | + <AuthProvider client={auth0} type=\\"auth0\\"> |
| 94 | + <RedwoodApolloProvider> |
| 95 | + <AnotherProvider> |
| 96 | + <Routes /> |
| 97 | + </AnotherProvider> |
| 98 | + </RedwoodApolloProvider> |
| 99 | + </AuthProvider> |
| 100 | + </RedwoodProvider> |
| 101 | + </FatalErrorBoundary> |
| 102 | + ) |
| 103 | +} |
| 104 | +
|
| 105 | +export default App |
| 106 | +" |
| 107 | +`; |
| 108 | + |
3 | 109 | exports[`Should add config lines to App.{js,tsx} Matches Auth0 Snapshot 1`] = `
|
4 | 110 | "import { AuthProvider } from '@redwoodjs/auth'
|
5 | 111 | import { Auth0Client } from '@auth0/auth0-spa-js'
|
@@ -357,3 +463,49 @@ const App = () => (
|
357 | 463 | export default App
|
358 | 464 | "
|
359 | 465 | `;
|
| 466 | + |
| 467 | +exports[`Should add config lines when RedwoodApolloProvider has props Matches Auth0 Snapshot 1`] = ` |
| 468 | +"import { AuthProvider } from '@redwoodjs/auth' |
| 469 | +import { Auth0Client } from '@auth0/auth0-spa-js' |
| 470 | +import { FatalErrorBoundary, RedwoodProvider } from '@redwoodjs/web' |
| 471 | +import { RedwoodApolloProvider } from '@redwoodjs/web/apollo' |
| 472 | +
|
| 473 | +import FatalErrorPage from 'src/pages/FatalErrorPage' |
| 474 | +import Routes from 'src/Routes' |
| 475 | +
|
| 476 | +import './index.css' |
| 477 | +
|
| 478 | +const auth0 = new Auth0Client({ |
| 479 | + domain: process.env.AUTH0_DOMAIN, |
| 480 | + client_id: process.env.AUTH0_CLIENT_ID, |
| 481 | + redirect_uri: process.env.AUTH0_REDIRECT_URI, |
| 482 | +
|
| 483 | + // ** NOTE ** Storing tokens in browser local storage provides persistence across page refreshes and browser tabs. |
| 484 | + // However, if an attacker can achieve running JavaScript in the SPA using a cross-site scripting (XSS) attack, |
| 485 | + // they can retrieve the tokens stored in local storage. |
| 486 | + // https://auth0.com/docs/libraries/auth0-spa-js#change-storage-options |
| 487 | + cacheLocation: 'localstorage', |
| 488 | + audience: process.env.AUTH0_AUDIENCE, |
| 489 | +
|
| 490 | + // @MARK: useRefreshTokens is required for automatically extending sessions |
| 491 | + // beyond that set in the initial JWT expiration. |
| 492 | + // |
| 493 | + // @MARK: https://auth0.com/docs/tokens/refresh-tokens |
| 494 | + // useRefreshTokens: true, |
| 495 | +}) |
| 496 | +
|
| 497 | +const App = () => ( |
| 498 | + <FatalErrorBoundary page={FatalErrorPage}> |
| 499 | + <RedwoodProvider titleTemplate=\\"%PageTitle | %AppTitle\\"> |
| 500 | + <AuthProvider client={auth0} type=\\"auth0\\"> |
| 501 | + <RedwoodApolloProvider graphQLClientConfig={{ cache }}> |
| 502 | + <Routes /> |
| 503 | + </RedwoodApolloProvider> |
| 504 | + </AuthProvider> |
| 505 | + </RedwoodProvider> |
| 506 | + </FatalErrorBoundary> |
| 507 | +) |
| 508 | +
|
| 509 | +export default App |
| 510 | +" |
| 511 | +`; |
0 commit comments