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.
|ContainerCon Vendors Offer Flexible Solutions for Managing All Your New Micro-VMs||Aug 24, 2016|
|Updates from LinuxCon and ContainerCon, Toronto, August 2016||Aug 23, 2016|
|NVMe over Fabrics Support Coming to the Linux 4.8 Kernel||Aug 22, 2016|
|What I Wish I’d Known When I Was an Embedded Linux Newbie||Aug 18, 2016|
|Pandas||Aug 17, 2016|
|Juniper Systems' Geode||Aug 16, 2016|
- Updates from LinuxCon and ContainerCon, Toronto, August 2016
- Download "Linux Management with Red Hat Satellite: Measuring Business Impact and ROI"
- What I Wish I’d Known When I Was an Embedded Linux Newbie
- NVMe over Fabrics Support Coming to the Linux 4.8 Kernel
- ContainerCon Vendors Offer Flexible Solutions for Managing All Your New Micro-VMs
- New Version of GParted
- All about printf
- Tor 0.2.8.6 Is Released
- Blender for Visual Effects
With all the industry talk about the benefits of Linux on Power and all the performance advantages offered by its open architecture, you may be considering a move in that direction. If you are thinking about analytics, big data and cloud computing, you would be right to evaluate Power. The idea of using commodity x86 hardware and replacing it every three years is an outdated cost model. It doesn’t consider the total cost of ownership, and it doesn’t consider the advantage of real processing power, high-availability and multithreading like a demon.
This ebook takes a look at some of the practical applications of the Linux on Power platform and ways you might bring all the performance power of this open architecture to bear for your organization. There are no smoke and mirrors here—just hard, cold, empirical evidence provided by independent sources. I also consider some innovative ways Linux on Power will be used in the future.Get the Guide