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.
|Dynamic DNS—an Object Lesson in Problem Solving||May 21, 2013|
|Using Salt Stack and Vagrant for Drupal Development||May 20, 2013|
|Making Linux and Android Get Along (It's Not as Hard as It Sounds)||May 16, 2013|
|Drupal Is a Framework: Why Everyone Needs to Understand This||May 15, 2013|
|Home, My Backup Data Center||May 13, 2013|
|Non-Linux FOSS: Seashore||May 10, 2013|
- RSS Feeds
- Dynamic DNS—an Object Lesson in Problem Solving
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
- Using Salt Stack and Vagrant for Drupal Development
- New Products
- A Topic for Discussion - Open Source Feature-Richness?
- Validate an E-Mail Address with PHP, the Right Way
- Drupal Is a Framework: Why Everyone Needs to Understand This
- What's the tweeting protocol?
- Tech Tip: Really Simple HTTP Server with Python
- Kernel Problem
54 min 19 sec ago
- BASH script to log IPs on public web server
5 hours 21 min ago
8 hours 57 min ago
- Reply to comment | Linux Journal
9 hours 29 min ago
- All the articles you talked
11 hours 53 min ago
- All the articles you talked
11 hours 56 min ago
- All the articles you talked
11 hours 57 min ago
16 hours 22 min ago
- Keeping track of IP address
18 hours 13 min ago
- Roll your own dynamic dns
23 hours 26 min ago
Enter to Win an Adafruit Pi Cobbler Breakout Kit for Raspberry Pi
It's Raspberry Pi month at Linux Journal. Each week in May, Adafruit will be giving away a Pi-related prize to a lucky, randomly drawn LJ reader. Winners will be announced weekly.
Fill out the fields below to enter to win this week's prize-- a Pi Cobbler Breakout Kit for Raspberry Pi.
Congratulations to our winners so far:
- 5-8-13, Pi Starter Pack: Jack Davis
- 5-15-13, Pi Model B 512MB RAM: Patrick Dunn
- 5-21-13, Prototyping Pi Plate Kit: Philip Kirby
- Next winner announced on 5-27-13!
Free Webinar: Hadoop
How to Build an Optimal Hadoop Cluster to Store and Maintain Unlimited Amounts of Data Using Microservers
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Some of key questions to be discussed are:
- What is the “typical” Hadoop cluster and what should be installed on the different machine types?
- Why should you consider the typical workload patterns when making your hardware decisions?
- Are all microservers created equal for Hadoop deployments?
- How do I plan for expansion if I require more compute, memory, storage or networking?