Based on the publication
“Designing Microservice” I decided to write (and wrote!) Open source for the implementation of two-factor authentication. In fact, there are two repositories that provide the entire “background” of the second authentication factor and provide a convenient architecture for the implementation of buns.

Separately, I note that the first part can serve as an independent application. Both services work through the API.
Pinkcodes
This application is responsible for creating, sending and checking pin. Under the hood Sinatra + Redis.
')
Implemented by:
- setting the pincode life time;
- restriction on the number of attempts to enter;
- selection of third-party gateway for sending SMS.
In the plans:
- other methods of pin delivery (ideally, put this delivery in a separate module / service);
- customizable code complexity level.
Accounting
This part deals with everything that is useful for authentication, but is not directly related to it. Powered by Rails + PG.
Implemented by:
- access by generated keys.
In the plans:
- access settings (for example, open access only to certain IPs);
- collection of statistics.
If we talk about statistics, then for two-factor it is a vital feature. For example, SMS gateways sometimes mark missing text messages as delivered. In this regard, the statistics created / confirmed will say much more and help not to lose valuable users.
Results
Of course, the solution was developed not as a competitor to existing ones, but as an alternative. For example, when you need to implement delivery through your gateway, work in a closed mode, finish yourself a feature and so on. I also hope that the community will help to make the service better with its expert assessment, pullrequests and “God knows what else.”
Links
Pinkcodes:
github.com/IlyaDonskikh/pincodeAccounting:
github.com/IlyaDonskikh/pincode_accountPerhaps someone from the readers had a question, what is this services folder and why is all business logic stored in it. The answer is here:
brewhouse.io/blog/2014/04/30/gourmet-service-objects.html .
Bonuses
In addition to all of the above, I have free computing power at Azur, so if you are interested in experimenting with this project, but “nowhere”, then write me in a personal. The project is launched in the cloud version here:
pinc0de.com .