I spent yesterday coding a very abbreviated version of an authentication service that uses Sinatra, Mongoid and RSpec 2. It took more than a couple hours because there are so many outdated code samples on the web that just don’t work. I put my code up on github for people to see. Just clone the repository and run:
rake spec
While the current example is very basic, I will update it with enhancements and talk more about how to write a good authentication service. For this example I quickly rolled my own basic authentication since the main purpose is to get you up and running quickly with Sinatra, Mongoid, and RSpec2 . I may end up using Authlogic, Devise, or improving on my own authentication functionality.
Get the code here.
Feel free to contribute to the example. Keep in mind this is a service to be consumed by front end apps, not a full application. Also I won’t accept contributions without tests.
If you enjoyed this post, make sure you subscribe to my RSS feed!










2 Comments
Greate code!
I might not understand what’s happening… shouldn’t the credentials or session be used by the user end-points? It looks like you could create, update, and retrieve users without ever verifying anything.