Skip to content

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)=>{returnrouter;};

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 /testrouter.get('/test',(req,res)=>res.json({message: 'this is a test'}));returnrouter;};

About

Simple key-based authentication server

Resources

Stars

5 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages