没有任何数据可供显示
开源项目社区 | 当前位置 : |
|
oss.trustie.net/open_source_projects | 主页 > 开源项目社区 > open-id-authentication |
open-id-authentication
|
0 | 0 | 5 |
贡献者 | 讨论 | 代码提交 |
OpenId Authentication Plugin For Ruby on RailsThis is a rewrite and complete clean up of the original open_id_authnetication located here: http://svn.rubyonrails.org/rails/plugins/open_id_authentication/
Provides a thin wrapper around the excellent ruby-openid gem from JanRan. Be sure to install that first:
gem install ruby-openidUnfortunately this plugin doesn't have user model generators or helpers to work with authentication. This plugin only provides easy way to communicate with an Open ID server. Maybe somebody can help and write some cool generators?
Installationscript/plugin install http://open-id-authentication.googlecode.com/svn/trunk/open_id_authentication/PrerequisitesOpenID authentication uses the session, so be sure that you haven't turned that off. It also relies on a number of database tables to store the authentication keys. So you'll have to run the migration to create these before you get started:
rake open_id_authentication:db:createThis code is completely decoupled from and user model and will simply return results upon success. It's up to you how to handle those results.
ExampleThis example is just to meant to demonstrate how you could use OpenID authentication.
config/routes.rb
map.open_id '/openid/:action', :controller => 'openid'app/views/openid/login.rhtml
OpenID:
"Signing in..." %>
app/controllers/openid_controller.rb
class OpenidController < ApplicationController
include OpenIdAuthentication
def login
return unless request.post?
status = begin_openid_authentication(params[:openid_url], open_id_path(:continue))
flash[:error] = case status
when :missing : 'Sorry, the OpenID is missing.'
when :failed : 'Sorry, the OpenID verification failed.'
when :timeout : 'Timed out.'
when :unknown : 'Not sure what happened.'
end
end
def continue
status = complete_openid_authentication
case status
when :missing : failed_login('Sorry, the OpenID server couldn\'t be found.')
when :canceled : failed_login('OpenID verification was canceled.')
when :failed : failed_login('Sorry, the OpenID verification failed.')
when :unknown : failed_login('Not sure what happened.')
when :success
# Handle User lookup or creation here...
# openid_result is a attr_reader for { :identity_url => String, :info => Hash }
render(:text => "okay! #{openid_result[:identity_url]} + #{openid_result[:info]}")
end
end
private
def failed_login(message)
flash[:error] = message
redirect_to(open_id_path(:login))
end
end