OpenIdAuthenticationはruby-openid1.1.4にしか対応していません。ですが、gem1.0.1では1.1.4が正しく動作しないため、プラグインにパッチをあてて使うことにしました。

  1. ruby-openidをインストール(2.0.4)

       1  gem install ruby-openid
    

  2. pluginのインストール

       1  $ ./script/plugin install http://svn.rubyonrails.org/rails/plugins/open_id_authentication/
    

  3. パッチをあてる

    • パッチを入手ticket10604.diffとして保存
      http://dev.rubyonrails.org/ticket/10604

    • プラグインのところに移動させておく

         1   #{RAILS_ROOT}/vendor/plugins/open_id_authentication/ticket10604.diff
      

    • プラグインのルートに移動して、patchを当てる

         1  $ patch -p1 < ticket10604.diff
         2  patching file init.rb
         3  Hunk #1 FAILED at 1.
         4  1 out of 1 hunk FAILED -- saving rejects to file init.rb.rej
         5  patching file lib/generators/open_id_authentication_tables/open_id_authentication_tables_generator.rb
         6  patching file lib/generators/open_id_authentication_tables/templates/migration.rb
         7  patching file lib/open_id_authentication.rb
         8  Hunk #5 succeeded at 69 with fuzz 1 (offset -2 lines).
         9  Hunk #6 succeeded at 88 (offset -2 lines).
        10  Hunk #7 succeeded at 152 (offset -2 lines).
        11  patching file lib/open_id_authentication/association.rb
        12  patching file lib/open_id_authentication/db_store.rb
        13  patching file lib/open_id_authentication/nonce.rb
        14  patching file lib/open_id_authentication/setting.rb
        15  patching file tasks/open_id_authentication_tasks.rake
        16  patching file test/normalize_test.rb
        17  patching file test/open_id_authentication_test.rb
        18  patching file test/status_test.rb
      

  4. READMEにあるExampleの作業

    • テーブル作成

         1   rake open_id_authentication:db:create 
      

    • routesに下記を加える

         1    map.open_id_complete 'session', :controller => "sessions", :action => "create", :requirements => { :method => :get }
         2    map.resource :session
      

    • SessionsController、vews/sessions/new.html.erbの作成
      ここでmatakeさんと同じようにはまったのですが、SessionConroller#open_id_authenticationをREADMEにあるresult.successful?のほうを使うとプラグインに手を入れずに使うことができます。(agilewebdevelopment.comのExampleを使うとNG)

         1      def open_id_authentication
         2        authenticate_with_open_id do |result, identity_url|
         3          if result.successful? && @current_user = @account.users.find_by_identity_url(identity_url)
         4            successful_login
         5          else
         6            failed_login(result.message || "Sorry, no user by that identity URL exists (#{identity_url})")
         7          end
         8        end
         9      end
      

  5. ruby-openidのバージョン指定をはずす

       1  #open_id_authentication/init.rb
       2  begin
       3  #  gem 'ruby-openid', '=1.1.4'
       4    gem 'ruby-openid'
    

参考

posted by Png satoko on Wed 27 Feb 2008 at 16:40

