At the Forge - Authenticating to a Rails Application
Last month, we began to look at OpenID, the open standard for distributed identification on the Internet. OpenID allows you to have a single user profile, authenticated against a provider you trust, and to use that profile with many different Web sites and Internet applications. OpenID has been growing in popularity during the past few years, after it was first developed and used by blogging company LiveJournal. Since then, it has become a more popular and open standard, and is now supported by many Web sites, as well as all popular programming languages.
I was hoping to use this month's column to show how easy it is to make a Web application compliant with OpenID—or in OpenID terminology, to make it into an OpenID consumer. It turns out that adding OpenID capabilities isn't actually that complicated or difficult, particularly with a popular framework like Ruby on Rails, for which there are many established plugins.
However, I also found that the OpenID plugin for Rails works especially well with a plugin called acts_as_authenticated. This plugin provides a simple, secure and highly customizable authentication system for Rails applications. So this month, we are taking a slight detour, looking at how we can use acts_as_authenticated in Rails applications. Along the way, we can see how to download and use Rails plugins, an important part of Web development with Rails. Next month, we'll build on what we have created, adding OpenID to our application for a truly flexible set of login options for our users.
Although Rails provides a great deal of functionality for developers, it offers few application-level features. Rather, most of its functionality is in the form of objects and methods that programmers can use to create new applications. But, there are no built-in applications, or application fragments, or even a centralized database schema that developers can expect to find in every Rails installation.
The Rails core developers have said that this is done on purpose, because every application has different needs, and it would be impossible to please everyone. And indeed, I understand their point. Each of my applications always has needed to keep a slightly different type of information about users, let alone other types of data. Any choice the developers might make will be wrong for some people.
I happen to think there is a middle ground here. Perhaps the Rails core doesn't need to include a complete solution for users, groups and permissions. But, given the overwhelming number of applications that do define and use such objects, it would make sense to include an easily extensible skeleton within the framework itself.
Such extensions are unlikely to appear in the near future, given the strong feelings the Rails core team has expressed about them in the past. However, all is not lost. Rails includes a “plugin” system that makes it possible to download collections of code—including models, views, controllers and more—and to install them into an application. If you can find and install an appropriate plugin, you get something of a compromise solution. Once installed, the code acts as if it were an integral part of your application. And, of course, you can add only those plugins that are important to your particular application.
Because so many applications require users to register and authenticate, it should come as no surprise that there are a number of available plugins. One of the most popular is acts_as_authenticated, a plugin written by Rails core team member Rick Olson. The name does not refer to an actual declaration, but is rather a playful way of saying that it was designed to work with Rails. And, although the README file (displayed when you install the plugin) indicates that it has been deprecated (in favor of restful_authentication), acts_as_authenticated is popular and stable enough, and plays well enough with OpenID, that it is worth a look.
Rails plugins are installed with the built-in plugin tool, located in script/plugin. You can list the plugins that are available:
But, this will list only those plugins located at one of the sources known to the system. To see a list of these sources, simply type:
To add a new source to the list, simply say:
script/plugin source http://svn.techno-weenie.net/projects/plugins/
Sure enough, after doing this, running script/plugin sources shows the new URL. And, of course, now typing script/plugin list shows many new plugins, from both the old source and the new one.
Fast/Flexible Linux OS Recovery
On Demand Now
In this live one-hour webinar, learn how to enhance your existing backup strategies for complete disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible full-system recovery solution for UNIX and Linux systems.
Join Linux Journal's Shawn Powers and David Huffman, President/CEO, Storix, Inc.
Free to Linux Journal readers.Register Now!
- Download "Linux Management with Red Hat Satellite: Measuring Business Impact and ROI"
- Back to Backups
- A New Version of Rust Hits the Streets
- Google's Abacus Project: It's All about Trust
- Secure Desktops with Qubes: Introduction
- Seeing Red and Getting Sleep
- Fancy Tricks for Changing Numeric Base
- Secure Desktops with Qubes: Installation
- Working with Command Arguments
- CentOS 6.8 Released
Until recently, IBM’s Power Platform was looked upon as being the system that hosted IBM’s flavor of UNIX and proprietary operating system called IBM i. These servers often are found in medium-size businesses running ERP, CRM and financials for on-premise customers. By enabling the Power platform to run the Linux OS, IBM now has positioned Power to be the platform of choice for those already running Linux that are facing scalability issues, especially customers looking at analytics, big data or cloud computing.
￼Running Linux on IBM’s Power hardware offers some obvious benefits, including improved processing speed and memory bandwidth, inherent security, and simpler deployment and management. But if you look beyond the impressive architecture, you’ll also find an open ecosystem that has given rise to a strong, innovative community, as well as an inventory of system and network management applications that really help leverage the benefits offered by running Linux on Power.Get the Guide