I’m building a camping app which uses OpenID for authentication, so I’m using JanRain’s OpenID 2.0.4 gem, which you can get with ‘gem install openid’.
Here’s some sample code for anyone else out there camping and wanting to drop in some authentication! Nice and short. When authenticated, the session’s @state variable will have identity set to the user’s openid url. It’s a great way to skip writing a ton of registration code, and awesome for apps which don’t use the database at all. In my app, i’ll simply create a folder with the openid url as it’s name (forward slashes changed to back slashes for obvious reasons) and store their data in that. Nice and easy to back up, move between servers, and very convenient to do admin stuff by simply messing with the file system directly. :)
Updated: slightly to be more suitable for use in CGI camping scripts, now only loads the JanRain library when it’s being used, instead of on every camping app request. Changed input’s name to ‘openid_identifier’ to be more standard.
So I’ve been hacking on a secret project using some ruby code on the server, and needed to make a module, which I could include in to a class. But I needed to access a class variable in that class from a method in the module. Seems modules in ruby have their own unique set of class variables totally seperate from that of the class it is used in. Work around? Here it is. I know, yucky eval, but hey, it works! Got any better idea’s?