sanji-auth-ui
Sanji auth service is part of Sanji UI framework and also it is a angular module. It accounts for authenticate and authorize a user based on json web token.
Dependencies
Installation
Sanji auth service is based on es6 + webpack to development and embrace npm to install it.
npm install sanji-auth-ui --save
How to use
You need to include module first.
angular
and then use auth
and session
as DI service. auth
service accounts for
identifying user and session
accounts for keeping login success information.
{ thiscredentials = username: '' passowrd: '' ; this { // Authenticate a user thisauth ; } }AppController$inject = '$http' 'auth' 'session';
Configuration
authProvider
You can define roles to acheive access control. Default includes admin, user and guest.
let app = angular;app;
sessionProvider
You can define token http header. Default is Authorization
.
let app = angular;app;
You also can define token key. Default is token
. The key name must match your server response data. For example:
token
let app = angular;app;
By the way, you can save autheticated user data in session
service,
let app = angular;app;
Contact
Author: Zack Yang © 2015
Support: if you find any problems with this library, open issue on Github