nuxt / example-auth0 Goto Github PK
View Code? Open in Web Editor NEWA simple example that shows how to use Nuxt.js with Auth0.
Home Page: https://auth0.nuxtjs.org
License: MIT License
A simple example that shows how to use Nuxt.js with Auth0.
Home Page: https://auth0.nuxtjs.org
License: MIT License
hey! in this repo, i see parameter 'redirect' in anonymous.js, and i think
redirect('/')
is go to new page, in my own nuxt.js project, when i add this 'redirect' parameter, like
export default function( { context, redirect} ){}...
, it will say "Cannot read property 'route' of undefined",Where is wrong? How do I do page jumps in middleware?
and sorry my for my poor english.
I try to follow the README.md and install the project locally. So i run npm install
and it throws me the following error in the console:
npm install
npm WARN deprecated [email protected]: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.
npm ERR! Unexpected end of JSON input while parsing near '...4.0","lodash.uniq":"^'
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/enux/.npm/_logs/2020-01-29T12_48_51_713Z-debug.log
Clone the repository:
git clone https://github.com/nuxt/example-auth0.git
cd example-auth0
Install the dependencies:
npm install
The core-js
dependency should be updated inside the package.json
, package-lock.json
and yarn.json
.
https://github.com/christianechevarria/example-auth0
Vuex store updates with auth values
User is redirected to home and can't access auth protected routes, but when tries to sign-in is already signed-in
This is likely related to this nuxt-community/auth-module#893 (see the note about SSG) but I wanted to add this as an issue in case anyone else runs into this problem.
To install them, you can run: npm install --save ~/config.json ~components/ForkThis ~components/Navbar ~components/SuperSecretDiv
When I execute the command“npm install”"npm run dev",What happened?
When trying to install dependencies with Yarn, the install command fails, because it cannot access some packages (the server returns 401 Unauthorized.) As far as I'm aware the failing packages are:
As you can see, the URLs point to https://repository.neo9.pro
instead of NPM or Yarn repositories.
Removing yarn.lock
and installing sort of fixes the problem, but it defeats the purpose of having a lock file in the first place. I think @Atinux was behind a proxy when he regenerated file in this commit: b40e16b
Easy to fix, submitting a PR.
export const state = () => ({
user: {},
});
export const mutations = {
};
export const actions = {
AUTH ({commit},{email, password}){
console.log('email, password =', email, password)
}
};
export const getters = {};
<template>
<form @submit.prevent="AUTH(model)">
<input type="text" required v-model.lazy = "model.email">
<input type="password" required v-model.lazy = "model.password" >
</template>
<script>
import { mapActions } from 'vuex'
export default {
data() {
return {
model:{
email:" " ,
password:" "
}
}
},
methods: {
...mapActions(['AUTH']),
}
}
Example-Auth0 (https://github.com/nuxt/example-auth0)
I had copied this example repos to local and register like README setup file.
I still have no idea yet. But I'll try to research config in dev mode
I want dev mode can open many tabs like pro mode
In dev mode, can not open more than 3 tabs browsers
Hi, Atinux
I am a sincere fan of nuxt
I wanna use firebase with nuxt to build my static page, but firebase don't have any token after doing below code
firebase.auth().signInWithEmailAndPassword(email, password).catch(function(error) {
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
// ...
});
I can't see it return any token that I can save it to resume my status that has logged In. so I think about using auth0 and using auth0's delegation to generate a exchange token, and use this token to log in firebase, and save the exchange token to record my firebase status, so I add these code in your code
var lock = new Auth0Lock('YOUR-AUTH0-CLIENT-ID', 'YOUR-AUTH0-DOMAIN.auth0.com');
var auth0 = new Auth0({ domain : 'YOUR-AUTH0-DOMAIN.auth0.com', clientID: 'YOUR-AUTH0-CLIENT-ID'})
// Display the default lock widget
lock.show();
// listen to when the user gets authenticated and then save the profile
lock.on("authenticated", function(authResult) {
lock.getProfile(authResult.idToken, function(error, profile) {
if (error) {
// handle error
return;
}
localStorage.setItem('profile', JSON.stringify(profile))
// Set the options to retreive a firebase delegation token
var options = {
id_token : authResult.idToken,
api : 'firebase',
scope : 'openid name email displayName',
target: 'YOUR-AUTH0-CLIENT-ID'
};
// Make a call to the Auth0 '/delegate'
auth0.getDelegationToken(options, function(err, result) {
if(!err) {
// Exchange the delegate token for a Firebase auth token
firebase.auth().signInWithCustomToken(result.id_token).catch(function(error) {
console.log(error);
});
}
});
});
});
but it can't achieve my goal, it seem lock.on()
don't receive some events or function show()
has exited before receiving some event. I have three questions , please give me some advice.
lock.on()
, have some best practice ?plugin
or middleware
or custom directory like utils
? I have a little puzzle.process.__FIREBASE__
to save firebase instance, but I think it don't match nuxt philosophy, how to save it in my whole applicationWhen I try to clone and 'npm run dev' this project, it seems to build and launch just fine. But when I navigate to localhost:3000, I get the error "ReferenceError: window is not defined". The offending line of code is server-bundle.js line 3538, "const json = window.localStorage.user;". Call stack is:
server-bundle.js:3538:16 getUserFromLocalStorage
server-bundle.js:2341:185
server-bundle.js:1630:15 promisify
server-bundle.js:1609:10 middlewareSeries
server-bundle.js:1125:72
How can I make this work?
npm run dev show up the following errors:
These dependencies were not found:
To install them, you can run: npm install --save core-js/modules/es6.regexp.to-string core-js/modules/es7.promise.finally core-js/modules/es7.symbol.async-iterator
I use node 10.12, npm 6.4.1 on Windows 10 and the original package.json
When I try to clone and 'npm run dev' this project, it seems to build and launch just fine. But when I navigate to localhost:3000, I get the error "ReferenceError: window is not defined". The offending line of code is server-bundle.js line 3538, "const json = window.localStorage.user;". Call stack is:
server-bundle.js:3538:16 getUserFromLocalStorage
server-bundle.js:2341:185
server-bundle.js:1630:15 promisify
server-bundle.js:1609:10 middlewareSeries
server-bundle.js:1125:72
This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.
These problems occurred while renovating this repository. View logs.
These updates have all been created already. Click a checkbox below to force a retry/rebase of any.
@nuxtjs/axios
, dotenv
, nuxt
, nuxt-start
)package.json
@nuxtjs/auth ^4.9.1
@nuxtjs/axios ^5.12.2
dotenv ^8.2.0
normalize.css ^8.0.1
nuxt-start ^2.14.3
nuxt ^2.14.3
After clicking log out (use $auth.logout() ) under the hood, it only clears the storage token, etc.. on the browser but not the session from auth0 server therefore it still remains logged in
Log out completely from Auth0 server
The cookie approach can be very safe if done properly. Doing the following is fairly trivial:
npm run dev show up the following errors:
ERROR Cannot find module 'webpack/lib/RequestShortener'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:594:15)
at Function.Module._load (internal/modules/cjs/loader.js:520:25)
at Module.require (internal/modules/cjs/loader.js:650:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Object. (node_modules\terser-webpack-plugin\dist\index.js:16:48)
at Module._compile (internal/modules/cjs/loader.js:702:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
at Module.load (internal/modules/cjs/loader.js:612:32)
at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
at Function.Module._load (internal/modules/cjs/loader.js:543:3)
I have get this error when I try access auth routes:
on app: Invalid token specified
An error occurred while rendering the page. Check developer tools console for details.
on terminal:
nuxt:render Rendering url /auth/signed-in +0ms
context.isServer has been deprecated, please use process.server instead.
nuxt:render Data fetching /auth/signed-in: 30ms +0ms
nuxt:render Rendering url / +10s
context.isServer has been deprecated, please use process.server instead.
nuxt:render Data fetching /: 1ms +9s
nuxt:render Rendering url /auth/signed-in +19s
context.isServer has been deprecated, please use process.server instead.
nuxt:render Data fetching /auth/signed-in: 1ms +19s
Someone have any idea?
Thanks.
Hi, i wasn't able to run the example until i changed the following
These helped to run the app. However, there was a persistent error when i tried to sign in with Auth0. All methods (Fb, username) responded with an error (token is not valid).
I managed to get the app working by disabling OIDC Conformant in my auth0 settings.
Although it's working now, are there any experts that can point out if there are any potential problems in future?
There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.
Error type: Cannot find preset's package (@nuxtjs)
Hi,
Looking at the live demo, I'm able to fetch https://auth0.nuxtjs.org/_nuxt/4.nuxt.bundle.44ee0eecf0cba54387c9.js without having signed into Auth0
(I'm not sure if the actual URL will change but basically this file contains the content of secret page).
I've only just heard about Nuxt.js so I might be missing something, but it seems to me like you're only doing client-side authentication in this example? Is this by design? I would argue that this not secure at all.
Could you update the example to include how to protect the end-point (/_nuxt/4.nuxt.bundle.44ee0eecf0cba54387c9.js) against unauthorized requests?
I also had a look at https://nuxtjs.org/examples/auth-routes/. Unfortunately, it suffers from the same issues - I am able to fetch https://nuxt-auth-routes.glitch.me/_nuxt/1.nuxt.bundle.js without being authenticated.
Thanks
Do I understand correctly that you do not check the JWT tokens for the validity of the signature? Judging by the source code, the username is simply retrieved from the token. And whether it was signed by Auth0
or not - there is no verification.
If this is the case, there to be needed a note about this in the README of this example. Otherwise, many programmers will create work sites on the basis of this example, in which the authorization zone will be “hacked” with any Base64-encoded JWT issued by any script.
git clone https://github.com/nuxt/example-auth0.git
;domain
and client_id
into nuxt.config.js
(I am not using the .env file as it seems to me that it doesn't get embedded in the SPA after running npm run build)spa
On a more complicated platform I am developing, some API calls that are made on the callback URL to populate a Vuex store all yields unauthorized error, meaning that the token doesn't get stored at all.
When running example-auth0 and the application I am developing in development mode with npm run dev
, everything works fine. So I suppose that something goes wrong only after running the build command.
I expect the callback URL to be opened and the token received stored.
The SPA stays stuck at the callback URL and no token is stored.
Webserver: Caddy
Configuration:
nuxt.federicod.dev {
root /root/dev/example-auth0/dist
}
No errors are shown in the console.
Why don't you use '@nuxtjs/auth' ?
I can't see it in packages.json whereas in this website : https://auth.nuxtjs.org/getting-started/setup It says you need it.
related to this issue: auth0/lock#809
I want to make jumps with parameters but not query parameters.
exp:
middleware -> auth.js
import _ from 'lodash'
export default function(ctx) {
if (!_.isEmpty(ctx.store.state.user)) {
ctx.redirect({ name: 'index', query: { message: 'your login...' } })
}
}
If you use the query parameters, the message will always exist when the user refreshes
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.