Ticket #2500: openidV2-withplugin.patch

File openidV2-withplugin.patch, 82.3 KB (added by amm, 10 years ago)

OpenID patch V2 (with plugin included)

  • app/controllers/user_controller.rb

    diff -N -x .svn -r -u /usr/local/src/svn.openstreetmap.org/sites/rails_port/app/controllers/user_controller.rb ./app/controllers/user_controller.rb
    old new  
    4444    @title = t 'user.account.title'
    4545    @tokens = @user.oauth_tokens.find :all, :conditions => 'oauth_tokens.invalidated_at is null and oauth_tokens.authorized_at is not null'
    4646
     47    #The redirect from the OpenID provider reenters here again
     48    #and we need to pass the parameters through to the
     49    #open_id_authentication function
     50    if params[:open_id_complete]
     51      openid_verify('')
     52      return
     53    end
     54
    4755    if params[:user] and params[:user][:display_name] and params[:user][:description]
    4856      if params[:user][:email] != @user.email
    4957        @user.new_email = params[:user][:email]
     
    5563        @user.pass_crypt = params[:user][:pass_crypt]
    5664        @user.pass_crypt_confirmation = params[:user][:pass_crypt_confirmation]
    5765      end
     66      if (params[:user][:openid_url].length == 0)
     67        #Clearing doesn't need OpenID validation, so we can set it here.
     68        @user.openid_url = nil
     69      end
    5870
    5971      @user.description = params[:user][:description]
    6072      @user.languages = params[:user][:languages].split(",")
     
    7183          flash.now[:notice] = t 'user.account.flash update success'
    7284        end
    7385      end
     86
     87      if (params[:user][:openid_url].length > 0)
     88        begin
     89          @norm_openid_url = OpenIdAuthentication.normalize_identifier(params[:user][:openid_url])
     90          if (@norm_openid_url != @user.openid_url)
     91            #If the OpenID has changed, we want to check that it is a valid OpenID and one
     92            #the user has control over before saving the openID as a password equivalent for
     93            #the user.
     94            openid_verify(@norm_openid_url)
     95          end
     96        rescue
     97          flash.now[:error] = t 'user.login.openid invalid'
     98        end
     99      end
    74100    end
    75101  end
    76102
     103  def openid_specialcase_mapping(openid_url)
     104    #Special case gmail.com, as it is pontentially a popular OpenID provider and unlike
     105    #yahoo.com, where it works automatically, Google have hidden their OpenID endpoint
     106    #somewhere obscure making it less userfriendly.
     107    if (openid_url.match(/(.*)gmail.com(\/?)$/) or openid_url.match(/(.*)googlemail.com(\/?)$/) )
     108      return 'https://www.google.com/accounts/o8/id'
     109    end
     110
     111    return nil
     112  end 
     113
     114  def openid_verify(openid_url)
     115    authenticate_with_open_id(openid_url) do |result, identity_url|
     116      if result.successful?
     117        #We need to use the openid url passed back from the OpenID provider
     118        #rather than the one supplied by the user, as these can be different.
     119        #e.g. one can simply enter yahoo.com in the login box, i.e. no user specific url
     120        #only once it comes back from the OpenID provider do we know the unique address for
     121        #the user.
     122        @user.openid_url = identity_url
     123        if @user.save
     124          flash.now[:notice] = t 'user.account.flash update success'
     125        end
     126      else if result.missing?
     127             mapped_id = openid_specialcase_mapping(openid_url)
     128             if mapped_id
     129               openid_verify(mapped_id)
     130             else
     131               flash.now[:error] = t 'user.login.openid missing provider'
     132             end
     133           else if result.invalid?
     134                  flash.now[:error] = t 'user.login.openid invalid'
     135                else
     136                  flash.now[:error] = t 'user.login.auth failure'
     137                end
     138           end
     139      end
     140    end
     141  end
     142
     143
    77144  def set_home
    78145    if params[:user][:home_lat] and params[:user][:home_lon]
    79146      @user.home_lat = params[:user][:home_lat].to_f
     
    142209    # The user is logged in already, so don't show them the signup page, instead
    143210    # send them to the home page
    144211    redirect_to :controller => 'site', :action => 'index' if session[:user]
     212
     213    @nickname = params['nickname']
     214    @email = params['email']
    145215  end
    146216
    147217  def login
     218
     219    #The redirect from the OpenID provider reenters here again
     220    #and we need to pass the parameters through to the
     221    # open_id_authentication function
     222    if params[:open_id_complete]
     223      open_id_authentication('')
     224    end
     225
     226   
    148227    if params[:user] and session[:user].nil?
    149       email_or_display_name = params[:user][:email]
    150       pass = params[:user][:password]
    151       user = User.authenticate(:username => email_or_display_name, :password => pass)
    152       if user
    153         session[:user] = user.id
    154       elsif User.authenticate(:username => email_or_display_name, :password => pass, :inactive => true)
    155         flash.now[:error] = t 'user.login.account not active'
     228
     229      if !params[:user][:openid_url].empty?
     230        open_id_authentication(params[:user][:openid_url])
    156231      else
    157         flash.now[:error] = t 'user.login.auth failure'
     232        email_or_display_name = params[:user][:email]
     233        pass = params[:user][:password]
     234        user = User.authenticate(:username => email_or_display_name, :password => pass)
     235        if user
     236          session[:user] = user.id
     237        elsif User.authenticate(:username => email_or_display_name, :password => pass, :inactive => true)
     238          flash.now[:error] = t 'user.login.account not active'
     239        else
     240          flash.now[:error] = t 'user.login.auth failure'
     241        end
    158242      end
    159243    end
    160 
     244 
    161245    if session[:user]
    162246      # The user is logged in, if the referer param exists, redirect them to that
    163247      # unless they've also got a block on them, in which case redirect them to
     
    177261    @title = t 'user.login.title'
    178262  end
    179263
     264  def open_id_authentication(openid_url)
     265    #TODO: only ask for nickname and email, if we don't already have a user for that openID, in which case
     266    #email and nickname are already filled out. I don't know how to do that with ruby syntax though, as we
     267    #don't want to duplicate the do block
     268    #On the other hand it also doesn't matter too much if we ask every time, as the OpenID provider should
     269    #remember these results, and shouldn't repromt the user for these data each time.
     270    authenticate_with_open_id(openid_url, :return_to => request.protocol + request.host_with_port + '/login?referer=' + params[:referer], :optional => [:nickname, :email]) do |result, identity_url, registration|
     271      if result.successful?
     272        #We need to use the openid url passed back from the OpenID provider
     273        #rather than the one supplied by the user, as these can be different.
     274        #e.g. one can simply enter yahoo.com in the login box, i.e. no user specific url
     275        #only once it comes back from the OpenID provider do we know the unique address for
     276        #the user.
     277        user = User.find_by_openid_url(identity_url)
     278        if user
     279          if user.visible? and user.active?
     280            session[:user] = user.id
     281          else
     282            user = nil
     283            flash.now[:error] = t 'user.login.account not active'
     284          end
     285        else
     286          #We don't have a user registered to this OpenID. Redirect to the create account page
     287          #with username and email filled in if they have been given by the OpenID provider through
     288          #the simple registration protocol
     289          redirect_to :controller => 'user', :action => 'new', :nickname => registration['nickname'], :email => registration['email']
     290        end
     291      else if result.missing?
     292             #Try and apply some heuristics to make common cases more userfriendly
     293             mapped_id = openid_specialcase_mapping(openid_url)
     294             if mapped_id
     295               open_id_authentication(mapped_id)
     296             else
     297               flash.now[:error] = t 'user.login.openid missing provider'
     298             end
     299           else if result.invalid?
     300                  flash.now[:error] = t 'user.login.openid invalid'
     301                else
     302                  flash.now[:error] = t 'user.login.auth failure'
     303                end
     304           end
     305      end
     306    end
     307  end
     308
    180309  def logout
    181310    if session[:token]
    182311      token = UserToken.find_by_token(session[:token])
  • app/models/user.rb

    diff -N -x .svn -r -u /usr/local/src/svn.openstreetmap.org/sites/rails_port/app/models/user.rb ./app/models/user.rb
    old new  
    2222  validates_confirmation_of :pass_crypt#, :message => ' must match the confirmation password'
    2323  validates_uniqueness_of :display_name, :allow_nil => true
    2424  validates_uniqueness_of :email
     25  validates_uniqueness_of :openid_url, :allow_nil => true
    2526  validates_length_of :pass_crypt, :within => 8..255
    2627  validates_length_of :display_name, :within => 3..255, :allow_nil => true
    2728  validates_length_of :email, :within => 6..255
  • app/views/user/account.html.erb

    diff -N -x .svn -r -u /usr/local/src/svn.openstreetmap.org/sites/rails_port/app/views/user/account.html.erb ./app/views/user/account.html.erb
    old new  
    55  <tr><td class="fieldName"><%= t 'user.new.display name' %></td><td><%= f.text_field :display_name %></td></tr>
    66  <tr><td class="fieldName"><%= t 'user.new.email address' %></td><td><%= f.text_field :email, {:size => 50, :maxlength => 255} %> <span class="minorNote"><%= t 'user.account.email never displayed publicly' %></span></td></tr>
    77  <tr><td class="fieldName" style="padding-bottom:0px;"><%= t 'user.new.password' %></td><td style="padding-bottom:0px;"><%= f.password_field :pass_crypt, {:value => '', :size => 30, :maxlength => 255} %></td></tr>
    8   <tr><td class="fieldName"><%= t 'user.new.confirm password' %></td><td><%= f.password_field :pass_crypt_confirmation, {:value => '', :size => 30, :maxlength => 255} %></td></tr>
     8  <tr><td class="fieldName" style="padding-bottom:0px;"><%= t 'user.new.confirm password' %></td><td><%= f.password_field :pass_crypt_confirmation, {:value => '', :size => 30, :maxlength => 255} %></td></tr>
     9  <tr><td class="fieldName" ><%= t 'user.account.openid.openid' %></td><td style="padding-bottom:0px;"><%= f.text_field :openid_url %> (<a href="<%= t 'user.account.openid.link' %>" target="_new"><%= t 'user.account.openid.link text' %></a>) </td></tr>
    910
    1011  <tr>
    1112  <td class="fieldName" valign="top"><%= t 'user.account.public editing.heading' %></td>
  • app/views/user/login.html.erb

    diff -N -x .svn -r -u /usr/local/src/svn.openstreetmap.org/sites/rails_port/app/views/user/login.html.erb ./app/views/user/login.html.erb
    old new  
    1 <h1><%= t 'user.login.heading' %></h1>
     1        <h1><%= t 'user.login.heading' %></h1>
    22
    33<p><%= t 'user.login.please login', :create_user_link => link_to(t('user.login.create_account'), :controller => 'user', :action => 'new', :referer => params[:referer]) %></p>
    44
     
    77<table id="loginForm">
    88  <tr><td class="fieldName"><%= t 'user.login.email or username' %></td><td><%= text_field('user', 'email',{:size => 28, :maxlength => 255, :tabindex => 1}) %></td></tr>
    99  <tr><td class="fieldName"><%= t 'user.login.password' %></td><td><%= password_field('user', 'password',{:size => 28, :maxlength => 255, :tabindex => 2}) %> <span class="minorNote">(<%= link_to t('user.login.lost password link'), :controller => 'user', :action => 'lost_password' %>)</span></td></tr>
    10   <tr><td colspan="2">&nbsp;<!--vertical spacer--></td></tr>
    11   <tr><td></td><td align="right"><%= submit_tag t('user.login.login_button'), :tabindex => 3 %></td></tr>
     10<tr><td colspan="2">&nbsp;<!--vertical spacer--></td></tr>
     11<tr><td></td><td align="right"><%= submit_tag t('user.login.login_button'), :tabindex => 3 %></td></tr>
     12<tr><td colspan = "3"><h4><%= t 'user.login.alternatively' %></h4></td></tr>
     13
     14
     15<tr><td colspan="2"><%= t 'user.login.openid description' %> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(<a href="<%= t 'user.account.openid.link' %>" target="_new"><%= t 'user.account.openid.link text' %></a>)</td></tr>
     16
     17<tr><td class="fieldName"><%= t 'user.login.openid' %></td><td><%= text_field('user', 'openid_url',{:size => 28, :maxlength => 255, :tabindex => 3}) %></td></tr>
     18<tr><td colspan="2">&nbsp;<!--vertical spacer--></td></tr>
     19<tr><td></td><td align="right"><%= submit_tag t('user.login.login_button'), :tabindex => 3 %></td></tr>
    1220</table>
    1321<% end %>
  • app/views/user/new.html.erb

    diff -N -x .svn -r -u /usr/local/src/svn.openstreetmap.org/sites/rails_port/app/views/user/new.html.erb ./app/views/user/new.html.erb
    old new  
    2121<% form_tag :action => 'save' do %>
    2222<%= hidden_field_tag('referer', h(params[:referer])) unless params[:referer].nil? %>
    2323<table id="signupForm">
    24   <tr><td class="fieldName"><%= t 'user.new.email address' %></td><td><%= text_field('user', 'email',{:size => 50, :maxlength => 255, :tabindex => 1}) %></td></tr>
     24  <tr><td class="fieldName"><%= t 'user.new.email address' %></td><td><%= text_field('user', 'email',{:size => 50, :maxlength => 255, :tabindex => 1, :value => @email}) %></td></tr>
    2525  <tr><td class="fieldName"><%= t 'user.new.confirm email address' %></td><td><%= text_field('user', 'email_confirmation',{:size => 50, :maxlength => 255, :tabindex => 2}) %></td></tr>
    2626  <tr><td></td><td><span class="minorNote"><%= t 'user.new.not displayed publicly' %></span></td></tr>
    2727  <tr><td colspan="2">&nbsp;<!--vertical spacer--></td></tr>
    28   <tr><td class="fieldName"><%= t 'user.new.display name' %></td><td><%= text_field('user', 'display_name',{:size => 30, :maxlength => 255, :tabindex => 3}) %></td></tr>
     28  <tr><td class="fieldName"><%= t 'user.new.display name' %></td><td><%= text_field('user', 'display_name',{:size => 30, :maxlength => 255, :tabindex => 3, :value => @nickname}) %></td></tr>
    2929  <tr><td></td><td><span class="minorNote"><%= t 'user.new.display name description' %></span></td></tr>
    3030  <tr><td colspan="2">&nbsp;<!--vertical spacer--></td></tr>
    3131  <tr><td class="fieldName"><%= t 'user.new.password' %></td><td><%= password_field('user', 'pass_crypt',{:size => 30, :maxlength => 255, :tabindex => 4}) %></td></tr>
  • config/environment.rb

    diff -N -x .svn -r -u /usr/local/src/svn.openstreetmap.org/sites/rails_port/config/environment.rb ./config/environment.rb
    old new  
    5252  config.gem 'rmagick', :lib => 'RMagick'
    5353  config.gem 'oauth', :version => '>= 0.3.6'
    5454  config.gem 'httpclient'
     55  config.gem 'ruby-openid', :lib => 'openid', :version => '>=2.0.4'
    5556
    5657  # Only load the plugins named here, in the order given. By default, all plugins
    5758  # in vendor/plugins are loaded in alphabetical order.
  • config/locales/en.yml

    diff -N -x .svn -r -u /usr/local/src/svn.openstreetmap.org/sites/rails_port/config/locales/en.yml ./config/locales/en.yml
    old new  
    13371337      create_account: "create an account"
    13381338      email or username: "Email Address or Username:"
    13391339      password: "Password:"
     1340      openid: "OpenID:"
     1341      openid description: "Use your OpenID to login"
     1342      alternatively: "Alternatively"
    13401343      lost password link: "Lost your password?"
    13411344      login_button: "Login"
    13421345      account not active: "Sorry, your account is not active yet.<br />Please click on the link in the account confirmation email to activate your account."
    13431346      auth failure: "Sorry, could not log in with those details."
     1347      openid missing provider: "Sorry, could not contact your OpenID provider"
     1348      openid invalid: "Sorry, your OpenID seems misformed"
    13441349    lost_password:
    13451350      title: "Lost password"
    13461351      heading: "Forgotten Password?"
     
    14371442      title: "Edit account"
    14381443      my settings: My settings
    14391444      email never displayed publicly: "(never displayed publicly)"
     1445      openid:
     1446        openid: "OpenID:"
     1447        link: "http://wiki.openstreetmap.org/wiki/OpenID"
     1448        link text: "what is this?"
    14401449      public editing:
    14411450        heading: "Public editing:"
    14421451        enabled: "Enabled. Not anonymous and can edit data."
  • db/migrate/048_add_open_id_authentication_tables.rb

    diff -N -x .svn -r -u /usr/local/src/svn.openstreetmap.org/sites/rails_port/db/migrate/048_add_open_id_authentication_tables.rb ./db/migrate/048_add_open_id_authentication_tables.rb
    old new  
     1class AddOpenIdAuthenticationTables < ActiveRecord::Migration
     2  def self.up
     3    create_table :open_id_authentication_associations, :force => true do |t|
     4      t.integer :issued, :lifetime
     5      t.string :handle, :assoc_type
     6      t.binary :server_url, :secret
     7    end
     8
     9    create_table :open_id_authentication_nonces, :force => true do |t|
     10      t.integer :timestamp, :null => false
     11      t.string :server_url, :null => true
     12      t.string :salt, :null => false
     13    end
     14   
     15    add_column :users, :openid_url, :string
     16
     17    add_index :users, [:openid_url], :name => "user_openid_unique_idx", :unique => true
     18    add_index :open_id_authentication_associations, [:server_url], :name => "open_id_associations_server_url_idx"
     19    add_index :open_id_authentication_nonces, [:timestamp], :name => "open_id_nonces_timestamp_idx"
     20  end
     21
     22  def self.down
     23    remove_index :users, :name => "user_openid_unique_idx"
     24    remove_index :open_id_authentication_associations, :name => "open_id_associations_server_url_idx"
     25    remove_index :open_id_authentication_nonces, :name => "open_id_nonces_timestamp_idx"
     26    remove_column :users, :openid_url
     27    drop_table :open_id_authentication_associations
     28    drop_table :open_id_authentication_nonces
     29  end
     30end
  • vendor/plugins/open_id_authentication/CHANGELOG

    diff -N -x .svn -r -u /usr/local/src/svn.openstreetmap.org/sites/rails_port/vendor/plugins/open_id_authentication/CHANGELOG ./vendor/plugins/open_id_authentication/CHANGELOG
    old new  
     1* Fake HTTP method from OpenID server since they only support a GET. Eliminates the need to set an extra route to match the server's reply. [Josh Peek]
     2
     3* OpenID 2.0 recommends that forms should use the field name "openid_identifier" rather than "openid_url" [Josh Peek]
     4
     5* Return open_id_response.display_identifier to the application instead of .endpoints.claimed_id. [nbibler]
     6
     7* Add Timeout protection [Rick]
     8
     9* An invalid identity url passed through authenticate_with_open_id will no longer raise an InvalidOpenId exception. Instead it will return Result[:missing] to the completion block.
     10
     11* Allow a return_to option to be used instead of the requested url [Josh Peek]
     12
     13* Updated plugin to use Ruby OpenID 2.x.x [Josh Peek]
     14
     15* Tied plugin to ruby-openid 1.1.4 gem until we can make it compatible with 2.x [DHH]
     16
     17* Use URI instead of regexps to normalize the URL and gain free, better matching #8136 [dkubb]
     18
     19* Allow -'s in #normalize_url [Rick]
     20
     21* remove instance of mattr_accessor, it was breaking tests since they don't load ActiveSupport.  Fix Timeout test [Rick]
     22
     23* Throw a InvalidOpenId exception instead of just a RuntimeError when the URL can't be normalized [DHH]
     24
     25* Just use the path for the return URL, so extra query parameters don't interfere [DHH]
     26
     27* Added a new default database-backed store after experiencing trouble with the filestore on NFS. The file store is still available as an option [DHH]
     28
     29* Added normalize_url and applied it to all operations going through the plugin [DHH]
     30
     31* Removed open_id? as the idea of using the same input box for both OpenID and username has died -- use using_open_id? instead (which checks for the presence of params[:openid_url] by default) [DHH]
     32
     33* Added OpenIdAuthentication::Result to make it easier to deal with default situations where you don't care to do something particular for each error state [DHH]
     34
     35* Stop relying on root_url being defined, we can just grab the current url instead [DHH]
     36 No newline at end of file
  • vendor/plugins/open_id_authentication/generators/open_id_authentication_tables/open_id_authentication_tables_generator.rb

    diff -N -x .svn -r -u /usr/local/src/svn.openstreetmap.org/sites/rails_port/vendor/plugins/open_id_authentication/generators/open_id_authentication_tables/open_id_authentication_tables_generator.rb ./vendor/plugins/open_id_authentication/generators/open_id_authentication_tables/open_id_authentication_tables_generator.rb
    old new  
     1class OpenIdAuthenticationTablesGenerator < Rails::Generator::NamedBase
     2  def initialize(runtime_args, runtime_options = {})
     3    super
     4  end
     5
     6  def manifest
     7    record do |m|
     8      m.migration_template 'migration.rb', 'db/migrate'
     9    end
     10  end
     11end
  • vendor/plugins/open_id_authentication/generators/open_id_authentication_tables/templates/migration.rb

    diff -N -x .svn -r -u /usr/local/src/svn.openstreetmap.org/sites/rails_port/vendor/plugins/open_id_authentication/generators/open_id_authentication_tables/templates/migration.rb ./vendor/plugins/open_id_authentication/generators/open_id_authentication_tables/templates/migration.rb
    old new  
     1class <%= class_name %> < ActiveRecord::Migration
     2  def self.up
     3    create_table :open_id_authentication_associations, :force => true do |t|
     4      t.integer :issued, :lifetime
     5      t.string :handle, :assoc_type
     6      t.binary :server_url, :secret
     7    end
     8
     9    create_table :open_id_authentication_nonces, :force => true do |t|
     10      t.integer :timestamp, :null => false
     11      t.string :server_url, :null => true
     12      t.string :salt, :null => false
     13    end
     14  end
     15
     16  def self.down
     17    drop_table :open_id_authentication_associations
     18    drop_table :open_id_authentication_nonces
     19  end
     20end
  • vendor/plugins/open_id_authentication/generators/upgrade_open_id_authentication_tables/templates/migration.rb

    diff -N -x .svn -r -u /usr/local/src/svn.openstreetmap.org/sites/rails_port/vendor/plugins/open_id_authentication/generators/upgrade_open_id_authentication_tables/templates/migration.rb ./vendor/plugins/open_id_authentication/generators/upgrade_open_id_authentication_tables/templates/migration.rb
    old new  
     1class <%= class_name %> < ActiveRecord::Migration
     2  def self.up
     3    drop_table :open_id_authentication_settings
     4    drop_table :open_id_authentication_nonces
     5
     6    create_table :open_id_authentication_nonces, :force => true do |t|
     7      t.integer :timestamp, :null => false
     8      t.string :server_url, :null => true
     9      t.string :salt, :null => false
     10    end
     11  end
     12
     13  def self.down
     14    drop_table :open_id_authentication_nonces
     15
     16    create_table :open_id_authentication_nonces, :force => true do |t|
     17      t.integer :created
     18      t.string :nonce
     19    end
     20
     21    create_table :open_id_authentication_settings, :force => true do |t|
     22      t.string :setting
     23      t.binary :value
     24    end
     25  end
     26end
  • vendor/plugins/open_id_authentication/generators/upgrade_open_id_authentication_tables/upgrade_open_id_authentication_tables_generator.rb

    diff -N -x .svn -r -u /usr/local/src/svn.openstreetmap.org/sites/rails_port/vendor/plugins/open_id_authentication/generators/upgrade_open_id_authentication_tables/upgrade_open_id_authentication_tables_generator.rb ./vendor/plugins/open_id_authentication/generators/upgrade_open_id_authentication_tables/upgrade_open_id_authentication_tables_generator.rb
    old new  
     1class UpgradeOpenIdAuthenticationTablesGenerator < Rails::Generator::NamedBase
     2  def initialize(runtime_args, runtime_options = {})
     3    super
     4  end
     5
     6  def manifest
     7    record do |m|
     8      m.migration_template 'migration.rb', 'db/migrate'
     9    end
     10  end
     11end
  • vendor/plugins/open_id_authentication/.git/config

    diff -N -x .svn -r -u /usr/local/src/svn.openstreetmap.org/sites/rails_port/vendor/plugins/open_id_authentication/.git/config ./vendor/plugins/open_id_authentication/.git/config
    old new  
     1[core]
     2        repositoryformatversion = 0
     3        filemode = true
     4        bare = false
     5        logallrefupdates = true
     6[remote "origin"]
     7        fetch = +refs/heads/*:refs/remotes/origin/*
     8        url = git://github.com/rails/open_id_authentication
     9[branch "master"]
     10        remote = origin
     11        merge = refs/heads/master
  • vendor/plugins/open_id_authentication/.git/description

    diff -N -x .svn -r -u /usr/local/src/svn.openstreetmap.org/sites/rails_port/vendor/plugins/open_id_authentication/.git/description ./vendor/plugins/open_id_authentication/.git/description
    old new  
     1Unnamed repository; edit this file 'description' to name the repository.
  • vendor/plugins/open_id_authentication/.git/HEAD

    diff -N -x .svn -r -u /usr/local/src/svn.openstreetmap.org/sites/rails_port/vendor/plugins/open_id_authentication/.git/HEAD ./vendor/plugins/open_id_authentication/.git/HEAD
    old new  
     1ref: refs/heads/master
  • vendor/plugins/open_id_authentication/.git/hooks/applypatch-msg.sample

    diff -N -x .svn -r -u /usr/local/src/svn.openstreetmap.org/sites/rails_port/vendor/plugins/open_id_authentication/.git/hooks/applypatch-msg.sample ./vendor/plugins/open_id_authentication/.git/hooks/applypatch-msg.sample
    old new  
     1#!/bin/sh
     2#
     3# An example hook script to check the commit log message taken by
     4# applypatch from an e-mail message.
     5#
     6# The hook should exit with non-zero status after issuing an
     7# appropriate message if it wants to stop the commit.  The hook is
     8# allowed to edit the commit message file.
     9#
     10# To enable this hook, rename this file to "applypatch-msg".
     11
     12. git-sh-setup
     13test -x "$GIT_DIR/hooks/commit-msg" &&
     14        exec "$GIT_DIR/hooks/commit-msg" ${1+"$@"}
     15:
  • vendor/plugins/open_id_authentication/.git/hooks/commit-msg.sample

    diff -N -x .svn -r -u /usr/local/src/svn.openstreetmap.org/sites/rails_port/vendor/plugins/open_id_authentication/.git/hooks/commit-msg.sample ./vendor/plugins/open_id_authentication/.git/hooks/commit-msg.sample
    old new  
     1#!/bin/sh
     2#
     3# An example hook script to check the commit log message.
     4# Called by git-commit with one argument, the name of the file
     5# that has the commit message.  The hook should exit with non-zero
     6# status after issuing an appropriate message if it wants to stop the
     7# commit.  The hook is allowed to edit the commit message file.
     8#
     9# To enable this hook, rename this file to "commit-msg".
     10
     11# Uncomment the below to add a Signed-off-by line to the message.
     12# Doing this in a hook is a bad idea in general, but the prepare-commit-msg
     13# hook is more suited to it.
     14#
     15# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
     16# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1"
     17
     18# This example catches duplicate Signed-off-by lines.
     19
     20test "" = "$(grep '^Signed-off-by: ' "$1" |
     21         sort | uniq -c | sed -e '/^[   ]*1[    ]/d')" || {
     22        echo >&2 Duplicate Signed-off-by lines.
     23        exit 1
     24}
  • vendor/plugins/open_id_authentication/.git/hooks/post-commit.sample

    diff -N -x .svn -r -u /usr/local/src/svn.openstreetmap.org/sites/rails_port/vendor/plugins/open_id_authentication/.git/hooks/post-commit.sample ./vendor/plugins/open_id_authentication/.git/hooks/post-commit.sample
    old new  
     1#!/bin/sh
     2#
     3# An example hook script that is called after a successful
     4# commit is made.
     5#
     6# To enable this hook, rename this file to "post-commit".
     7
     8: Nothing
  • vendor/plugins/open_id_authentication/.git/hooks/post-receive.sample

    diff -N -x .svn -r -u /usr/local/src/svn.openstreetmap.org/sites/rails_port/vendor/plugins/open_id_authentication/.git/hooks/post-receive.sample ./vendor/plugins/open_id_authentication/.git/hooks/post-receive.sample
    old new  
     1#!/bin/sh
     2#
     3# An example hook script for the "post-receive" event.
     4#
     5# The "post-receive" script is run after receive-pack has accepted a pack
     6# and the repository has been updated.  It is passed arguments in through
     7# stdin in the form
     8#  <oldrev> <newrev> <refname>
     9# For example:
     10#  aa453216d1b3e49e7f6f98441fa56946ddcd6a20 68f7abf4e6f922807889f52bc043ecd31b79f814 refs/heads/master
     11#
     12# see contrib/hooks/ for an sample, or uncomment the next line and
     13# rename the file to "post-receive".
     14
     15#. /usr/share/doc/git-core/contrib/hooks/post-receive-email
  • vendor/plugins/open_id_authentication/.git/hooks/post-update.sample

    diff -N -x .svn -r -u /usr/local/src/svn.openstreetmap.org/sites/rails_port/vendor/plugins/open_id_authentication/.git/hooks/post-update.sample ./vendor/plugins/open_id_authentication/.git/hooks/post-update.sample
    old new  
     1#!/bin/sh
     2#
     3# An example hook script to prepare a packed repository for use over
     4# dumb transports.
     5#
     6# To enable this hook, rename this file to "post-update".
     7
     8exec git-update-server-info
  • vendor/plugins/open_id_authentication/.git/hooks/pre-applypatch.sample

    diff -N -x .svn -r -u /usr/local/src/svn.openstreetmap.org/sites/rails_port/vendor/plugins/open_id_authentication/.git/hooks/pre-applypatch.sample ./vendor/plugins/open_id_authentication/.git/hooks/pre-applypatch.sample
    old new  
     1#!/bin/sh
     2#
     3# An example hook script to verify what is about to be committed
     4# by applypatch from an e-mail message.
     5#
     6# The hook should exit with non-zero status after issuing an
     7# appropriate message if it wants to stop the commit.
     8#
     9# To enable this hook, rename this file to "pre-applypatch".
     10
     11. git-sh-setup
     12test -x "$GIT_DIR/hooks/pre-commit" &&
     13        exec "$GIT_DIR/hooks/pre-commit" ${1+"$@"}
     14:
  • vendor/plugins/open_id_authentication/.git/hooks/pre-commit.sample

    diff -N -x .svn -r -u /usr/local/src/svn.openstreetmap.org/sites/rails_port/vendor/plugins/open_id_authentication/.git/hooks/pre-commit.sample ./vendor/plugins/open_id_authentication/.git/hooks/pre-commit.sample
    old new  
     1#!/bin/sh
     2#
     3# An example hook script to verify what is about to be committed.
     4# Called by git-commit with no arguments.  The hook should
     5# exit with non-zero status after issuing an appropriate message if
     6# it wants to stop the commit.
     7#
     8# To enable this hook, rename this file to "pre-commit".
     9
     10if git-rev-parse --verify HEAD >/dev/null 2>&1
     11then
     12        against=HEAD
     13else
     14        # Initial commit: diff against an empty tree object
     15        against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
     16fi
     17
     18exec git diff-index --check --cached $against --
  • vendor/plugins/open_id_authentication/.git/hooks/prepare-commit-msg.sample

    diff -N -x .svn -r -u /usr/local/src/svn.openstreetmap.org/sites/rails_port/vendor/plugins/open_id_authentication/.git/hooks/prepare-commit-msg.sample ./vendor/plugins/open_id_authentication/.git/hooks/prepare-commit-msg.sample
    old new  
     1#!/bin/sh
     2#
     3# An example hook script to prepare the commit log message.
     4# Called by git-commit with the name of the file that has the
     5# commit message, followed by the description of the commit
     6# message's source.  The hook's purpose is to edit the commit
     7# message file.  If the hook fails with a non-zero status,
     8# the commit is aborted.
     9#
     10# To enable this hook, rename this file to "prepare-commit-msg".
     11
     12# This hook includes three examples.  The first comments out the
     13# "Conflicts:" part of a merge commit.
     14#
     15# The second includes the output of "git diff --name-status -r"
     16# into the message, just before the "git status" output.  It is
     17# commented because it doesn't cope with --amend or with squashed
     18# commits.
     19#
     20# The third example adds a Signed-off-by line to the message, that can
     21# still be edited.  This is rarely a good idea.
     22
     23case "$2,$3" in
     24  merge,)
     25    perl -i.bak -ne 's/^/# /, s/^# #/#/ if /^Conflicts/ .. /#/; print' "$1" ;;
     26
     27# ,|template,)
     28#   perl -i.bak -pe '
     29#      print "\n" . `git diff --cached --name-status -r`
     30#        if /^#/ && $first++ == 0' "$1" ;;
     31
     32  *) ;;
     33esac
     34
     35# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
     36# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1"
  • vendor/plugins/open_id_authentication/.git/hooks/pre-rebase.sample

    diff -N -x .svn -r -u /usr/local/src/svn.openstreetmap.org/sites/rails_port/vendor/plugins/open_id_authentication/.git/hooks/pre-rebase.sample ./vendor/plugins/open_id_authentication/.git/hooks/pre-rebase.sample
    old new  
     1#!/bin/sh
     2#
     3# Copyright (c) 2006, 2008 Junio C Hamano
     4#
     5# The "pre-rebase" hook is run just before "git-rebase" starts doing
     6# its job, and can prevent the command from running by exiting with
     7# non-zero status.
     8#
     9# The hook is called with the following parameters:
     10#
     11# $1 -- the upstream the series was forked from.
     12# $2 -- the branch being rebased (or empty when rebasing the current branch).
     13#
     14# This sample shows how to prevent topic branches that are already
     15# merged to 'next' branch from getting rebased, because allowing it
     16# would result in rebasing already published history.
     17
     18publish=next
     19basebranch="$1"
     20if test "$#" = 2
     21then
     22        topic="refs/heads/$2"
     23else
     24        topic=`git symbolic-ref HEAD` ||
     25        exit 0 ;# we do not interrupt rebasing detached HEAD
     26fi
     27
     28case "$topic" in
     29refs/heads/??/*)
     30        ;;
     31*)
     32        exit 0 ;# we do not interrupt others.
     33        ;;
     34esac
     35
     36# Now we are dealing with a topic branch being rebased
     37# on top of master.  Is it OK to rebase it?
     38
     39# Does the topic really exist?
     40git show-ref -q "$topic" || {
     41        echo >&2 "No such branch $topic"
     42        exit 1
     43}
     44
     45# Is topic fully merged to master?
     46not_in_master=`git-rev-list --pretty=oneline ^master "$topic"`
     47if test -z "$not_in_master"
     48then
     49        echo >&2 "$topic is fully merged to master; better remove it."
     50        exit 1 ;# we could allow it, but there is no point.
     51fi
     52
     53# Is topic ever merged to next?  If so you should not be rebasing it.
     54only_next_1=`git-rev-list ^master "^$topic" ${publish} | sort`
     55only_next_2=`git-rev-list ^master           ${publish} | sort`
     56if test "$only_next_1" = "$only_next_2"
     57then
     58        not_in_topic=`git-rev-list "^$topic" master`
     59        if test -z "$not_in_topic"
     60        then
     61                echo >&2 "$topic is already up-to-date with master"
     62                exit 1 ;# we could allow it, but there is no point.
     63        else
     64                exit 0
     65        fi
     66else
     67        not_in_next=`git-rev-list --pretty=oneline ^${publish} "$topic"`
     68        perl -e '
     69                my $topic = $ARGV[0];
     70                my $msg = "* $topic has commits already merged to public branch:\n";
     71                my (%not_in_next) = map {
     72                        /^([0-9a-f]+) /;
     73                        ($1 => 1);
     74                } split(/\n/, $ARGV[1]);
     75                for my $elem (map {
     76                                /^([0-9a-f]+) (.*)$/;
     77                                [$1 => $2];
     78                        } split(/\n/, $ARGV[2])) {
     79                        if (!exists $not_in_next{$elem->[0]}) {
     80                                if ($msg) {
     81                                        print STDERR $msg;
     82                                        undef $msg;
     83                                }
     84                                print STDERR " $elem->[1]\n";
     85                        }
     86                }
     87        ' "$topic" "$not_in_next" "$not_in_master"
     88        exit 1
     89fi
     90
     91exit 0
     92
     93################################################################
     94
     95This sample hook safeguards topic branches that have been
     96published from being rewound.
     97
     98The workflow assumed here is:
     99
     100 * Once a topic branch forks from "master", "master" is never
     101   merged into it again (either directly or indirectly).
     102
     103 * Once a topic branch is fully cooked and merged into "master",
     104   it is deleted.  If you need to build on top of it to correct
     105   earlier mistakes, a new topic branch is created by forking at
     106   the tip of the "master".  This is not strictly necessary, but
     107   it makes it easier to keep your history simple.
     108
     109 * Whenever you need to test or publish your changes to topic
     110   branches, merge them into "next" branch.
     111
     112The script, being an example, hardcodes the publish branch name
     113to be "next", but it is trivial to make it configurable via
     114$GIT_DIR/config mechanism.
     115
     116With this workflow, you would want to know:
     117
     118(1) ... if a topic branch has ever been merged to "next".  Young
     119    topic branches can have stupid mistakes you would rather
     120    clean up before publishing, and things that have not been
     121    merged into other branches can be easily rebased without
     122    affecting other people.  But once it is published, you would
     123    not want to rewind it.
     124
     125(2) ... if a topic branch has been fully merged to "master".
     126    Then you can delete it.  More importantly, you should not
     127    build on top of it -- other people may already want to
     128    change things related to the topic as patches against your
     129    "master", so if you need further changes, it is better to
     130    fork the topic (perhaps with the same name) afresh from the
     131    tip of "master".
     132
     133Let's look at this example:
     134
     135                   o---o---o---o---o---o---o---o---o---o "next"
     136                  /       /           /           /
     137                 /   a---a---b A     /           /
     138                /   /               /           /
     139               /   /   c---c---c---c B         /
     140              /   /   /             \         /
     141             /   /   /   b---b C     \       /
     142            /   /   /   /             \     /
     143    ---o---o---o---o---o---o---o---o---o---o---o "master"
     144
     145
     146A, B and C are topic branches.
     147
     148 * A has one fix since it was merged up to "next".
     149
     150 * B has finished.  It has been fully merged up to "master" and "next",
     151   and is ready to be deleted.
     152
     153 * C has not merged to "next" at all.
     154
     155We would want to allow C to be rebased, refuse A, and encourage
     156B to be deleted.
     157
     158To compute (1):
     159
     160        git-rev-list ^master ^topic next
     161        git-rev-list ^master        next
     162
     163        if these match, topic has not merged in next at all.
     164
     165To compute (2):
     166
     167        git-rev-list master..topic
     168
     169        if this is empty, it is fully merged to "master".
  • vendor/plugins/open_id_authentication/.git/hooks/update.sample

    diff -N -x .svn -r -u /usr/local/src/svn.openstreetmap.org/sites/rails_port/vendor/plugins/open_id_authentication/.git/hooks/update.sample ./vendor/plugins/open_id_authentication/.git/hooks/update.sample
    old new  
     1#!/bin/sh
     2#
     3# An example hook script to blocks unannotated tags from entering.
     4# Called by git-receive-pack with arguments: refname sha1-old sha1-new
     5#
     6# To enable this hook, rename this file to "update".
     7#
     8# Config
     9# ------
     10# hooks.allowunannotated
     11#   This boolean sets whether unannotated tags will be allowed into the
     12#   repository.  By default they won't be.
     13# hooks.allowdeletetag
     14#   This boolean sets whether deleting tags will be allowed in the
     15#   repository.  By default they won't be.
     16# hooks.allowdeletebranch
     17#   This boolean sets whether deleting branches will be allowed in the
     18#   repository.  By default they won't be.
     19# hooks.denycreatebranch
     20#   This boolean sets whether remotely creating branches will be denied
     21#   in the repository.  By default this is allowed.
     22#
     23
     24# --- Command line
     25refname="$1"
     26oldrev="$2"
     27newrev="$3"
     28
     29# --- Safety check
     30if [ -z "$GIT_DIR" ]; then
     31        echo "Don't run this script from the command line." >&2
     32        echo " (if you want, you could supply GIT_DIR then run" >&2
     33        echo "  $0 <ref> <oldrev> <newrev>)" >&2
     34        exit 1
     35fi
     36
     37if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then
     38        echo "Usage: $0 <ref> <oldrev> <newrev>" >&2
     39        exit 1
     40fi
     41
     42# --- Config
     43allowunannotated=$(git config --bool hooks.allowunannotated)
     44allowdeletebranch=$(git config --bool hooks.allowdeletebranch)
     45denycreatebranch=$(git config --bool hooks.denycreatebranch)
     46allowdeletetag=$(git config --bool hooks.allowdeletetag)
     47
     48# check for no description
     49projectdesc=$(sed -e '1q' "$GIT_DIR/description")
     50case "$projectdesc" in
     51"Unnamed repository"* | "")
     52        echo "*** Project description file hasn't been set" >&2
     53        exit 1
     54        ;;
     55esac
     56
     57# --- Check types
     58# if $newrev is 0000...0000, it's a commit to delete a ref.
     59zero="0000000000000000000000000000000000000000"
     60if [ "$newrev" = "$zero" ]; then
     61        newrev_type=delete
     62else
     63        newrev_type=$(git-cat-file -t $newrev)
     64fi
     65
     66case "$refname","$newrev_type" in
     67        refs/tags/*,commit)
     68                # un-annotated tag
     69                short_refname=${refname##refs/tags/}
     70                if [ "$allowunannotated" != "true" ]; then
     71                        echo "*** The un-annotated tag, $short_refname, is not allowed in this repository" >&2
     72                        echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&2
     73                        exit 1
     74                fi
     75                ;;
     76        refs/tags/*,delete)
     77                # delete tag
     78                if [ "$allowdeletetag" != "true" ]; then
     79                        echo "*** Deleting a tag is not allowed in this repository" >&2
     80                        exit 1
     81                fi
     82                ;;
     83        refs/tags/*,tag)
     84                # annotated tag
     85                ;;
     86        refs/heads/*,commit)
     87                # branch
     88                if [ "$oldrev" = "$zero" -a "$denycreatebranch" = "true" ]; then
     89                        echo "*** Creating a branch is not allowed in this repository" >&2
     90                        exit 1
     91                fi
     92                ;;
     93        refs/heads/*,delete)
     94                # delete branch
     95                if [ "$allowdeletebranch" != "true" ]; then
     96                        echo "*** Deleting a branch is not allowed in this repository" >&2
     97                        exit 1
     98                fi
     99                ;;
     100        refs/remotes/*,commit)
     101                # tracking branch
     102                ;;
     103        refs/remotes/*,delete)
     104                # delete tracking branch
     105                if [ "$allowdeletebranch" != "true" ]; then
     106                        echo "*** Deleting a tracking branch is not allowed in this repository" >&2
     107                        exit 1
     108                fi
     109                ;;
     110        *)
     111                # Anything else (is there anything else?)
     112                echo "*** Update hook: unknown type of update to ref $refname of type $newrev_type" >&2
     113                exit 1
     114                ;;
     115esac
     116
     117# --- Finished
     118exit 0
  • vendor/plugins/open_id_authentication/.git/info/exclude

    Binary files /usr/local/src/svn.openstreetmap.org/sites/rails_port/vendor/plugins/open_id_authentication/.git/index and ./vendor/plugins/open_id_authentication/.git/index differ
    diff -N -x .svn -r -u /usr/local/src/svn.openstreetmap.org/sites/rails_port/vendor/plugins/open_id_authentication/.git/info/exclude ./vendor/plugins/open_id_authentication/.git/info/exclude
    old new  
     1# git-ls-files --others --exclude-from=.git/info/exclude
     2# Lines that start with '#' are comments.
     3# For a project mostly in C, the following would be a good set of
     4# exclude patterns (uncomment them if you want to use them):
     5# *.[oa]
     6# *~
  • vendor/plugins/open_id_authentication/.git/logs/HEAD

    diff -N -x .svn -r -u /usr/local/src/svn.openstreetmap.org/sites/rails_port/vendor/plugins/open_id_authentication/.git/logs/HEAD ./vendor/plugins/open_id_authentication/.git/logs/HEAD
    old new  
     10000000000000000000000000000000000000000 079b91f70602814c98d4345e198f743bb56b76b5 Kai Krueger <kai@aiputerlx.(none)> 1261995580 +0100   clone: from git://github.com/rails/open_id_authentication
  • vendor/plugins/open_id_authentication/.git/logs/refs/heads/master

    diff -N -x .svn -r -u /usr/local/src/svn.openstreetmap.org/sites/rails_port/vendor/plugins/open_id_authentication/.git/logs/refs/heads/master ./vendor/plugins/open_id_authentication/.git/logs/refs/heads/master
    old new  
     10000000000000000000000000000000000000000 079b91f70602814c98d4345e198f743bb56b76b5 Kai Krueger <kai@aiputerlx.(none)> 1261995580 +0100   clone: from git://github.com/rails/open_id_authentication
  • vendor/plugins/open_id_authentication/.git/logs/refs/remotes/origin/HEAD

    diff -N -x .svn -r -u /usr/local/src/svn.openstreetmap.org/sites/rails_port/vendor/plugins/open_id_authentication/.git/logs/refs/remotes/origin/HEAD ./vendor/plugins/open_id_authentication/.git/logs/refs/remotes/origin/HEAD
    old new  
     10000000000000000000000000000000000000000 079b91f70602814c98d4345e198f743bb56b76b5 Kai Krueger <kai@aiputerlx.(none)> 1261995580 +0100   clone: from git://github.com/rails/open_id_authentication
  • vendor/plugins/open_id_authentication/.git/packed-refs

    Binary files /usr/local/src/svn.openstreetmap.org/sites/rails_port/vendor/plugins/open_id_authentication/.git/objects/pack/pack-12ea3fdfba26ed4f804b18b17c10df762bef57d5.idx and ./vendor/plugins/open_id_authentication/.git/objects/pack/pack-12ea3fdfba26ed4f804b18b17c10df762bef57d5.idx differ
    Binary files /usr/local/src/svn.openstreetmap.org/sites/rails_port/vendor/plugins/open_id_authentication/.git/objects/pack/pack-12ea3fdfba26ed4f804b18b17c10df762bef57d5.pack and ./vendor/plugins/open_id_authentication/.git/objects/pack/pack-12ea3fdfba26ed4f804b18b17c10df762bef57d5.pack differ
    diff -N -x .svn -r -u /usr/local/src/svn.openstreetmap.org/sites/rails_port/vendor/plugins/open_id_authentication/.git/packed-refs ./vendor/plugins/open_id_authentication/.git/packed-refs
    old new  
     1# pack-refs with: peeled
     2337fb8278c8ba61d65955b4bf558fb76796a67d2 refs/remotes/origin/rack
     3079b91f70602814c98d4345e198f743bb56b76b5 refs/remotes/origin/master
  • vendor/plugins/open_id_authentication/.git/refs/heads/master

    diff -N -x .svn -r -u /usr/local/src/svn.openstreetmap.org/sites/rails_port/vendor/plugins/open_id_authentication/.git/refs/heads/master ./vendor/plugins/open_id_authentication/.git/refs/heads/master
    old new  
     1079b91f70602814c98d4345e198f743bb56b76b5
  • vendor/plugins/open_id_authentication/.git/refs/remotes/origin/HEAD

    diff -N -x .svn -r -u /usr/local/src/svn.openstreetmap.org/sites/rails_port/vendor/plugins/open_id_authentication/.git/refs/remotes/origin/HEAD ./vendor/plugins/open_id_authentication/.git/refs/remotes/origin/HEAD
    old new  
     1ref: refs/remotes/origin/master
  • vendor/plugins/open_id_authentication/init.rb

    diff -N -x .svn -r -u /usr/local/src/svn.openstreetmap.org/sites/rails_port/vendor/plugins/open_id_authentication/init.rb ./vendor/plugins/open_id_authentication/init.rb
    old new  
     1if config.respond_to?(:gems)
     2  config.gem 'ruby-openid', :lib => 'openid', :version => '>=2.0.4'
     3else
     4  begin
     5    require 'openid'
     6  rescue LoadError
     7    begin
     8      gem 'ruby-openid', '>=2.0.4'
     9    rescue Gem::LoadError
     10      puts "Install the ruby-openid gem to enable OpenID support"
     11    end
     12  end
     13end
     14
     15config.to_prepare do
     16  OpenID::Util.logger = Rails.logger
     17  ActionController::Base.send :include, OpenIdAuthentication
     18end
  • vendor/plugins/open_id_authentication/lib/open_id_authentication/association.rb

    diff -N -x .svn -r -u /usr/local/src/svn.openstreetmap.org/sites/rails_port/vendor/plugins/open_id_authentication/lib/open_id_authentication/association.rb ./vendor/plugins/open_id_authentication/lib/open_id_authentication/association.rb
    old new  
     1module OpenIdAuthentication
     2  class Association < ActiveRecord::Base
     3    set_table_name :open_id_authentication_associations
     4
     5    def from_record
     6      OpenID::Association.new(handle, secret, issued, lifetime, assoc_type)
     7    end
     8  end
     9end
  • vendor/plugins/open_id_authentication/lib/open_id_authentication/db_store.rb

    diff -N -x .svn -r -u /usr/local/src/svn.openstreetmap.org/sites/rails_port/vendor/plugins/open_id_authentication/lib/open_id_authentication/db_store.rb ./vendor/plugins/open_id_authentication/lib/open_id_authentication/db_store.rb
    old new  
     1require 'openid/store/interface'
     2
     3module OpenIdAuthentication
     4  class DbStore < OpenID::Store::Interface
     5    def self.cleanup_nonces
     6      now = Time.now.to_i
     7      Nonce.delete_all(["timestamp > ? OR timestamp < ?", now + OpenID::Nonce.skew, now - OpenID::Nonce.skew])
     8    end
     9
     10    def self.cleanup_associations
     11      now = Time.now.to_i
     12      Association.delete_all(['issued + lifetime > ?',now])
     13    end
     14
     15    def store_association(server_url, assoc)
     16      remove_association(server_url, assoc.handle)
     17      Association.create(:server_url => server_url,
     18                         :handle     => assoc.handle,
     19                         :secret     => assoc.secret,
     20                         :issued     => assoc.issued,
     21                         :lifetime   => assoc.lifetime,
     22                         :assoc_type => assoc.assoc_type)
     23    end
     24
     25    def get_association(server_url, handle = nil)
     26      assocs = if handle.blank?
     27          Association.find_all_by_server_url(server_url)
     28        else
     29          Association.find_all_by_server_url_and_handle(server_url, handle)
     30        end
     31
     32      assocs.reverse.each do |assoc|
     33        a = assoc.from_record
     34        if a.expires_in == 0
     35          assoc.destroy
     36        else
     37          return a
     38        end
     39      end if assocs.any?
     40
     41      return nil
     42    end
     43
     44    def remove_association(server_url, handle)
     45      Association.delete_all(['server_url = ? AND handle = ?', server_url, handle]) > 0
     46    end
     47
     48    def use_nonce(server_url, timestamp, salt)
     49      return false if Nonce.find_by_server_url_and_timestamp_and_salt(server_url, timestamp, salt)
     50      return false if (timestamp - Time.now.to_i).abs > OpenID::Nonce.skew
     51      Nonce.create(:server_url => server_url, :timestamp => timestamp, :salt => salt)
     52      return true
     53    end
     54  end
     55end
  • vendor/plugins/open_id_authentication/lib/open_id_authentication/nonce.rb

    diff -N -x .svn -r -u /usr/local/src/svn.openstreetmap.org/sites/rails_port/vendor/plugins/open_id_authentication/lib/open_id_authentication/nonce.rb ./vendor/plugins/open_id_authentication/lib/open_id_authentication/nonce.rb
    old new  
     1module OpenIdAuthentication
     2  class Nonce < ActiveRecord::Base
     3    set_table_name :open_id_authentication_nonces
     4  end
     5end
  • vendor/plugins/open_id_authentication/lib/open_id_authentication/request.rb

    diff -N -x .svn -r -u /usr/local/src/svn.openstreetmap.org/sites/rails_port/vendor/plugins/open_id_authentication/lib/open_id_authentication/request.rb ./vendor/plugins/open_id_authentication/lib/open_id_authentication/request.rb
    old new  
     1module OpenIdAuthentication
     2  module Request
     3    def self.included(base)
     4      base.alias_method_chain :request_method, :openid
     5    end
     6
     7    def request_method_with_openid
     8      if !parameters[:_method].blank? && parameters[:open_id_complete] == '1'
     9        parameters[:_method].to_sym
     10      else
     11        request_method_without_openid
     12      end
     13    end
     14  end
     15end
     16
     17# In Rails 2.3, the request object has been renamed
     18# from AbstractRequest to Request
     19if defined? ActionController::Request
     20  ActionController::Request.send :include, OpenIdAuthentication::Request
     21else
     22  ActionController::AbstractRequest.send :include, OpenIdAuthentication::Request
     23end
  • vendor/plugins/open_id_authentication/lib/open_id_authentication/timeout_fixes.rb

    diff -N -x .svn -r -u /usr/local/src/svn.openstreetmap.org/sites/rails_port/vendor/plugins/open_id_authentication/lib/open_id_authentication/timeout_fixes.rb ./vendor/plugins/open_id_authentication/lib/open_id_authentication/timeout_fixes.rb
    old new  
     1# http://trac.openidenabled.com/trac/ticket/156
     2module OpenID
     3  @@timeout_threshold = 20
     4
     5  def self.timeout_threshold
     6    @@timeout_threshold
     7  end
     8
     9  def self.timeout_threshold=(value)
     10    @@timeout_threshold = value
     11  end
     12
     13  class StandardFetcher
     14    def make_http(uri)
     15      http = @proxy.new(uri.host, uri.port)
     16      http.read_timeout = http.open_timeout = OpenID.timeout_threshold
     17      http
     18    end
     19  end
     20end
     21 No newline at end of file
  • vendor/plugins/open_id_authentication/lib/open_id_authentication.rb

    diff -N -x .svn -r -u /usr/local/src/svn.openstreetmap.org/sites/rails_port/vendor/plugins/open_id_authentication/lib/open_id_authentication.rb ./vendor/plugins/open_id_authentication/lib/open_id_authentication.rb
    old new  
     1require 'uri'
     2require 'openid/extensions/sreg'
     3require 'openid/extensions/ax'
     4require 'openid/store/filesystem'
     5
     6require File.dirname(__FILE__) + '/open_id_authentication/association'
     7require File.dirname(__FILE__) + '/open_id_authentication/nonce'
     8require File.dirname(__FILE__) + '/open_id_authentication/db_store'
     9require File.dirname(__FILE__) + '/open_id_authentication/request'
     10require File.dirname(__FILE__) + '/open_id_authentication/timeout_fixes' if OpenID::VERSION == "2.0.4"
     11
     12module OpenIdAuthentication
     13  OPEN_ID_AUTHENTICATION_DIR = RAILS_ROOT + "/tmp/openids"
     14
     15  def self.store
     16    @@store
     17  end
     18
     19  def self.store=(*store_option)
     20    store, *parameters = *([ store_option ].flatten)
     21
     22    @@store = case store
     23    when :db
     24      OpenIdAuthentication::DbStore.new
     25    when :file
     26      OpenID::Store::Filesystem.new(OPEN_ID_AUTHENTICATION_DIR)
     27    else
     28      store
     29    end
     30  end
     31
     32  self.store = :db
     33
     34  class InvalidOpenId < StandardError
     35  end
     36
     37  class Result
     38    ERROR_MESSAGES = {
     39      :missing      => "Sorry, the OpenID server couldn't be found",
     40      :invalid      => "Sorry, but this does not appear to be a valid OpenID",
     41      :canceled     => "OpenID verification was canceled",
     42      :failed       => "OpenID verification failed",
     43      :setup_needed => "OpenID verification needs setup"
     44    }
     45
     46    def self.[](code)
     47      new(code)
     48    end
     49
     50    def initialize(code)
     51      @code = code
     52    end
     53
     54    def status
     55      @code
     56    end
     57
     58    ERROR_MESSAGES.keys.each { |state| define_method("#{state}?") { @code == state } }
     59
     60    def successful?
     61      @code == :successful
     62    end
     63
     64    def unsuccessful?
     65      ERROR_MESSAGES.keys.include?(@code)
     66    end
     67
     68    def message
     69      ERROR_MESSAGES[@code]
     70    end
     71  end
     72
     73  # normalizes an OpenID according to http://openid.net/specs/openid-authentication-2_0.html#normalization
     74  def self.normalize_identifier(identifier)
     75    # clean up whitespace
     76    identifier = identifier.to_s.strip
     77
     78    # if an XRI has a prefix, strip it.
     79    identifier.gsub!(/xri:\/\//i, '')
     80
     81    # dodge XRIs -- TODO: validate, don't just skip.
     82    unless ['=', '@', '+', '$', '!', '('].include?(identifier.at(0))
     83      # does it begin with http?  if not, add it.
     84      identifier = "http://#{identifier}" unless identifier =~ /^http/i
     85
     86      # strip any fragments
     87      identifier.gsub!(/\#(.*)$/, '')
     88
     89      begin
     90        uri = URI.parse(identifier)
     91        uri.scheme = uri.scheme.downcase  # URI should do this
     92        identifier = uri.normalize.to_s
     93      rescue URI::InvalidURIError
     94        raise InvalidOpenId.new("#{identifier} is not an OpenID identifier")
     95      end
     96    end
     97
     98    return identifier
     99  end
     100
     101  # deprecated for OpenID 2.0, where not all OpenIDs are URLs
     102  def self.normalize_url(url)
     103    ActiveSupport::Deprecation.warn "normalize_url has been deprecated, use normalize_identifier instead"
     104    self.normalize_identifier(url)
     105  end
     106
     107  protected
     108    def normalize_url(url)
     109      OpenIdAuthentication.normalize_url(url)
     110    end
     111
     112    def normalize_identifier(url)
     113      OpenIdAuthentication.normalize_identifier(url)
     114    end
     115
     116    # The parameter name of "openid_identifier" is used rather than the Rails convention "open_id_identifier"
     117    # because that's what the specification dictates in order to get browser auto-complete working across sites
     118    def using_open_id?(identity_url = nil) #:doc:
     119      identity_url ||= params[:openid_identifier] || params[:openid_url]
     120      !identity_url.blank? || params[:open_id_complete]
     121    end
     122
     123    def authenticate_with_open_id(identity_url = nil, options = {}, &block) #:doc:
     124      identity_url ||= params[:openid_identifier] || params[:openid_url]
     125
     126      if params[:open_id_complete].nil?
     127        begin_open_id_authentication(identity_url, options, &block)
     128      else
     129        complete_open_id_authentication(&block)
     130      end
     131    end
     132
     133  private
     134    def begin_open_id_authentication(identity_url, options = {})
     135      identity_url = normalize_identifier(identity_url)
     136      return_to    = options.delete(:return_to)
     137      method       = options.delete(:method)
     138     
     139      options[:required] ||= []  # reduces validation later
     140      options[:optional] ||= []
     141
     142      open_id_request = open_id_consumer.begin(identity_url)
     143      add_simple_registration_fields(open_id_request, options)
     144      add_ax_fields(open_id_request, options)
     145      redirect_to(open_id_redirect_url(open_id_request, return_to, method))
     146    rescue OpenIdAuthentication::InvalidOpenId => e
     147      yield Result[:invalid], identity_url, nil
     148    rescue OpenID::OpenIDError, Timeout::Error => e
     149      logger.error("[OPENID] #{e}")
     150      yield Result[:missing], identity_url, nil
     151    end
     152
     153    def complete_open_id_authentication
     154      params_with_path = params.reject { |key, value| request.path_parameters[key] }
     155      params_with_path.delete(:format)
     156      open_id_response = timeout_protection_from_identity_server { open_id_consumer.complete(params_with_path, requested_url) }
     157      identity_url     = normalize_identifier(open_id_response.display_identifier) if open_id_response.display_identifier
     158
     159      case open_id_response.status
     160      when OpenID::Consumer::SUCCESS
     161        profile_data = {}
     162
     163        # merge the SReg data and the AX data into a single hash of profile data
     164        [ OpenID::SReg::Response, OpenID::AX::FetchResponse ].each do |data_response|
     165          if data_response.from_success_response( open_id_response )
     166            profile_data.merge! data_response.from_success_response( open_id_response ).data
     167          end
     168        end
     169       
     170        yield Result[:successful], identity_url, profile_data
     171      when OpenID::Consumer::CANCEL
     172        yield Result[:canceled], identity_url, nil
     173      when OpenID::Consumer::FAILURE
     174        yield Result[:failed], identity_url, nil
     175      when OpenID::Consumer::SETUP_NEEDED
     176        yield Result[:setup_needed], open_id_response.setup_url, nil
     177      end
     178    end
     179
     180    def open_id_consumer
     181      OpenID::Consumer.new(session, OpenIdAuthentication.store)
     182    end
     183
     184    def add_simple_registration_fields(open_id_request, fields)
     185      sreg_request = OpenID::SReg::Request.new
     186     
     187      # filter out AX identifiers (URIs)
     188      required_fields = fields[:required].collect { |f| f.to_s unless f =~ /^https?:\/\// }.compact
     189      optional_fields = fields[:optional].collect { |f| f.to_s unless f =~ /^https?:\/\// }.compact
     190     
     191      sreg_request.request_fields(required_fields, true) unless required_fields.blank?
     192      sreg_request.request_fields(optional_fields, false) unless optional_fields.blank?
     193      sreg_request.policy_url = fields[:policy_url] if fields[:policy_url]
     194      open_id_request.add_extension(sreg_request)
     195    end
     196   
     197    def add_ax_fields( open_id_request, fields )
     198      ax_request = OpenID::AX::FetchRequest.new
     199     
     200      # look through the :required and :optional fields for URIs (AX identifiers)
     201      fields[:required].each do |f|
     202        next unless f =~ /^https?:\/\//
     203        ax_request.add( OpenID::AX::AttrInfo.new( f, nil, true ) )
     204      end
     205
     206      fields[:optional].each do |f|
     207        next unless f =~ /^https?:\/\//
     208        ax_request.add( OpenID::AX::AttrInfo.new( f, nil, false ) )
     209      end
     210     
     211      open_id_request.add_extension( ax_request )
     212    end
     213       
     214    def open_id_redirect_url(open_id_request, return_to = nil, method = nil)
     215      open_id_request.return_to_args['_method'] = (method || request.method).to_s
     216      open_id_request.return_to_args['open_id_complete'] = '1'
     217      open_id_request.redirect_url(root_url, return_to || requested_url)
     218    end
     219
     220    def requested_url
     221      relative_url_root = self.class.respond_to?(:relative_url_root) ?
     222        self.class.relative_url_root.to_s :
     223        request.relative_url_root
     224      "#{request.protocol}#{request.host_with_port}#{ActionController::Base.relative_url_root}#{request.path}"
     225    end
     226
     227    def timeout_protection_from_identity_server
     228      yield
     229    rescue Timeout::Error
     230      Class.new do
     231        def status
     232          OpenID::FAILURE
     233        end
     234
     235        def msg
     236          "Identity server timed out"
     237        end
     238      end.new
     239    end
     240end
  • vendor/plugins/open_id_authentication/Rakefile

    diff -N -x .svn -r -u /usr/local/src/svn.openstreetmap.org/sites/rails_port/vendor/plugins/open_id_authentication/Rakefile ./vendor/plugins/open_id_authentication/Rakefile
    old new  
     1require 'rake'
     2require 'rake/testtask'
     3require 'rake/rdoctask'
     4
     5desc 'Default: run unit tests.'
     6task :default => :test
     7
     8desc 'Test the open_id_authentication plugin.'
     9Rake::TestTask.new(:test) do |t|
     10  t.libs << 'lib'
     11  t.pattern = 'test/**/*_test.rb'
     12  t.verbose = true
     13end
     14
     15desc 'Generate documentation for the open_id_authentication plugin.'
     16Rake::RDocTask.new(:rdoc) do |rdoc|
     17  rdoc.rdoc_dir = 'rdoc'
     18  rdoc.title    = 'OpenIdAuthentication'
     19  rdoc.options << '--line-numbers' << '--inline-source'
     20  rdoc.rdoc_files.include('README')
     21  rdoc.rdoc_files.include('lib/**/*.rb')
     22end
  • vendor/plugins/open_id_authentication/README

    diff -N -x .svn -r -u /usr/local/src/svn.openstreetmap.org/sites/rails_port/vendor/plugins/open_id_authentication/README ./vendor/plugins/open_id_authentication/README
    old new  
     1OpenIdAuthentication
     2====================
     3
     4Provides a thin wrapper around the excellent ruby-openid gem from JanRan. Be sure to install that first:
     5
     6  gem install ruby-openid
     7
     8To understand what OpenID is about and how it works, it helps to read the documentation for lib/openid/consumer.rb
     9from that gem.
     10
     11The specification used is http://openid.net/specs/openid-authentication-2_0.html.
     12
     13
     14Prerequisites
     15=============
     16
     17OpenID authentication uses the session, so be sure that you haven't turned that off. It also relies on a number of
     18database tables to store the authentication keys. So you'll have to run the migration to create these before you get started:
     19
     20  rake open_id_authentication:db:create
     21
     22Or, use the included generators to install or upgrade:
     23
     24  ./script/generate open_id_authentication_tables MigrationName
     25  ./script/generate upgrade_open_id_authentication_tables MigrationName
     26
     27Alternatively, you can use the file-based store, which just relies on on tmp/openids being present in RAILS_ROOT. But be aware that this store only works if you have a single application server. And it's not safe to use across NFS. It's recommended that you use the database store if at all possible. To use the file-based store, you'll also have to add this line to your config/environment.rb:
     28
     29  OpenIdAuthentication.store = :file
     30
     31This particular plugin also relies on the fact that the authentication action allows for both POST and GET operations.
     32If you're using RESTful authentication, you'll need to explicitly allow for this in your routes.rb.
     33
     34The plugin also expects to find a root_url method that points to the home page of your site. You can accomplish this by using a root route in config/routes.rb:
     35
     36  map.root :controller => 'articles'
     37
     38This plugin relies on Rails Edge revision 6317 or newer.
     39
     40
     41Example
     42=======
     43
     44This example is just to meant to demonstrate how you could use OpenID authentication. You might well want to add
     45salted hash logins instead of plain text passwords and other requirements on top of this. Treat it as a starting point,
     46not a destination.
     47
     48Note that the User model referenced in the simple example below has an 'identity_url' attribute. You will want to add the same or similar field to whatever
     49model you are using for authentication.
     50
     51Also of note is the following code block used in the example below:
     52
     53  authenticate_with_open_id do |result, identity_url|
     54    ...
     55  end
     56 
     57In the above code block, 'identity_url' will need to match user.identity_url exactly. 'identity_url' will be a string in the form of 'http://example.com' -
     58If you are storing just 'example.com' with your user, the lookup will fail.
     59
     60There is a handy method in this plugin called 'normalize_url' that will help with validating OpenID URLs.
     61
     62  OpenIdAuthentication.normalize_url(user.identity_url)
     63
     64The above will return a standardized version of the OpenID URL - the above called with 'example.com' will return 'http://example.com/'
     65It will also raise an InvalidOpenId exception if the URL is determined to not be valid.
     66Use the above code in your User model and validate OpenID URLs before saving them.
     67
     68config/routes.rb
     69
     70  map.root :controller => 'articles'
     71  map.resource :session
     72
     73
     74app/views/sessions/new.erb
     75
     76  <% form_tag(session_url) do %>
     77    <p>
     78      <label for="name">Username:</label>
     79      <%= text_field_tag "name" %>
     80    </p>
     81
     82    <p>
     83      <label for="password">Password:</label>
     84      <%= password_field_tag %>
     85    </p>
     86
     87    <p>
     88      ...or use:
     89    </p>
     90
     91    <p>
     92      <label for="openid_identifier">OpenID:</label>
     93      <%= text_field_tag "openid_identifier" %>
     94    </p>
     95
     96    <p>
     97      <%= submit_tag 'Sign in', :disable_with => "Signing in&hellip;" %>
     98    </p>
     99  <% end %>
     100
     101app/controllers/sessions_controller.rb
     102  class SessionsController < ApplicationController
     103    def create
     104      if using_open_id?
     105        open_id_authentication
     106      else
     107        password_authentication(params[:name], params[:password])
     108      end
     109    end
     110
     111
     112    protected
     113      def password_authentication(name, password)
     114        if @current_user = @account.users.authenticate(params[:name], params[:password])
     115          successful_login
     116        else
     117          failed_login "Sorry, that username/password doesn't work"
     118        end
     119      end
     120
     121      def open_id_authentication
     122        authenticate_with_open_id do |result, identity_url|
     123          if result.successful?
     124            if @current_user = @account.users.find_by_identity_url(identity_url)
     125              successful_login
     126            else
     127              failed_login "Sorry, no user by that identity URL exists (#{identity_url})"
     128            end
     129          else
     130            failed_login result.message
     131          end
     132        end
     133      end
     134   
     135   
     136    private
     137      def successful_login
     138        session[:user_id] = @current_user.id
     139        redirect_to(root_url)
     140      end
     141
     142      def failed_login(message)
     143        flash[:error] = message
     144        redirect_to(new_session_url)
     145      end
     146  end
     147
     148
     149
     150If you're fine with the result messages above and don't need individual logic on a per-failure basis,
     151you can collapse the case into a mere boolean:
     152
     153    def open_id_authentication
     154      authenticate_with_open_id do |result, identity_url|
     155        if result.successful? && @current_user = @account.users.find_by_identity_url(identity_url)
     156          successful_login
     157        else
     158          failed_login(result.message || "Sorry, no user by that identity URL exists (#{identity_url})")
     159        end
     160      end
     161    end
     162
     163
     164Simple Registration OpenID Extension
     165====================================
     166
     167Some OpenID Providers support this lightweight profile exchange protocol.  See more: http://www.openidenabled.com/openid/simple-registration-extension
     168
     169You can support it in your app by changing #open_id_authentication
     170
     171      def open_id_authentication(identity_url)
     172        # Pass optional :required and :optional keys to specify what sreg fields you want.
     173        # Be sure to yield registration, a third argument in the #authenticate_with_open_id block.
     174        authenticate_with_open_id(identity_url,
     175            :required => [ :nickname, :email ],
     176            :optional => :fullname) do |result, identity_url, registration|
     177          case result.status
     178          when :missing
     179            failed_login "Sorry, the OpenID server couldn't be found"
     180          when :invalid
     181            failed_login "Sorry, but this does not appear to be a valid OpenID"
     182          when :canceled
     183            failed_login "OpenID verification was canceled"
     184          when :failed
     185            failed_login "Sorry, the OpenID verification failed"
     186          when :successful
     187            if @current_user = @account.users.find_by_identity_url(identity_url)
     188              assign_registration_attributes!(registration)
     189
     190              if current_user.save
     191                successful_login
     192              else
     193                failed_login "Your OpenID profile registration failed: " +
     194                  @current_user.errors.full_messages.to_sentence
     195              end
     196            else
     197              failed_login "Sorry, no user by that identity URL exists"
     198            end
     199          end
     200        end
     201      end
     202     
     203      # registration is a hash containing the valid sreg keys given above
     204      # use this to map them to fields of your user model
     205      def assign_registration_attributes!(registration)
     206        model_to_registration_mapping.each do |model_attribute, registration_attribute|
     207          unless registration[registration_attribute].blank?
     208            @current_user.send("#{model_attribute}=", registration[registration_attribute])
     209          end
     210        end
     211      end
     212
     213      def model_to_registration_mapping
     214        { :login => 'nickname', :email => 'email', :display_name => 'fullname' }
     215      end
     216
     217Attribute Exchange OpenID Extension
     218===================================
     219
     220Some OpenID providers also support the OpenID AX (attribute exchange) protocol for exchanging identity information between endpoints.  See more: http://openid.net/specs/openid-attribute-exchange-1_0.html
     221
     222Accessing AX data is very similar to the Simple Registration process, described above -- just add the URI identifier for the AX field to your :optional or :required parameters.  For example:
     223
     224        authenticate_with_open_id(identity_url,
     225            :required => [ :email, 'http://schema.openid.net/birthDate' ]) do |result, identity_url, registration|
     226     
     227This would provide the sreg data for :email, and the AX data for 'http://schema.openid.net/birthDate'
     228
     229
     230
     231Copyright (c) 2007 David Heinemeier Hansson, released under the MIT license
     232 No newline at end of file
  • vendor/plugins/open_id_authentication/tasks/open_id_authentication_tasks.rake

    diff -N -x .svn -r -u /usr/local/src/svn.openstreetmap.org/sites/rails_port/vendor/plugins/open_id_authentication/tasks/open_id_authentication_tasks.rake ./vendor/plugins/open_id_authentication/tasks/open_id_authentication_tasks.rake
    old new  
     1namespace :open_id_authentication do
     2  namespace :db do
     3    desc "Creates authentication tables for use with OpenIdAuthentication"
     4    task :create => :environment do
     5      generate_migration(["open_id_authentication_tables", "add_open_id_authentication_tables"])
     6    end
     7
     8    desc "Upgrade authentication tables from ruby-openid 1.x.x to 2.x.x"
     9    task :upgrade => :environment do
     10      generate_migration(["upgrade_open_id_authentication_tables", "upgrade_open_id_authentication_tables"])
     11    end
     12
     13    def generate_migration(args)
     14      require 'rails_generator'
     15      require 'rails_generator/scripts/generate'
     16
     17      if ActiveRecord::Base.connection.supports_migrations?
     18        Rails::Generator::Scripts::Generate.new.run(args)
     19      else
     20        raise "Task unavailable to this database (no migration support)"
     21      end
     22    end
     23
     24    desc "Clear the authentication tables"
     25    task :clear => :environment do
     26      OpenIdAuthentication::DbStore.cleanup_nonces
     27      OpenIdAuthentication::DbStore.cleanup_associations
     28    end
     29  end
     30end
  • vendor/plugins/open_id_authentication/test/normalize_test.rb

    diff -N -x .svn -r -u /usr/local/src/svn.openstreetmap.org/sites/rails_port/vendor/plugins/open_id_authentication/test/normalize_test.rb ./vendor/plugins/open_id_authentication/test/normalize_test.rb
    old new  
     1require File.dirname(__FILE__) + '/test_helper'
     2
     3class NormalizeTest < Test::Unit::TestCase
     4  include OpenIdAuthentication
     5
     6  NORMALIZATIONS = {
     7    "openid.aol.com/nextangler"             => "http://openid.aol.com/nextangler",
     8    "http://openid.aol.com/nextangler"      => "http://openid.aol.com/nextangler",
     9    "https://openid.aol.com/nextangler"     => "https://openid.aol.com/nextangler",
     10    "HTTP://OPENID.AOL.COM/NEXTANGLER"      => "http://openid.aol.com/NEXTANGLER",
     11    "HTTPS://OPENID.AOL.COM/NEXTANGLER"     => "https://openid.aol.com/NEXTANGLER",
     12    "loudthinking.com"                      => "http://loudthinking.com/",
     13    "http://loudthinking.com"               => "http://loudthinking.com/",
     14    "http://loudthinking.com:80"            => "http://loudthinking.com/",
     15    "https://loudthinking.com:443"          => "https://loudthinking.com/",
     16    "http://loudthinking.com:8080"          => "http://loudthinking.com:8080/",
     17    "techno-weenie.net"                     => "http://techno-weenie.net/",
     18    "http://techno-weenie.net"              => "http://techno-weenie.net/",
     19    "http://techno-weenie.net  "            => "http://techno-weenie.net/",
     20    "=name"                                 => "=name"
     21  }
     22
     23  def test_normalizations
     24    NORMALIZATIONS.each do |from, to|
     25      assert_equal to, normalize_identifier(from)
     26    end
     27  end
     28
     29  def test_broken_open_id
     30    assert_raises(InvalidOpenId) { normalize_identifier(nil) }
     31  end
     32end
  • vendor/plugins/open_id_authentication/test/open_id_authentication_test.rb

    diff -N -x .svn -r -u /usr/local/src/svn.openstreetmap.org/sites/rails_port/vendor/plugins/open_id_authentication/test/open_id_authentication_test.rb ./vendor/plugins/open_id_authentication/test/open_id_authentication_test.rb
    old new  
     1require File.dirname(__FILE__) + '/test_helper'
     2
     3class OpenIdAuthenticationTest < Test::Unit::TestCase
     4  def setup
     5    @controller = Class.new do
     6      include OpenIdAuthentication
     7      def params() {} end
     8    end.new
     9  end
     10
     11  def test_authentication_should_fail_when_the_identity_server_is_missing
     12    open_id_consumer = mock()
     13    open_id_consumer.expects(:begin).raises(OpenID::OpenIDError)
     14    @controller.expects(:open_id_consumer).returns(open_id_consumer)
     15    @controller.expects(:logger).returns(mock(:error => true))
     16
     17    @controller.send(:authenticate_with_open_id, "http://someone.example.com") do |result, identity_url|
     18      assert result.missing?
     19      assert_equal "Sorry, the OpenID server couldn't be found", result.message
     20    end
     21  end
     22
     23  def test_authentication_should_be_invalid_when_the_identity_url_is_invalid
     24    @controller.send(:authenticate_with_open_id, "!") do |result, identity_url|
     25      assert result.invalid?, "Result expected to be invalid but was not"
     26      assert_equal "Sorry, but this does not appear to be a valid OpenID", result.message
     27    end
     28  end
     29
     30  def test_authentication_should_fail_when_the_identity_server_times_out
     31    open_id_consumer = mock()
     32    open_id_consumer.expects(:begin).raises(Timeout::Error, "Identity Server took too long.")
     33    @controller.expects(:open_id_consumer).returns(open_id_consumer)
     34    @controller.expects(:logger).returns(mock(:error => true))
     35
     36    @controller.send(:authenticate_with_open_id, "http://someone.example.com") do |result, identity_url|
     37      assert result.missing?
     38      assert_equal "Sorry, the OpenID server couldn't be found", result.message
     39    end
     40  end
     41
     42  def test_authentication_should_begin_when_the_identity_server_is_present
     43    @controller.expects(:begin_open_id_authentication)
     44    @controller.send(:authenticate_with_open_id, "http://someone.example.com")
     45  end
     46end
  • vendor/plugins/open_id_authentication/test/status_test.rb

    diff -N -x .svn -r -u /usr/local/src/svn.openstreetmap.org/sites/rails_port/vendor/plugins/open_id_authentication/test/status_test.rb ./vendor/plugins/open_id_authentication/test/status_test.rb
    old new  
     1require File.dirname(__FILE__) + '/test_helper'
     2
     3class StatusTest < Test::Unit::TestCase
     4  include OpenIdAuthentication
     5
     6  def test_state_conditional
     7    assert Result[:missing].missing?
     8    assert Result[:missing].unsuccessful?
     9    assert !Result[:missing].successful?
     10
     11    assert Result[:successful].successful?
     12    assert !Result[:successful].unsuccessful?
     13  end
     14end
     15 No newline at end of file
  • vendor/plugins/open_id_authentication/test/test_helper.rb

    diff -N -x .svn -r -u /usr/local/src/svn.openstreetmap.org/sites/rails_port/vendor/plugins/open_id_authentication/test/test_helper.rb ./vendor/plugins/open_id_authentication/test/test_helper.rb
    old new  
     1require 'test/unit'
     2require 'rubygems'
     3
     4gem 'activesupport'
     5require 'active_support'
     6
     7gem 'actionpack'
     8require 'action_controller'
     9
     10gem 'mocha'
     11require 'mocha'
     12
     13gem 'ruby-openid'
     14require 'openid'
     15
     16RAILS_ROOT = File.dirname(__FILE__) unless defined? RAILS_ROOT
     17require File.dirname(__FILE__) + "/../lib/open_id_authentication"