forked from omniauth/omniauth
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Perform normal discovery before Google Apps discovery. Closes omniaut…
…h#50 (thanks for starting point, samsm)
- Loading branch information
Michael Bleigh
committed
Oct 12, 2010
1 parent
93406af
commit 610b663
Showing
2 changed files
with
33 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters