Patch #5966

change to allow openID to use Google Apps

Added by Chris Mague almost 7 years ago. Updated over 5 years ago.

Status:NewStart date:2010-07-26
Priority:NormalDue date:
Assignee:-% Done:

100%

Category:OpenID
Target version:-

Description

diff -r ./config/environment.rb /home/chris/tmp/redmine/them/redmine-1.0.0/config/environment.rb
61,62d60
< 
< require 'gapps_openid'
diff -r ./app/controllers/account_controller.rb /home/chris/tmp/redmine/them/redmine-1.0.0/app/controllers/account_controller.rb
161,164c161
<     r = authenticate_with_open_id(openid_url, :required => ["http://schema.openid.net/contact/email"], :return_to => signin_url) do |result, identity_url, registration|
<       logger.warn "Failed login because: '#{result.inspect} at #{Time.now.utc}" 
<       logger.warn "Failed login because: '#{result} at #{Time.now.utc}" 
<       logger.warn "Failed login because: '#{result.message} at #{Time.now.utc}" 
---
>     authenticate_with_open_id(openid_url, :required => [:nickname, :fullname, :email], :return_to => signin_url) do |result, identity_url, registration|
166,170c163
<         logger.warn "identity_url: '#{identity_url} at #{Time.now.utc}" 
<         logger.warn "registration: '#{registration.inspect} at #{Time.now.utc}" 
<         #user = User.find_or_initialize_by_identity_url(identity_url)
<         logger.warn "registration: '#{registration["http://schema.openid.net/contact/email"][0]}'" 
<         user = User.find_by_mail(registration["http://schema.openid.net/contact/email"][0])
---
>         user = User.find_or_initialize_by_identity_url(identity_url)

History

#1 Updated by Holger Just almost 7 years ago

Just wrapped the description in pre tags.

#2 Updated by Felix Schäfer almost 7 years ago

The OpenID endpoint for Google accounts is https://www.google.com/accounts/o8/id , and from what I hear it works well. Please state what problem this patch is supposed to solve.

#3 Updated by Toshi MARUYAMA about 6 years ago

  • Category set to Accounts / authentication

#4 Updated by Andriy Lesyuk almost 6 years ago

Google OpenID does not work for me under versions 1.0.1 and 1.1.2... I have investigated a little this issue and found that changing the open_id_authenticate function to the following code helps (includes more attributes than Chris' patch):

  def open_id_authenticate(openid_url)
    authenticate_with_open_id(openid_url, :required => [:nickname, :fullname, :email,
        'http://axschema.org/namePerson/first', 'http://axschema.org/namePerson/last', 'http://axschema.org/contact/email'
      ], :return_to => signin_url) do |result, identity_url, registration|
      if result.successful?
        user = User.find_or_initialize_by_identity_url(identity_url)
        if user.new_record?
          # Self-registration off
          redirect_to(home_url) && return unless Setting.self_registration?

          # Create on the fly
          user.login = registration['nickname'] unless registration['nickname'].nil?
          user.mail = registration['email'] unless registration['email'].nil?
          user.firstname, user.lastname = registration['fullname'].split(' ') unless registration['fullname'].nil?

          user.login = registration['http://axschema.org/contact/email'].first unless registration['http://axschema.org/contact/email'].nil?
          user.mail = registration['http://axschema.org/contact/email'].first unless registration['http://axschema.org/contact/email'].nil?
          user.firstname = registration['http://axschema.org/namePerson/first'].first unless registration['http://axschema.org/namePerson/first'].nil?
          user.lastname = registration['http://axschema.org/namePerson/last'].first unless registration['http://axschema.org/namePerson/last'].nil?

          user.random_password
          user.register

          case Setting.self_registration
          when '1'
            register_by_email_activation(user) do
              onthefly_creation_failed(user)
            end
          when '3'
            register_automatically(user) do
              onthefly_creation_failed(user)
            end
          else
            register_manually_by_administrator(user) do
              onthefly_creation_failed(user)
            end
          end          
        else
          # Existing record
          if user.active?
            successful_authentication(user)
          else
            account_pending
          end
        end
      end
    end
  end

See also:

Unless I missed something it looks like Google OpenID does not work at all in Redmine!

#5 Updated by Etienne Massip over 5 years ago

  • Category changed from Accounts / authentication to OpenID

#6 Updated by Antoine Beaupré over 5 years ago

  • % Done changed from 0 to 100

there is a fix for this: http://projects.andriylesyuk.com/projects/openid-fix

why isn't this factored in?!

Also available in: Atom PDF