Role Based Authorization for Vue.js & Nuxt.js Apps Using vue-kindergarten
Modular security for Vue, Vuex, Vue-Router and Nuxt
Dive into building a simple Vue, Vuex, Vue-Router application with Role Based Authorization by integrating vue-kindergarten. In computer systems security, role-based access control is an approach to restricting system access to authorized users. Vue-kindergarten is a plugin for Vue.js and Nuxt.js applications that simplifies an implementation of role based authorization. It is basically an integration of kindergarten library into Vue ecosystem.
The main advantages are:
- Provides an easy way to define new authorization rules
- Groups authorization rules by a certain business domain
- Protects routes and components using the same pattern
- Is framework independent and works on the server as well
- Provides an easy way to create a new behavior when user is trying to access a restricted resource
- Lightens store and components by moving authorization rules to modules
Terms Used in Vue-Kindergarten
Perimeter is a module that represents a business domain in your application. Perimeter can define the method that should be exposed and some rules that must be followed.
Modules (perimeters) are plugged into the sandbox and all exposed methods will be accessible through it. Sandbox is governed by a governess and she is the one who makes sure that all rules are followed in order to prevent any kind of troubles.
The governess is guarding your sandbox. She makes sure that child doesn’t do any unauthorized activities and she can deal with troubles your way! Governess defines the behavior of your application when a user is doing illegal stuff.
Child in vue-kindergarten represents the current user of your application.
vue-kindergarten is a plugin for Vue 2.0 that integrates kindergarten into your Vue applications. It helps you to authorize your components, routes and the rest of your application in a modular way.