ess / authlogic_remote_http

This is a simple add-on for authlogic that allows authentication against a remote HTTP Basic auth location.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

authlogic-remote-http

github.com/ess/authlogic_remote_http

DESCRIPTION:

This gem is still in development, but it’s usable as it is. It provides authlogic with the ability to auth users against a remote HTTP location that supports HTTP Basic Authentication.

It is based on the basic skeleton of pol’s fork of authlogic_ldap ( github.com/pol/authlogic_ldap )

FEATURES/PROBLEMS:

SYNOPSIS:

REQUIREMENTS:

  • authlogic

INSTALL:

  • script/plugin install git://github.com/ess/authlogic_remote_http.git

  • optionally add remote_http user/pass columns to your user model

  • add remote_http configuration options to your user and sessions models

EXAMPLE:

Before I begin, I’d like to apologize in advance for my tone. I’m not really one for businessworldspeak, and that tends to show muchly in my docs.

Much like authlogic itself, after you install the plugin, the rest is pretty much up to you. If you like, you can add a remote_http_login column to your database table. Personally, I prefer not to do so, but if you do, that’s cool.

At any rate, since I’m not using these columns, my User model looks like this:

class User < ActiveRecord::Base
  acts_as_authentic do |c|
    c.validate_remote_http_login = false
  end
end

I know … it’s sparse, but this is an example. Ever notice that examples are rarely actually useful?

Anyways, in order for everything to be shiny and happy, you’ll need to add some configuration options to your session (UserSession in this example) model as well:

class UserSession < Authlogic::Session::Base
  remote_http_uri 'http://thefulluri.to/your/remote/auth/'
  find_by_remote_http_login_method :find_or_create_by_login
end

There are a couple of things to note here. The first is that remote_http_uri MUST be a well-formed URI. It needs to have its scheme, a colon, a couple of slashes, a hostname, optionally a colon and a port number, another slash, and the full path to the location against which HTTP Basic auth should be performed. If this is a directory, you’re going to need the trailing slash as well.

Secondly, since I’ve not added a remote_http_login column to my user table, I need to specify the method that should be used to check that table. I’m pretty lazy when it comes down, so rather than taking the time to hassle the user for not already having registered, I’ve got my session model set up to just create the user if it doesn’t already exist in the database.

From this point, everything should Just Work (TM). If something fails, I’d appreciate a heads-up through the issue tracker on the github repo for the add-on.

LICENSE:

(The MIT License)

Copyright © 2009 Dennis Walters, II, ( smurfeater.com )

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

This is a simple add-on for authlogic that allows authentication against a remote HTTP Basic auth location.

License:MIT License


Languages

Language:Ruby 100.0%