Skip to content

amcode21/simple-auth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple Auth Server

Information

This is a simple key-based auth server written in Node.js. The modules used in this project are:

Current Routes

  • View key schema here

  • Admin Endpoints

    • POST /key/new - Creates new key and returns its ID
      • Body: None
      • 201 Created returned if operation successful
    • GET /key/:id - Gets key by ID and shows relevant information
    • PUT /key/:id - Updates key with machineId in request body
      • Body: { "machineId": "something" }
      • 200 OK returned if operation successful
  • Other Endpoints

    • POST /key/verify - Verifies if machineId and key in body are in database
      • Body: { "key": "something", "machineId": "something" }
      • 200 OK returned if operation successful
    • POST /key/active - Checks whether key is currently bound to a specific device
      • Body: { "key": "something" }
      • 200 OK returned if operation successful

Note: All responses have a 'message' attribute which gives a more detailed reason why a request failed, if it did, rather than just the status code.

Adding Routes

To add routes, there are only a few simple steps:

  • Create a new file in the routes/ folder. This will become the base of the route.
    • Creating a file called example.js creates a base route of /example
  • Add this code to begin with:
'use strict';

module.exports = (router) => {

    return router;
};

Do NOT remove the module.exports or anything already inside it.

  • To add routes, simply start coding like you would in a regular Express.js app!
'use strict';

module.exports = (router) => {
    // GET /example/
    router.get('/', (req, res) => res.send('hello there'));

    // GET /test
    router.get('/test', (req, res) => res.json({ message: 'this is a test' }));

    return router;
};

About

Simple key-based authentication server

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors