Giter Club home page Giter Club logo

rio-auth's Introduction

rio-auth api

A simple jwt generator and validator for user auth purpose

dependencies: mongodb


  • use

npm run start --MONGO_URI=yourdatabase-uri --AUDIENCE=Token-Audience --ISSUER=Token-Issuer --EXPIRE_TIME=Expire-Time --APP_SECRET=secret

params:

MONGO_URI - you database url

AUDIENCE - The token Audience, default: myapp

ISSUER - The token issuer, default: myapp

EXPIRE_TIME - The token expire time in seconds, default: 60 * 60 * 24 * 30 // 1 month in seconds

APP_SECRET - Some string used to add and revoke roles from users:

methods:

  • login

Do login if user has account otherwise create a new user, the password is hashed using bcrypt

/**
 * POST /api/v1/login
 * {
 *	"email":"[email protected]",
 *	"password": "qwerty"
 * }
 */
  • validate Validate a JWT
/**
 * POST /api/v1/validate
 * {
 *	"token":"token"
 * }
 */
  • grantrole Grant a role to an user (every user has the role user)
/**
* POST /api/v1/grantrole
* {
*  "role": "master of universe",
*  "email": "[email protected]",
*  "secret": "secret_token"
* }
*/
  • revokerole Revoke a role from the user
 /**
 * POST /api/v1/rovekerole
 * {
 *  "role": "master of universe",
 *  "email": "[email protected]",
 *  "secret": "secret_token"
 * }
 */

rio-auth's People

Contributors

87victorhugo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.