Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/youknowriad/authenticate.js
AuthenticateJS is a simple angular library for handling security
https://github.com/youknowriad/authenticate.js
Last synced: 21 days ago
JSON representation
AuthenticateJS is a simple angular library for handling security
- Host: GitHub
- URL: https://github.com/youknowriad/authenticate.js
- Owner: youknowriad
- License: mit
- Created: 2014-02-20T19:44:59.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-02-02T08:09:31.000Z (almost 9 years ago)
- Last Synced: 2024-10-03T12:35:37.281Z (about 1 month ago)
- Language: JavaScript
- Size: 16.6 KB
- Stars: 38
- Watchers: 11
- Forks: 13
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
AuthenticateJS
=============AuthenticateJS is a simple angular library for handling security
Installation
------------To use this library you should have a server application that handles authentication with sessions and it should have a login api that uses a username and password parameters from request body, a logout url and an api to get the current loggedin user with its credentials.
* Install the library
```bash
bower install authenticateJS
```* load the library
```html
```
* copy the library partials to your public directory to the folder partials/authenticateJS* add it to your dependencies
```javascript
angular.module('myapp', ['authenticate.js']);
```* configure
```javascript
angular.module('myapp').config(['AuthenticateJSProvider', function (AuthenticateJSProvider) {AuthenticateJSProvider.setConfig({
host: 'api/', // your base api url
loginUrl: 'auth/login', // login api url
logoutUrl: 'auth/logout', // logout api url
loggedinUrl: 'auth/loggedin', // api to get the user profile and rolesunauthorizedPage: '/unauthorized', // url (frontend) of the unauthorized page
targetPage: '/dashboard', // url (frontend) of the target page on login success
loginPage: '/login' // url (frontend) of the login page
});}]);
```Usage
-----* In your login page, include the login form like this
```html
```
You can override the default login form template like this```html
```* add a security attribute to your routes
* a false value means that the route is not protected,
* a true value means, you have to be loggedin to access this route,
* other custom string can be used to indicate that a user role is required to access this route (the string represent the role that have to be found in user.roles)* you can call AuthenticateJS.logout(); to loggout
* you cas use AuthenticateJS.getLoggedinUser() to get the current loggedin user