Hi, I'm Rob Johansen. Thanks for giving me the opportunity to interview with Doppler! I enjoyed working through this take-home assessment, and I'd like to highlight some of my thoughts as I went along—particularly in regard to attack vectors:
I added support for basic rate limiting to illustrate that this was on my mind, although in a real tokenization service the rate limiting might look very different.
I wanted to be certain that users of the service would only be able to access their own
tokens and secrets. I addressed this by requiring an API key as a bearer token in the
HTTP Authorization
header (all endpoints require this authentication).
Where applicable, each endpoint returns early if the required input is missing or malformed.
I designed the service to provide as little information as possible:
- The
x-powered-by
header is disabled - All client errors result in a 400 status, making it impossible to probe the endpoints with varying inputs and glean information from changing status codes. I acknowledge that this is a controversial decision.
I added one or more tests for every endpoint, so there is some measure of reassurance that each is working properly.
To run the project locally:
-
Make sure you have Node.js installed. I use nvm to manage multiple versions of Node.js, and tested this project with Node.js v16.14.0.
-
Clone this repository:
git clone https://github.com/rob-johansen/doppler.git
-
Install dependencies:
npm install
-
Start the server on port 3000:
npm start
-
Send requests using a tool like curl or Postman. Here are curl examples for each endpoint:
POST
curl 'http://localhost:3000/tokens' \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer API-KEY-1' \ --data '{"secret":"password"}'
GET
curl 'http://localhost:3000/tokens?t=<TOKEN>' \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer API-KEY-1'
PUT
curl 'http://localhost:3000/tokens/<TOKEN>' \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer API-KEY-1' \ --request 'PUT' \ --data '{"secret":"drowssap"}' \ --verbose
DELETE
curl 'http://localhost:3000/tokens/<TOKEN>' \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer API-KEY-1' \ --request 'DELETE' \ --verbose
Execute the following to run tests:
npm test