0.01
Repository is archived
No commit activity in last 3 years
No release in over 3 years
A warden strategy for authenticate with OpenID
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 1.2.9

Runtime

 Project Readme

Warden OpenID Strategy¶ ↑

Install¶ ↑

$ gem install warden-openid

Usage¶ ↑

1. Configure Warden uses OpenID strategy¶ ↑

require 'warden-openid'

use Rack::Session::Cookie
use Rack::OpenID
use Warden::Manager do |manager|
  manager.default_strategies :openid
  manager.failure_app = FailureApp
end

2. Setup user finder¶ ↑

Warden::OpenID.configure do |config|
  config.user_finder do |response|
    User.find_by_identity_url(response.identity_url)
  end
end

response is an instance of OpenID::Consumer::Response.

3. Create route and view¶ ↑

Example by Sinatra and Haml:

post '/signin' do
  authenticate!
end

%form(action='/signin' method='post')
  %input(type='text' name='openid_identifier')
  %input(type='submit' value='Sign in')

This strategy starts with openid_identifier parameter.

You may need to customize /unauthenticated route. Please refer to examples directory for details.

Fetch additional fields from server¶ ↑

Warden::OpenID.configure do |config|
  config.required_fields = 'email'
  config.optional_fields = %w(nickname fullname)

  config.user_finder do |response|
    fields = OpenID::SReg::Response.from_success_response(response)
    p fields['email']
    p fields['nickname']
  end
end

Caveats¶ ↑

If you use this with Rails, please don’t use OpenID::Store::Memory. A problem occurs by class reloading in the development mode.

For example, OpenID::Store::Filesystem is used instead:

require 'openid/store/filesystem'
Rails.configuration.middleware.use Rack::OpenID, OpenID::Store::Filesystem.new(Rails.root + 'tmp/openid')

Contributors¶ ↑

  • Philip H. MacIver

Note on Patches/Pull Requests¶ ↑

  • Fork the project.

  • Make your feature addition or bug fix.

  • Add tests for it. This is important so I don’t break it in a future version unintentionally.

  • Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)

  • Send me a pull request. Bonus points for topic branches.

Copyright © 2010 Keita Urashima. See LICENSE for details.