Installations
npm install vue-auth0-plugin
Developer Guide
Typescript
Yes
Module System
CommonJS, UMD
Node Version
20.7.0
NPM Version
10.2.3
Releases
Contributors
Unable to fetch Contributors
Languages
TypeScript (81.66%)
JavaScript (18.34%)
validate.email 🚀
Verify real, reachable, and deliverable emails with instant MX records, SMTP checks, and disposable email detection.
Developer
jnt0r
Download Statistics
Total Downloads
54,517
Last Day
23
Last Week
77
Last Month
398
Last Year
12,815
GitHub Statistics
MIT License
21 Stars
957 Commits
5 Forks
3 Watchers
7 Branches
3 Contributors
Updated on Apr 29, 2024
Package Meta Information
Latest Version
3.0.22
Package Id
vue-auth0-plugin@3.0.22
Unpacked Size
43.78 kB
Size
7.59 kB
File Count
13
NPM Version
10.2.3
Node Version
20.7.0
Published on
Dec 11, 2023
Total Downloads
Cumulative downloads
Total Downloads
54,517
Last Day
15%
23
Compared to previous day
Last Week
14.9%
77
Compared to previous week
Last Month
53.7%
398
Compared to previous month
Last Year
-14.4%
12,815
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
1
Peer Dependencies
2
Dev Dependencies
34
Vue-Auth0-Plugin
Simple Auth0 wrapper for Vue.js based on the Auth0 Single Page App SDK
:warning: Currently, only compatible with Vue 3. Support for Vue 2 is planned.
Prerequisites
You need an Auth0 tenant and a configured Auth0 application. For information about how to create these, take a look at the official documentation.
Installation
1npm install --save vue-auth0-plugin
Samples
To see some samples how to use the plugin, take a look into the samples folder in the project.
Usage
Register the plugin in your main.ts file. For a list of available options, take a look here: https://auth0.github.io/auth0-spa-js/interfaces/auth0clientoptions.html.
1import { createApp } from 'vue'; 2import VueAuth0Plugin from 'vue-auth0-plugin'; 3import App from './App.vue'; 4 5const app = createApp(App); 6app.use(VueAuth0Plugin, { 7 domain: 'YOUR_AUTH0_DOMAIN', 8 clientId: 'YOUR_CLIENT_ID', 9 // ... other optional options ... 10}); 11app.mount('#app');
Then Auth0 can be injected using the provided injectAuth
function. For more information about provide/inject, take a look here https://v3.vuejs.org/guide/component-provide-inject.html. For example:
1import { injectAuth } from 'vue-auth0-plugin' 2 3const auth = injectAuth(); 4 5const authenticated = auth.authenticated; 6const loading = auth.loading; 7const user = auth.user; 8 9if (!auth.authenticated) { 10 auth.loginWithRedirect(); 11 12 // If errors occurre during login, they are provided in auth.error property 13 if (auth.error != undefined) { 14 // Do something with the error 15 } 16}
Auth0 can also be injected using the Options API like the example below
1<template> 2 <div class="about"> 3 <h1>You are logged in as {{ auth.user.name }} ({{ auth.user.nickname }})</h1> 4 <img :src="auth.user.picture" alt="Profile picture"/> 5 <button v-on:click="auth.logout()">Logout</button> 6 </div> 7</template> 8<script lang="ts"> 9import { Options, Vue } from 'vue-class-component'; 10import { injectionToken } from 'vue-auth0-plugin' 11@Options({ 12 inject: [injectionToken], 13}) 14export default class MyComponent extends Vue {} 15</script>
If you want to use the state of authentication when you do not have access to the Vue instance, you can use the exported AuthenticationState.
1import { AuthenticationState } from 'vue-auth0-plugin'; 2 3if (!AuthenticationState.authenticated) { 4 // do something here 5} 6 7// or asynchronous using Promise 8if (!await AuthenticationState.getAuthenticatedAsPromise) { 9 // do something here 10}
INFO: The synchronous
AuthenticationState.authenticated
can give wrong result if used before initialization of the plugin. Then the plugin is still loading the state of authentication and returns the default value false. In this case you should use the asynchronousAuthenticationState.getAuthenticatedAsPromise
that resolves when the loading has finished and then returns the state of authentication.
If you want to use the properties provided by Auth0 when you do not have access to the Vue instance, you can use the exported AuthenticationProperties.
1import { AuthenticationProperties as auth0 } from 'vue-auth0-plugin'; 2 3const token = auth0.getTokenSilently();
AuthenticationGuards
The plugin implements two Vue Router NavigationGuards to secure routes with Auth0. The AuthenticationGuard
has an integrated redirect to the Auth0 login when the user is not authenticated. The AuthenticationGuardWithoutLoginRedirect
does not have this redirect. The example below shows how to use this AuthenticationGuards.
1import { AuthenticationGuard } from 'vue-auth0-plugin'; 2// or alternative 3import { AuthenticationGuardWithoutLoginRedirect } from 'vue-auth0-plugin'; 4 5let routes = [ 6 ... 7 { 8 path: '/private', 9 name: 'PrivateRoute', 10 component: () => import(/* webpackChunkName: "private" */ '../views/Private.vue'), 11 beforeEnter: AuthenticationGuard, // or AuthenticationGuardWithoutLoginRedirect 12 }, 13]; 14 15const router = createRouter({ 16 history: createWebHistory(YOUR_BASE_URL), 17 routes, 18});
Changelog
Changelog can be seen at GitHub Releases.
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
If you have questions or want to provide a good idea for improvements, please open an issue.
License

No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
packaging workflow detected
Details
- Info: Project packages its releases by way of GitHub Actions.: .github/workflows/ci.yml:12
Reason
SAST tool is run on all commits
Details
- Info: all commits (30) are checked with a SAST tool
Reason
dependency not pinned by hash detected -- score normalized to 2
Details
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/automerge_dependabot_pr.yml:10: update your workflow using https://app.stepsecurity.io/secureworkflow/jnt0r/vue-auth0-plugin/automerge_dependabot_pr.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:21: update your workflow using https://app.stepsecurity.io/secureworkflow/jnt0r/vue-auth0-plugin/ci.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:26: update your workflow using https://app.stepsecurity.io/secureworkflow/jnt0r/vue-auth0-plugin/ci.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:36: update your workflow using https://app.stepsecurity.io/secureworkflow/jnt0r/vue-auth0-plugin/ci.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:40: update your workflow using https://app.stepsecurity.io/secureworkflow/jnt0r/vue-auth0-plugin/ci.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:53: update your workflow using https://app.stepsecurity.io/secureworkflow/jnt0r/vue-auth0-plugin/ci.yml/master?enable=pin
- Info: 0 out of 2 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 4 third-party GitHubAction dependencies pinned
- Info: 1 out of 1 npmCommand dependencies pinned
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/automerge_dependabot_pr.yml:1
- Warn: no topLevel permission defined: .github/workflows/ci.yml:1
- Info: no jobLevel write permissions found
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
34 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-x4c5-c7rf-jjgv
- Warn: Project is vulnerable to: GHSA-h5c3-5r3r-rr8q
- Warn: Project is vulnerable to: GHSA-rmvr-2pp2-xj38
- Warn: Project is vulnerable to: GHSA-xx4v-prfh-6cgc
- Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw
- Warn: Project is vulnerable to: GHSA-qwcr-r2fm-qrc7
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-pxg6-pf52-xh8x
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-rv95-896h-c2vc
- Warn: Project is vulnerable to: GHSA-qw6h-vgh9-j6wx
- Warn: Project is vulnerable to: GHSA-jchw-25xp-jwwc
- Warn: Project is vulnerable to: GHSA-cxjh-pqwp-8mfp
- Warn: Project is vulnerable to: GHSA-c7qv-q95q-8v27
- Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-mwcw-c2x4-8c55
- Warn: Project is vulnerable to: GHSA-9wv6-86v2-598j
- Warn: Project is vulnerable to: GHSA-rhx6-c78j-4q9w
- Warn: Project is vulnerable to: GHSA-7fh5-64p2-3v2j
- Warn: Project is vulnerable to: GHSA-gcx4-mw62-g8wm
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-m6fv-jmcg-4jfg
- Warn: Project is vulnerable to: GHSA-76p7-773f-r4q5
- Warn: Project is vulnerable to: GHSA-cm22-4g7w-348p
- Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36
- Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3
- Warn: Project is vulnerable to: GHSA-g3ch-rx76-35fx
- Warn: Project is vulnerable to: GHSA-hc6q-2mpp-qw7j
- Warn: Project is vulnerable to: GHSA-4vvj-4cpr-p986
- Warn: Project is vulnerable to: GHSA-wr3j-pwj9-hqq6
- Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7
- Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q
Score
4.4
/10
Last Scanned on 2025-02-17
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More