Skip to content

Commit

Permalink
Perform normal discovery before Google Apps discovery. Closes omniaut…
Browse files Browse the repository at this point in the history
…h#50 (thanks for starting point, samsm)
  • Loading branch information
Michael Bleigh committed Oct 12, 2010
1 parent 93406af commit 610b663
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
32 changes: 32 additions & 0 deletions oa-openid/lib/omniauth/openid/gapps.rb
@@ -0,0 +1,32 @@
require 'openid/consumer'
require 'gapps_openid'

module OpenID
# Because gapps_openid changes the discovery order
# (looking first for Google Apps, then anything else),
# we need to monkeypatch it to make it play nicely
# with others.
def self.discover(uri)
discovered = self.default_discover(uri)

if discovered.last.empty?
info = discover_google_apps(uri)
return info if info
end

return discovered
rescue OpenID::DiscoveryFailure => e
info = discover_google_apps(uri)

if info.nil?
raise e
else
return info
end
end

def self.discover_google_apps(uri)
discovery = GoogleDiscovery.new
discovery.perform_discovery(uri)
end
end
2 changes: 1 addition & 1 deletion oa-openid/lib/omniauth/strategies/open_id.rb
@@ -1,5 +1,5 @@
require 'rack/openid'
require 'gapps_openid'
require 'omniauth/openid/gapps'
require 'omniauth/openid'

module OmniAuth
Expand Down

0 comments on commit 610b663

Please sign in to comment.