DEV Community


Posted on

Sidecar pattern and Ursc

Sidecar pattern

The sidecar pattern is a distrbuted single node application pattern where a side application is used to extend functionality of the main application. Ursc can keep track of registration and login of users for another application.


Ursc is a containerized sidecar application that help on keeping registration and login of user for any application.

Ursc has a very simple API:


curl -v -X POST -H "Content-Type: application/json"  -d '{"name":"name","password":"password"}'  localhost:8083/user/register

Returns 201 if user is created, if there is already a user with the same name, response is code 403.


curl -v -X POST -H "Content-Type: application/json"  -d '{"name":"name","password":"password"}'  localhost:8080/user/login

Returns 200 and a signed JWT token if credentials are correct, otherwise response will be code 403.


curl -i -H "Authorization: Basic eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJhYSIsImlhdCI6MTU5NzA3OTUwMCwiZXhwIjoxNTk3MDgzMTAwfQ.VCGsGjpAMEVUzQu2twamNUrbFeyjNECGjeq0nxlDlm1" -X GET localhost:8080/user/check

Check validity of the token sent in the Authorization header and returns 200 code with the name of user if the token is valid, if not response is 422.


If you want to deploy Ursc you also need a MongoDB instance. Make sure your database is up and running then have a look on the configuration file config.conf:


Change the jwt signature and encryption salt to make your application saver. Then run, now you should have a Docker container running Ursc!

# Link mongodb container with alias "mongodb", expose application on port 8083
./ -l mongodb:mongodb -p 8080 

Discussion (0)