At my main customer’s we needed to choose an authorization framework. This is for a complex enterprise application, and requiring fine-grained authorization on:
- model: most users can only access their own objects.
Grant fell off almost immediately. It centered all authorization in the model, and I felt it was a bit too lightweight for our application.
Then I looked at declarative authorization and cancan. At first sight, declarative authorization looked like a winner: I’m a believer in open source natural selection, and with about 650 people watching the plugin on github, it looked like a lot of people had found it a good fit. It’s also been lovingly polished since september 2008, so the kinks have probably been ironed out.
I cloned both plugins, and looked at the code and documentation. Cancan is partly based on declarative_authorization. What struck me at first sight, is how simple cancan looked. Much less code, much less meta-monkey-magic. And a very friendly DSL and documentation.
And get this: I ran reek on both plugins (it’s a hobby of mine). And cancan came out practically clean ! That’s like having an alien in the living room ! It never happens ! Run reek on your own code, just for laughs, and you’ll see what I mean.
So we ended up choosing cancan, although declarative_authorization might have more features out of the box, we feel we’ll be able to extend cancan with much more ease, if at all necessary. It feels better to have a clean, fathomable codebase, than a larger engine. I’m aware that cancan has the unfair advantage of having learned from its predecessors, and kudos to the maintainers of declarative_authorization for having inspired others.
*Note: I’m aware there are quite a few other plugins out there. If you found another one and you’re very happy about it, please share. *