项目作者: StellarFw

项目描述 :
The official authentication module for Stellar
高级语言: JavaScript
项目地址: git://github.com/StellarFw/Identify.git
创建时间: 2016-07-29T16:53:59Z
项目社区:https://github.com/StellarFw/Identify

开源协议:

下载


Identify

Identify is an authentication solution for Stellar made to cur repetitive work involving management of users. A DRY approach on features like account creation, login, logout, confirmation by e-mail, password reset, etc.

Composition

  • actions:
  • auth.register - create a new user account;
  • auth.login - login with an existent user account;
  • auth.disableUser - disable the user account. Disabled users can not make login;
  • auth.checkSession - check the state of a token and if it’s valid return the expire time (expireAt) and the user info (user);
  • models:
  • user - model to represent a user on the database;
  • events:
  • auth.checkSessionResponse - this event allows edit the response for the auth.checkSession action.
  • middleware:
  • auth.needAuth - only authenticated users can access the protected action.

Quick start

To start using Identify on your Stellar application you can follow the commands below.

If you use git to manage the changes in your application you can add Identify as a Git submodule.

  1. # add Identify as a Git submodule
  2. git submodule add https://github.com/StellarFw/Identify modules/identify

If you don’t use Git in your app you can use Git only to clone the repo or make the download of repository Zip.

  1. git clone https://github.com/StellarFw/Identify modules/identify

Activate the Module

Now to activate the module you just need add "identify" to the manifest.json file on your app root folder. Like this:

  1. {
  2. "name": "my-awesome-app",
  3. "version": "1.0.0",
  4. "modules": ["identify"]
  5. }

Usage

The code below show the usage of the middleware:

  1. export const example = {
  2. name: "example",
  3. description: "This is a protected action",
  4. middleware: ["auth.needAuth"],
  5. run: (api, action, next) => {
  6. // only authenticated users reach this point
  7. // do something...
  8. next();
  9. },
  10. };

Note: it’s recommended load this module before all the others.

TODOs

  • Add a mechanism to reset the user password
  • Add a way to validate users at account creation
  • Add a way to invalidate tokens