GithubHelp home page GithubHelp logo

joelroxell / heimdall Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 385 KB

Heimdall is a minimal authentication service tailored for dockerized development and deployment.

License: MIT License

Shell 5.29% JavaScript 59.85% Python 34.19% Groovy 0.67%

heimdall's Introduction

Heimdall(beta)

Authentication microservice.

Heimdall is a minimal authentication service tailored for dockerized development and deployment.

Maintainer: Joel Roxell <[email protected]>

TL;DR

TOC

Dependencies

  • Redis
  • MongoDB

Environment

VARIABLE DESCRIPTION
NODE_ENV Sets the application to either production or development mode
SECRET Secret which is used to sign and verify JWTs
SALT_ROUNDS Amount of rounds that bcrypt should use on encryption
TOKEN_TTL Minutes before a token expires

API

METHOD URI ERROR CODE SUCCESS CODE OUTPUT
POST /user/register 400, 409 201 User
GET /user 400, 403 200 User
POST /user/reset-password 400, 403 200 User
POST /auth/sign-in 400, 401 200 Token(encoded)

Register a User

POST /user/register

Creates a new User

HEADERS

Content-Type: json/application

REQUEST BODY

NOTE: both properties must be of type String

{
  "email": "[email protected]",
  "password": "someSecretPassword"
}

RESPONSE

HTTP 201 - User was created successfully

{
  "email": "[email protected]"
}

HTTP 400 - Invalid request body

{
  "error": "request body did not pass validation"
}

HTTP 409 - User Already exists

{
  "error": "a user with that email already exists"
}

Get User information

GET /user

Returns a JSON string containing user information.

HEADERS

Content-Type: json/application Authentication: Bearer {encoded-JWT}

RESPONSE

HTTP 200 - User was created successfully

{
  "email": "[email protected]"
}

HTTP 403 - Invalid JWT

{
  "error": "jwt expired|invalid token"
}

Sign in

GET /user/sign-in

Returnes a encoded JWT on success.

HEADERS

Content-Type: json/application

RESPONSE

HTTP 200 - User signed in successfully

{
 "token": "{header.payload.signature}"
}

HTTP 400 - Invalid request body

{
  "error": "request body did not pass validation"
}

HTTP 401 - Invalid credentials

{
  "error": "authentication failed"
}

Reset User password

PUT /user/reset-password

Sets a new password for the specific User and returnes the updated User.

HEADERS

Content-Type: json/application Authentication: Bearer {encoded-JWT}

RESPONSE

HTTP 200 - User was created successfully

{
  "email": "[email protected]"
}

HTTP 400 - Invalid request body

{
  "error": "request body did not pass validation"
}

HTTP 403 - Invalid JWT

{
  "error": "jwt expired|invalid token"
}

Development

Prerequisites

To be able to get this project up and running, you'll need:

  • Docker
  • Docker Compose
  • npm

Setup

Follow these steps to get going:

The service will now build and run in a Docker container. The codebase is mounted into the container and the server will be restarted on save.

Tools & Scripts

SCRIPT USAGE CAVEATS
npm test Runs all unit tests using mocha The container must be running.
npm run test:watch Runs all unit tests and watches for changes The container must be running.
npm run test:debug Runs all unit tests and watches with node --inspect The container must be running.
npm run cov Runs all unit tests and generates coverage The container must be running.
npm run open:cov Opens the code coverage report in the default browser The container must be running.
npm run precommit Runs eslint just like the git precommit hook does -
npm run bash Enters the container with bash The container must be running.
npm run reinstall Installs dependencies using yarn inside the container The container must be running.
npm run generate:pem Generates a new .pem and .pub file used to sign JWTs Requers the container to be rebooted.

Testing

Tests should be easy to read. You can use this standard when writing tests.

describe <subject>
	it (the subject) should <act like this> when <this action is performed>

Real example:

describe('Request handler', function() {
	it('should return false when receiving invalid payload', function() {
		// ...
	});
});

heimdall's People

Watchers

 avatar  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.