Authlogic shares the love, merb support added

Rails doesn’t have to hog all of the Authlogic love, it’s time to start sharing. So I decided to send a little love to the merb peeps and add in a merb adapter. Just install the Authlogic gem and include it as a dependency and you are good to go. Authentication in your app is as easy as setting up a resource for a model.

I think this is just the beginning though, here are my thoughts….

The Big Picture

Thanks to things like Rack, the MVC design pattern, and ActiveRecord / DataMapper, all of these frameworks look very similar. They all have a similar pattern, which is the inherent nature of the MVC design pattern. So I decided to take advantage of this with Authlogic. Any specific framework implementation is extracted out into an adapter. Similar to how ActiveRecord has an adapter for each database type, except the Authlogic adapters are much simpler.

Probably the main reason these adapters are so simple / similar is because of Rack. Thanks to Rack, there is a request standard across all of these frameworks. “But Ben, why not skip all of this nonsense and implement this right into Rack?”. The reason I didn’t go right into Rack is…

  1. Not every “Rack compatible” framework uses the Rack libraries. After digging through the rails internals I found that the RackRequest class extends AbstractRequest, which has nothing to do with Rack. Lastly, older versions of rails aren’t rack compatible.
  2. I need to hook into the controller anyways with a before_filter
  3. With my implementation you get the best of both worlds. I designed the AbstractAdapter to conform to the rack standards, and any framework specific implementation can subclass this and do it’s magic.

So what’s the big picture here? The big picture is that there is no reason Authlogic can’t be an authentication solution for virtually any ruby framework out there. Why reinvent the wheel for every framework?

What about framework X?

Since writing adapters for rails and merb was so simple, why not keep going? Here are a few frameworks I plan to write an adapter for:

  1. Mack
  2. Ramaze
  3. Sinatra

If you are feeling generous and want to write an adapter for a framework other than rails or merb, please do so. Let me know about it and I will add it into the source.

Final thoughts

Authlogic loves you regardless of your framework

  • Share/Save/Bookmark

2 Responses to “Authlogic shares the love, merb support added”

  1. marktucks says:

    Sweet, I’ve been looking for an authentication system for Merb for at least 3 days now. I tried Merbful authentication but couldn’t get the generator to work. I’ll give Auth(gasm)logic a spin.

  2. windoz says:

    thanks for authlogic – I love it

    +1 for authlogic / sinatra