At the Forge - Authenticating to a Rails Application
acts_as_authenticated is good enough for many sites as it currently stands. However, there are a number of plugins, suggestions and modifications that you can use with acts_as_authenticated.
For example, many registrations systems want to stop bots from automatically creating user names or e-mail addresses, which can be used to send spam. Thus, it's common for the registration system to ask that users confirm their membership requests via e-mail. So, you enter your information at the site and receive a message that asks you to click on a link. Only after clicking on that link is your account actually activated.
This functionality, although not an obvious part of the core acts_as_authenticated plugin, comes with it and is easy to use. Basically, we use the other generator that comes with acts_as_authenticated. This creates the templates and most of the logic that we need for people to confirm their login status.
There are a wide variety of other things you can do with acts_as_authenticated. For example, you can set it so that passwords are encrypted, but in a way such that it would be reversible. Another common task is to let users change their personal information, such as e-mail addresses and telephone numbers.
This whole discussion of acts_as_authenticated began because I wanted to use OpenID in a Rails application. However, I also wanted to integrate OpenID with an existing authentication mechanism, which brought me to acts_as_authenticated. Now that we have a working, if bare-bones, authentication system on our Web site, we can move on to the next step.
Even if you are not using acts_as_authenticated in your Rails application, it's useful to see how plugins work, how you interact with them and how you can use them to build your Rails application out of parts that have been contributed by other programmers.
Next month, we will look at how we can integrate OpenID into our login system—namely, allowing people to log in using either a user name/password combination or OpenID.
If you're still new to Rails, I strongly recommend The Rails Way by Obie Fernandez. I have found it to be both clear and comprehensive, and one chapter in the book is dedicated to acts_as_authenticated.
There are a number of good resources about acts_as_authenticated on the Web. However, the most comprehensive is the author's Wiki, at technoweenie.stikipad.com/plugins/show/Acts+as+Authenticated.
Reuven M. Lerner, a longtime Web/database developer and consultant, is a PhD candidate in learning sciences at Northwestern University, studying on-line learning communities. He recently returned (with his wife and three children) to their home in Modi'in, Israel, after four years in the Chicago area.
Free DevOps eBooks, Videos, and more!
Regardless of where you are in your DevOps process, Linux Journal can help!
We offer here the DEFINITIVE DevOps for Dummies, a mobile Application Development Primer, and advice & help from the expert sources like:
- Linux Journal
- Users, Permissions and Multitenant Sites
- Flexible Access Control with Squid Proxy
- ZaTab: ZaReason's Open Tablet
- Are you an extremist?
- High-Availability Storage with HA-LVM
- Security in Three Ds: Detect, Decide and Deny
- Non-Linux FOSS: Telephone
- Tails above the Rest, Part II
- New Products
- Girls and Software