├── .editorconfig ├── .env.example ├── .github └── ISSUE_TEMPLATE │ └── config.yml ├── .gitignore ├── LICENSE ├── README.md ├── assets └── main.css ├── components ├── ForkThis.vue ├── Navbar.vue └── SuperSecretDiv.vue ├── layouts └── default.vue ├── now.json ├── nuxt.config.js ├── package.json ├── pages ├── about.vue ├── auth │ └── signed-in.vue ├── index.vue └── secret.vue ├── renovate.json ├── store └── index.js └── yarn.lock /.editorconfig: -------------------------------------------------------------------------------- 1 | # editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_size = 2 6 | indent_style = space 7 | end_of_line = lf 8 | charset = utf-8 9 | trim_trailing_whitespace = true 10 | insert_final_newline = true 11 | 12 | [*.md] 13 | trim_trailing_whitespace = false 14 | -------------------------------------------------------------------------------- /.env.example: -------------------------------------------------------------------------------- 1 | AUTH0_CLIENT_ID="" 2 | AUTH0_DOMAIN="" 3 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | contact_links: 3 | - name: 🚨 Bug report 4 | url: https://cmty.app/nuxt/issues/new?type=bug-report&repo=example-auth0 5 | about: | 6 | Please report bugs here. 7 | - name: 🙋 Feature request 8 | url: https://cmty.app/nuxt/issues/new?type=feature-request&repo=example-auth0 9 | about: | 10 | Please request features here. 11 | - name: 🤔 Consulting from the Nuxt team 12 | url: https://otechie.com/nuxt 13 | about: | 14 | Get technical support, project audits, app deployments, and custom development from the core Nuxt.js team. 15 | - name: ❗️ All other issues | 其他问题 16 | url: https://cmty.app/nuxt/issues/new?repo=example-auth0 17 | about: | 18 | Please create all other issues here. 19 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # dependencies 2 | node_modules 3 | 4 | # logs 5 | npm-debug.log 6 | 7 | # Nuxt build 8 | .nuxt 9 | 10 | # Nuxt generate 11 | dist 12 | 13 | # Auth0 config 14 | .env 15 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017-2020 NuxtJS Team 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # nuxt-auth0 2 | 3 | > A simple example that shows how to use [Nuxt.js](https://nuxtjs.org) with [Auth0](https://auth0.com) 4 | 5 | ![nuxt-auth0](https://cloud.githubusercontent.com/assets/904724/22703834/d971838c-ed65-11e6-90f9-5ecf2a1be5f0.gif) 6 | 7 | You can access a simple demo here: https://auth0.nuxtjs.org 8 | 9 | ## Setup 10 | 11 | * Create an account at Auth0 (https://auth0.com) 12 | * Add your endpoints to your client's allowed urls like this ![nuxt-callbacks](https://cloud.githubusercontent.com/assets/904724/22703633/23f35724-ed65-11e6-83e4-227ad77c00ff.png) 13 | * Add your logout endpoint to your account allowed urls like this ![nuxt-logout-cb](https://cloud.githubusercontent.com/assets/904724/22703768/9782bbbc-ed65-11e6-93b7-9c1e4d5d7984.png) 14 | 15 | * Copy the file `.env.example` at the root folder, rename it as `.env` and add your Auth0 keys 16 | 17 | ## Running Locally 18 | 19 | ``` 20 | git clone https://github.com/nuxt/example-auth0.git 21 | cd example-auth0 22 | npm install 23 | npm run dev 24 | ``` 25 | 26 | -------------------------------------------------------------------------------- /assets/main.css: -------------------------------------------------------------------------------- 1 | * { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif; 4 | } 5 | 6 | h1 { 7 | font-size: 40px; 8 | font-weight: 200; 9 | line-height: 40px; 10 | } 11 | p { 12 | font-size: 20px; 13 | font-weight: 200; 14 | line-height: 30px; 15 | } 16 | a { 17 | color: #333; 18 | padding-bottom: 2px; 19 | border-bottom: 1px solid #ccc; 20 | text-decoration: none; 21 | font-weight: 400; 22 | line-height: 30px; 23 | transition: border-bottom .2s; 24 | cursor: pointer; 25 | } 26 | a:hover { 27 | border-bottom-color: #333; 28 | } 29 | -------------------------------------------------------------------------------- /components/ForkThis.vue: -------------------------------------------------------------------------------- 1 | 12 | 13 | 48 | -------------------------------------------------------------------------------- /components/Navbar.vue: -------------------------------------------------------------------------------- 1 | 10 | 11 | 18 | 19 | 49 | -------------------------------------------------------------------------------- /components/SuperSecretDiv.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 22 | -------------------------------------------------------------------------------- /layouts/default.vue: -------------------------------------------------------------------------------- 1 | 10 | 11 | 22 | 23 | 34 | -------------------------------------------------------------------------------- /now.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 2, 3 | "builds": [ 4 | { 5 | "src": "nuxt.config.js", 6 | "use": "@nuxtjs/now-builder" 7 | } 8 | ], 9 | "build": { 10 | "env": { 11 | "AUTH0_DOMAIN": "@auth0-domain", 12 | "AUTH0_CLIENT_ID": "@auth0-client-id" 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /nuxt.config.js: -------------------------------------------------------------------------------- 1 | import 'dotenv/config' 2 | 3 | export default { 4 | /* 5 | ** Headers of the page 6 | */ 7 | head: { 8 | title: 'Nuxt.js + Auth0', 9 | meta: [ 10 | { charset: 'utf-8' }, 11 | { name: 'viewport', content: 'width=device-width, initial-scale=1' }, 12 | { hid: 'description', name: 'description', content: 'Nuxt.js project' } 13 | ], 14 | link: [ 15 | { rel: 'icon', type: 'image/x-icon', href: 'https://nuxtjs.org/favicon.ico' } 16 | ] 17 | }, 18 | /* 19 | ** Global CSS 20 | */ 21 | css: [ 22 | 'normalize.css', 23 | '@/assets/main.css' 24 | ], 25 | /* 26 | ** Modules 27 | */ 28 | modules: [ 29 | // axios is required by @nuxtjs/auth 30 | '@nuxtjs/axios', 31 | // https://auth.nuxtjs.org 32 | '@nuxtjs/auth' 33 | ], 34 | auth: { 35 | redirect: { 36 | login: '/', // redirect user when not connected 37 | callback: '/auth/signed-in' 38 | }, 39 | strategies: { 40 | local: false, 41 | auth0: { 42 | domain: process.env.AUTH0_DOMAIN, 43 | client_id: process.env.AUTH0_CLIENT_ID 44 | } 45 | } 46 | }, 47 | build: { 48 | // For stormkit.io 49 | publicPath: process.env.PUBLIC_PATH, 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nuxt-auth0", 3 | "version": "1.0.0", 4 | "description": "Nuxt.js + Auth0", 5 | "author": "NuxtJS Team", 6 | "private": true, 7 | "scripts": { 8 | "dev": "nuxt", 9 | "build": "nuxt build", 10 | "start": "nuxt-start" 11 | }, 12 | "dependencies": { 13 | "@nuxtjs/auth": "^4.9.1", 14 | "@nuxtjs/axios": "^5.12.2", 15 | "dotenv": "^8.2.0", 16 | "normalize.css": "^8.0.1", 17 | "nuxt-start": "^2.14.3" 18 | }, 19 | "devDependencies": { 20 | "nuxt": "^2.14.3" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /pages/about.vue: -------------------------------------------------------------------------------- 1 | 7 | -------------------------------------------------------------------------------- /pages/auth/signed-in.vue: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /pages/index.vue: -------------------------------------------------------------------------------- 1 | 18 | 19 | 28 | 29 | 36 | -------------------------------------------------------------------------------- /pages/secret.vue: -------------------------------------------------------------------------------- 1 | 8 | 9 | 19 | 20 | 32 | -------------------------------------------------------------------------------- /renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "@nuxtjs" 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /store/index.js: -------------------------------------------------------------------------------- 1 | // Enable store for auth module 2 | --------------------------------------------------------------------------------