{"id":43786391,"url":"https://github.com/17axah/vue-router-auth","last_synced_at":"2026-02-05T19:04:38.137Z","repository":{"id":143926588,"uuid":"263366276","full_name":"17axah/vue-router-auth","owner":"17axah","description":"Flexible configuration of routes. Closing routers for authorized / unauthorized users.","archived":false,"fork":false,"pushed_at":"2020-05-20T13:29:53.000Z","size":11,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-06T08:24:47.343Z","etag":null,"topics":["auth","guard","permissions","plugin","router","vue","vue-router","vuejs"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/17axah.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-05-12T14:49:53.000Z","updated_at":"2024-04-01T19:03:57.000Z","dependencies_parsed_at":null,"dependency_job_id":"0feb2ef9-0b44-4b0d-8634-b19dfd42a3c5","html_url":"https://github.com/17axah/vue-router-auth","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/17axah/vue-router-auth","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/17axah%2Fvue-router-auth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/17axah%2Fvue-router-auth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/17axah%2Fvue-router-auth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/17axah%2Fvue-router-auth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/17axah","download_url":"https://codeload.github.com/17axah/vue-router-auth/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/17axah%2Fvue-router-auth/sbom","scorecard":{"id":1690,"data":{"date":"2025-08-11","repo":{"name":"github.com/17axah/vue-router-auth","commit":"8535f1fe5407368283f05137f81cafa419c61f2f"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.6,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Code-Review","score":0,"reason":"Found 0/9 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"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"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"License","score":0,"reason":"license file not detected","details":["Warn: project does not have a license file"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-14T12:41:43.611Z","repository_id":143926588,"created_at":"2025-08-14T12:41:43.611Z","updated_at":"2025-08-14T12:41:43.611Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29130114,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-05T18:55:47.139Z","status":"ssl_error","status_checked_at":"2026-02-05T18:55:04.010Z","response_time":65,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["auth","guard","permissions","plugin","router","vue","vue-router","vuejs"],"created_at":"2026-02-05T19:04:38.069Z","updated_at":"2026-02-05T19:04:38.131Z","avatar_url":"https://github.com/17axah.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# vue-router-auth\nFlexible routes setup. Closing routes for authorized / unauthorized users, users with specific roles.\n\nThis module is designed for the fact that you already have an authorization system and you need to close the pages for unauthorized / authorized users.\n\u003cbr\u003e\n\u003cbr\u003e\nIf you find an error, incorrect behavior please open the corresponding\n[issue](https://github.com/17axah/vue-router-auth/issues). \u003cbr\u003e\nPlease also rate this [repository](https://github.com/17axah/vue-router-auth). :blush:\n\n\u003chr\u003e\n\n## :book: Usage\n\n```bash\n$ npm i vue-router-auth\n```\n\n```js\nimport Vue from 'vue';\nimport VueRouterAuth from 'vue-router-auth';\n\nconst options = {\n  router,\n  guard: ({ $auth }) =\u003e $auth.loggedIn,\n};\n\nVue.use(VueRouterAuth, options);\n```\nor\n```js\nimport { middleware } from 'vue-router-auth';\n\nconst options = {\n  router,\n  guard: ({ $auth }) =\u003e $auth.loggedIn,\n};\n\nrouter.beforeEach(middleware(options));\n```\n\nAfter which you need to configure the routes:\n\n```js\nconst routes = [\n  {\n    path: '/',\n    component: () =\u003e import('layouts/MainLayout.vue'),\n    children: [\n      {\n        path: 'login',\n        component: () =\u003e import('pages/Login.vue'),\n        meta: {\n          auth: {\n            access: false,\n          },\n        },\n      },\n    ],\n  },\n  {\n    path: '/account',\n    component: () =\u003e import('layouts/Auth.vue'),\n    meta: {\n      auth: {\n        access: true,\n      },\n    },\n    children: [\n      {\n        path: '',\n        component: () =\u003e import('pages/Account.vue'),\n      },\n      {\n        path: 'settings',\n        component: () =\u003e import('pages/Settings.vue'),\n      },\n    ],\n  },\n];\n```\n\n## :gear: Customization\n### Options\nList of passed options during initialization:\n\nname    | default                                           | description                                                                                                                                                                                                                     | required | type\n--------|---------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------|--------\nrouter  | -                                                 | app router                                                                                                                                                                                                                      | true     | Object\nguard   | \u003cpre\u003e() =\u003e false\u003c/pre\u003e                            | Function to check access. It has a context argument: ***to***, ***from***, ***Vue.prototype*** and the context that was passed in the module option. Use read-only context (**must be redefined**)                              | true     | Function\nroutes  | \u003cpre\u003e{ guest: '/public', auth: '/account' }\u003c/pre\u003e | Routes for redirecting authorized, unauthorized users, users with specific roles.                                                                                                                                               | false    | Object\ncontext | \u003cpre\u003e{}\u003c/pre\u003e                                     | The data that will be available in the functions (***guard***, ***redirect***)                                                                                                                                                  | false    | Object\n\nAlso, for full work, you need to configure the meta field in routes:\n\n### Route options\nList of options passed to the *meta.auth* route field:\n\nname     | description                                          | type\n---------|------------------------------------------------------|--------\naccess   | A flag indicating the closure of the route.          | Boolean or String\nredirect | route or function returning a route.                 | Function or Object or String\nguard    | individual ***guard*** function for a specific route | Function\n\n***functions redirect and guard have the same arguments as the main guard function.***\n\n### Description\nTo close the route for unauthorized users, you must specify true in the *meta.auth.access* route field.\nTo close the route for authorized users, set the *meta.auth.access* field to false.\nIn this case, the *guard* function should return true for authorized users and false for unauthorized users.\nTo configure user redirection, use the *routes* option.\n*guest* - the route where the unauthorized user will be redirected, *auth* - the authorized user.\nYou can also specify the redirection route individually for each route in the *meta.auth.redirect* field.\nThe guard and redirect functions in the arguments receive a context, to expand it use the *context* option.\n\n#### Using roles\nIn order to close the route for a specific role in the *meta.auth.access* route field, you must specify the role name,\nin this case, the *guard* function should return a string with the name of this role, otherwise redirection will occur.\nTo configure redirection for a specific role, you need to add a field to the *routes* option with the name of this role. \n\n\n### :eyes: Examples\n```js\nimport { middleware } from 'vue-router-auth';\nimport auth from 'auth-module'; // for example\n\nconst options = {\n  router,\n  guard: ({ auth }) =\u003e auth.loggedIn,\n  context: {\n    auth,\n  },\n};\n\nrouter.beforeEach(middleware(options));\n```\n\n```js\nconst routes = [\n  {\n    path: '/',\n    component: () =\u003e import('layouts/MainLayout.vue'),\n    children: [\n      {\n        path: 'login',\n        component: () =\u003e import('pages/Login.vue'),\n        meta: {\n          auth: {\n            access: false,\n          },\n        },\n      },\n    ],\n  },\n  {\n    path: '/account',\n    component: () =\u003e import('layouts/Auth.vue'),\n    meta: {\n      auth: {\n        access: true,\n      },\n    },\n    children: [\n      {\n        path: '',\n        component: () =\u003e import('pages/Account.vue'),\n      },\n      {\n        path: 'settings',\n        component: () =\u003e import('pages/Settings.vue'),\n        meta: {\n          auth: {\n            access: false,\n          },\n        },\n      },\n    ],\n  },\n];\n```\nIn the example above, the */login* route will be closed to authorized users.\nA route */account* will be closed to unauthorized users,\nbut the route */account* */settings* will be open to unauthorized users and closed to authorized users.\n\n#### Using roles:\n```js\nimport { middleware } from 'vue-router-auth';\nimport auth from 'auth-module'; // for example\n\nconst options = {\n  router,\n  guard: ({ auth }) =\u003e auth.user.role, // \"admin\"\n  routes: {\n    admin: '/route-for-not-admin',\n  },\n  context: {\n    auth,\n  },\n};\n\nrouter.beforeEach(middleware(options));\n```\n```js\nconst routes = [\n  // ...\n  {\n    path: '/account',\n    component: () =\u003e import('layouts/Auth.vue'),\n    children: [\n      {\n        path: 'payments',\n        component: () =\u003e import('pages/Account.vue'),\n        meta: {\n          auth: {\n            access: 'simple-role',\n            redirect: '/any-route',\n          },\n        },\n      },\n      {\n        path: 'settings',\n        component: () =\u003e import('pages/Settings.vue'),\n        meta: {\n          auth: {\n            access: 'admin',\n          },\n        },\n      },\n    ],\n  },\n];\n```\n\n## :copyright: License\n\n[MIT](http://opensource.org/licenses/MIT)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F17axah%2Fvue-router-auth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F17axah%2Fvue-router-auth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F17axah%2Fvue-router-auth/lists"}