Boone Putney bio photo

Boone Putney

Software Development
Random Musings
Austin, Texas

HumanPlanet Soleer

Email LinkedIn Github

We’re currently evaluating an RDBMS (PostgreSQL) or Graph Database (Neo4j) for an upcoming project. As such, I decided to imlpement a basic RESTful Authentication API in Go with Neo4j to get inside and poke around. Source is available on GitHub if you want to check it out.


Make sure you have:

Implementation notes

  • Authentication is implemented with a JSON Web Token (JWT).
  • Password hashes are generated by creating individual random salt, and bcrypting this salt prepended to the submitted password.
  • The salt and password hash are stored as paramters to a Person Node in the Neo4j database.

Example commandline interaction via (replace ALLCAPS values as required):

Register new user:

curl -d '{"email": "EMAIL@SOMEWHERE.COM", "password": "PASSWORD"}' -H "Content-Type:application/json" http://localhost:8080/api/register

Authenticate registered user:

curl -d '{"username": "EMAIL@SOMEWHERE.COM", "password": "PASSWORD"}' -H "Content-Type:application/json" http://localhost:8080/api/login

Get currently logged in user:

curl -H "Authorization:Bearer JWTOKEN_RETURNED_FROM_LOGIN_REQUEST" http://localhost:8080/api/auth_test

Refresh JWT token:

curl -H "Authorization:Bearer JWTOKEN_RETURNED_FROM_LOGIN_REQUEST" http://localhost:8080/api/refresh_token