Friend: an Extensible Authentication and Authorization Library for Clojure Ring Webapps
Say hello to my little Friend.
There’s plenty of technical stuff in the README to chew on if you like. In short, I’m hoping this can eventually be a warden/spring-security/everyauth /omniauth for Clojure; that is, a common abstraction for authentication and authorization mechanisms. Clojure has been around long enough that adding pedestrian things like form and HTTP Basic and $AUTH_METHOD_HERE to a Ring application should be easy. Right now, it’s not: either you’re pasting together a bunch of different libraries that don’t necessarily compose well together, or you get drawn into shaving the authentication and authorization yaks for the fifth time in your life so you can sleep well at night.
Hopefully Friend will make this a solved problem, or at least push things in that direction. It plays nice with all of the best principles of Ring, and includes support for:
- form, HTTP Basic, and OpenID authentication
- role-based authorization (optionally using hierarchical roles via Clojure’s derive and isa?)
- su capabilities (multiple login support / a.k.a. “log in as”)
- channel security (i.e. HTTPS-only for certain Ring routes)
- …and more
Most importantly, it takes a stab at a couple of core abstractions for others to drop in other authentication workflows, e.g. OAuth in all of its incarnations, NTLM, BrowserID, etc. etc. etc. There are already plenty of Clojure implementations for all sorts of authentication methods; hopefully someone (you?!) will step up and bring one of them to the party, so anyone’s Friend-empowered Clojure webapp can easily offer any or all of them with a minimum of suffering.
Finally: frankly, it’s absurd that I’m writing security-related stuffs. (I know it hardly ever works out that way, but it seems like some experts somewhere should be taking care of this.) It would be a great thing if you were to beat on Friend and try to find exploits, general breakage, etc., especially if you have prior experience in this area.
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)