Update auth0 sample: bump dependencies and improve config management (#9778)

* Update auth0 sample: bump dependencies and improve config management

* Fixed linter

* Fix symlink
This commit is contained in:
Sandrino Di Mattia 2019-12-18 20:16:00 +01:00 committed by Luis Alvarez D
parent a7e96706fc
commit d0424d201d
4 changed files with 41 additions and 12 deletions

View file

@ -2,6 +2,8 @@
This example shows how you can use `@auth0/nextjs-auth` to easily add authentication support to your Next.js application.
Read more: [https://auth0.com/blog/ultimate-guide-nextjs-authentication-auth0/](https://auth0.com/blog/ultimate-guide-nextjs-authentication-auth0/)
### Using `create-next-app`
Execute [`create-next-app`](https://github.com/zeit/next.js/tree/canary/packages/create-next-app) with [Yarn](https://yarnpkg.com/lang/en/docs/cli/create/) or [npx](https://github.com/zkat/npx#readme) to bootstrap the example:

View file

@ -1,14 +1,15 @@
import { initAuth0 } from '@auth0/nextjs-auth0'
import config from './config'
export default initAuth0({
clientId: process.env.AUTH0_CLIENT_ID,
clientSecret: process.env.AUTH0_CLIENT_SECRET,
scope: process.env.AUTH0_SCOPE,
domain: process.env.AUTH0_DOMAIN,
redirectUri: process.env.REDIRECT_URI,
postLogoutRedirectUri: process.env.POST_LOGOUT_REDIRECT_URI,
clientId: config.AUTH0_CLIENT_ID,
clientSecret: config.AUTH0_CLIENT_SECRET,
scope: config.AUTH0_SCOPE,
domain: config.AUTH0_DOMAIN,
redirectUri: config.REDIRECT_URI,
postLogoutRedirectUri: config.POST_LOGOUT_REDIRECT_URI,
session: {
cookieSecret: process.env.SESSION_COOKIE_SECRET,
cookieLifetime: process.env.SESSION_COOKIE_LIFETIME,
cookieSecret: config.SESSION_COOKIE_SECRET,
cookieLifetime: config.SESSION_COOKIE_LIFETIME,
},
})

View file

@ -0,0 +1,26 @@
if (typeof window === 'undefined') {
/**
* Settings exposed to the server.
*/
module.exports = {
AUTH0_CLIENT_ID: process.env.AUTH0_CLIENT_ID,
AUTH0_CLIENT_SECRET: process.env.AUTH0_CLIENT_SECRET,
AUTH0_SCOPE: process.env.AUTH0_SCOPE,
AUTH0_DOMAIN: process.env.AUTH0_DOMAIN,
REDIRECT_URI: process.env.REDIRECT_URI,
POST_LOGOUT_REDIRECT_URI: process.env.POST_LOGOUT_REDIRECT_URI,
SESSION_COOKIE_SECRET: process.env.SESSION_COOKIE_SECRET,
SESSION_COOKIE_LIFETIME: process.env.SESSION_COOKIE_LIFETIME,
}
} else {
/**
* Settings exposed to the client.
*/
module.exports = {
AUTH0_CLIENT_ID: process.env.AUTH0_CLIENT_ID,
AUTH0_SCOPE: process.env.AUTH0_SCOPE,
AUTH0_DOMAIN: process.env.AUTH0_DOMAIN,
REDIRECT_URI: process.env.REDIRECT_URI,
POST_LOGOUT_REDIRECT_URI: process.env.POST_LOGOUT_REDIRECT_URI,
}
}

View file

@ -8,11 +8,11 @@
"author": "",
"license": "MIT",
"dependencies": {
"@auth0/nextjs-auth0": "0.4.0",
"dotenv": "^8.1.0",
"@auth0/nextjs-auth0": "^0.6.0",
"dotenv": "^8.2.0",
"isomorphic-unfetch": "^3.0.0",
"next": "latest",
"react": "^16.9.0",
"react-dom": "^16.9.0"
"react": "^16.12.0",
"react-dom": "^16.12.0"
}
}