views:

821

answers:

1

I'm trying to make a web app in Sinatra, and I was wondering if there was a good solution for user sign-up with email verification, as well as authentication - perhaps as rack middleware? OpenID support would be nice to have too.

I suppose I can roll my own, but I didn't want to reinvent the wheel. If I have to do so, can anyone point me to the libraries I might want to use, maybe even example code? I'm also worried I might end up forgetting to implement something important with signup/authentication, since I've never done this before.

In case I need a homemade solution, I've found bcrypt-ruby for password encryption and Sinatra::Mailer or Pony for email. For signing on with OpenID support, there's hancock and hancock-client, though I'm not entirely clear on usage and I don't actually need single sign-on support. Maybe I should just use a ruby openid library? Do I need anything else?

This is a pretty muddled question, but I hope someone more experienced can point me in the right direction.

+1  A: 

You might be interested in Authlogic. You'll need to implement the e-mail verification yourself, but it will provide you with a good foundation for supporting this.

Authlogic can be used in any ruby framework you want: Rails, Merb, Sinatra, Mack, your own framework, whatever. It’s not tied down to Rails. It does this by abstracting itself from these framework’s controllers by using a controller adapter. Thanks to Rack, there is a defined standard for controller structure, and that’s what Authlogic’s abstract adapter follows. So if your controller follows the rack standards, you don’t need to do anything.

Tate Johnson
Thanks, that looks good. However, I can't figure out how to use it with Sinatra, since the examples are for rails...
ehsanul
I wrote an adapter to make authlogic work with sinatra. It's available as part of this template: http://github.com/ehsanul/Sinatra-Authlogic-Template/tree/master
ehsanul
Very cool @eshanul.
Tate Johnson