ng-mr-authorize
Authorization service for ui-router in angular.
Overview
mr.authorize
authorizes a state by looking inside of it for an auth
property and tries to authorize the user based on that.
Installation
bower install ng-mr-authorize --save
Features
- Two kinds of authorization: basic (if authed or not) and policies.
- Child states inherit parent's auth object so you can specify authorization requirements on the parent and even extend them.
Usage
First, referencing the module:
angular;
Then you'll have to configure authorizeProvider
:
angular ;
Consider the following states:
$stateProvider ...
The final step:
angular
All options
auth
object:
The $stateProvider;
You can also use:
auth: true
as a shortcut forauth: { authed: true }
auth: 'p1'
as a shortcut forauth: { policies: ['p1'] }
auth: ['p1', 'p2']
as a shortcut forauth: { policies: ['p1', 'p2'] }
Note: auth: { policies: ['p1'] }
is implicitly the same as auth: { authed: true, policies: ['p1'] }