Here’s a Snippet of code that gives you instant OpenID Authentication. It will set @state.identity to the user’s OpenID URL once they’ve logged in, so you’ll need to be using some kind of camping session handler. You’ll also need to install the OpenID gem from JanRain by running “gem install openid” in a terminal. It’s lovely for your user’s as they can login with existing Yahoo, AOL, LiveJournal, etc accounts, not needing to register for your app, and you get to skip writing all that annoying account creation & management code and get straight down to business!
Drop this code in your controllers, and make a form somewhere with an input by the name ‘openid_identifier’ with it’s action pointing to /login in your app. That’s all there is to it! To check if the user is logged in from various controllers in your camping app, do something like ‘return redirect(‘/index’) unless @state.identity’. The .identity property contains a unique URL which you use the same way you’d use a username normally. To add a log out Link to your app, you just need to make a controller that does @state.delete(’identity’) :)