OpenIdAuthentication is depend on gem ruby-openid 1.1.4. In addition, ruby-openid 1.1.4 is broken with 1.0.1 gem :(
So, I applied patch(Ticket#10604) and they works well.

  1. Install gem ruby-openid(2.0.4)

       1  gem install ruby-openid
    

  2. Install plugin

       1  $ ./script/plugin install http://svn.rubyonrails.org/rails/plugins/open_id_authentication/
    

  3. Apply patch

    • Get a patch and save as ticket10604.diff
      http://dev.rubyonrails.org/ticket/10604

    • Move diff file to plugin root

         1   #{RAILS_ROOT}/vendor/plugins/open_id_authentication/ticket10604.diff
      

    • Move to plugin root and do patch command

         1  $ patch -p1 < ticket10604.diff
         2  patching file init.rb
         3  Hunk #1 FAILED at 1.
         4  1 out of 1 hunk FAILED -- saving rejects to file init.rb.rej
         5  patching file lib/generators/open_id_authentication_tables/open_id_authentication_tables_generator.rb
         6  patching file lib/generators/open_id_authentication_tables/templates/migration.rb
         7  patching file lib/open_id_authentication.rb
         8  Hunk #5 succeeded at 69 with fuzz 1 (offset -2 lines).
         9  Hunk #6 succeeded at 88 (offset -2 lines).
        10  Hunk #7 succeeded at 152 (offset -2 lines).
        11  patching file lib/open_id_authentication/association.rb
        12  patching file lib/open_id_authentication/db_store.rb
        13  patching file lib/open_id_authentication/nonce.rb
        14  patching file lib/open_id_authentication/setting.rb
        15  patching file tasks/open_id_authentication_tasks.rake
        16  patching file test/normalize_test.rb
        17  patching file test/open_id_authentication_test.rb
        18  patching file test/status_test.rb
      

  4. Do some work in README

    • Creating tables

         1   rake open_id_authentication:db:create 
      

    • Add some routes

         1  #config/routes.rb
         2    map.open_id_complete 'session', :controller => "sessions", :action => "create", :requirements => { :method => :get }
         3    map.resource :session
      

    • Generate SessionsController, and create vews/sessions/new.html.erb
      Tip:NOT to use sample code in agilewebdevelopment.com. Use sample code in README.

         1      def open_id_authentication
         2        authenticate_with_open_id do |result, identity_url|
         3          if result.successful? && @current_user = @account.users.find_by_identity_url(identity_url)
         4            successful_login
         5          else
         6            failed_login(result.message || "Sorry, no user by that identity URL exists (#{identity_url})")
         7          end
         8        end
         9      end
      

  5. Ommit version of ruby-openid

       1  #open_id_authentication/init.rb
       2  begin
       3  #  gem 'ruby-openid', '=1.1.4'
       4    gem 'ruby-openid'
    

posted by Png hibi on Wed 27 Feb 2008 at 16:23 with 2 comments

My name is Genki Takiuchi. I was born in Tokyo at 1980, so I am 27.

I've started programming when I was 8 years old. Simple games brought me to the world defined by BASIC. 20 years made me pass through many languages such as C/C++, HDL, HLSL, Java, D, Perl, Scheme, Erlang, Haskell and Ruby.

I won the Minister of Education prize at the programming contest in Japan when I was 19. I had studied concentratedly about computer graphics (photorealistic rendering) and statistics.

And now, I have worked with Ruby on Rails for more than 2 years. I wrote some articles to "WEB+DB press" and "Nikkei Software" which are magazines published in Japan.

I have a life work that is to solve the problem in the computer graphics.

posted by Png takiuchi on Wed 27 Feb 2008 at 15:24

このブログに英語(非常にbrokenですが)で書いている記事を、 今後はもう一つのブログの方に書くことにしました。

理由としては、複数の言語が混在しているのは読みにくいのでは ないかということと、別なブログとして英語のブログを作ることで 英語の勉強に気合を入れるためです。

ということで、よろしくお願いいたします。

posted by Png genki on Wed 27 Feb 2008 at 13:48

I decided to separate entries into two blogs according to its language. This is the first entry which has written in English to this weblog.

I had decided learn about English about two years ago, but that is not achieved yet. The goal is so far. I want to communicate with cool programmers using English as a native or second language.

By the way, I plan to write something about Ruby on Rails, computer graphics (especially about offline rendering) and so on to this blog.

If you are familiar with Japanse, please visit "Hello, world!" the another weblog which is written Japanese.

Thank you.

posted by Png takiuchi on Wed 27 Feb 2008 at 13:27
Contents
OpenIdAuthenticationを使う: Rails2.x + gem 1.0.1 + ruby-openid2.0.4
Using OpenIdAuthentication with Rails2.x, gem1.0.1, ruby-openid2.0.4
About Me
英語のエントリを別なブログに分離します
I Started New Weblog in English
Comments
瀧内元気: MacOS版は以下にあります * [genki/ViMouse](https://githu... '23-1
KingofSmack: Here also good reads for this mobile applicatio... '14-5
Spencer: You don't have to re-compile it, this version w... '14-4
staiano: Any chance we can get a recompile for 10.9? '14-1
dsjf: https://gist.github.com/6bf1bf2c3cbb5eb6e7a7 これ... '13-1
Services from s21g
twpro(ツイプロ)
Twitterプロフィールを快適検索
地価2009
土地の値段を調べてみよう
MyRestaurant
自分だけのレストラン手帳
Formula
ブログに数式を埋め込める数式コミュニティ