Module: OmniAuth + + + +
+-
+
- Defined in: +
- lib/omniauth/openid/version.rb,
+ lib/omniauth/strategies/open_id.rb +
+
Defined Under Namespace
++ + + Modules: OpenID, Strategies + + + + +
+ + + + + + + + + ++ + + Modules: OpenID, Strategies + + + + +
+ + + + + + + + + +"2.0.2"+ + + + + Classes: OpenID + + +
+ + + + + + + + + +OmniAuth strategy for connecting via OpenID. This allows for connection
+to a wide variety of sites, some of which are listed on the OpenID website.
{ + email: "http://axschema.org/contact/email", + name: "http://axschema.org/namePerson", + nickname: "http://axschema.org/namePerson/friendly", + first_name: "http://axschema.org/namePerson/first", + last_name: "http://axschema.org/namePerson/last", + city: "http://axschema.org/contact/city/home", + state: "http://axschema.org/contact/state/home", + website: "http://axschema.org/contact/web/default", + image: "http://axschema.org/media/image/aspect11", +}
+ + + +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135+ |
+
+ # File 'lib/omniauth/strategies/open_id.rb', line 121 + +def ax_user_info + ax = ::OpenID::AX::FetchResponse.from_success_response(openid_response) + return {} unless ax + { + "email" => ax.get_single(AX[:email]), + "first_name" => ax.get_single(AX[:first_name]), + "last_name" => ax.get_single(AX[:last_name]), + "name" => (ax.get_single(AX[:name]) || [ax.get_single(AX[:first_name]), ax.get_single(AX[:last_name])].join(" ")).strip, + "location" => ("#{ax.get_single(AX[:city])}, #{ax.get_single(AX[:state])}" if Array(ax.get_single(AX[:city])).any? && Array(ax.get_single(AX[:state])).any?), + "nickname" => ax.get_single(AX[:nickname]), + "urls" => ({"Website" => Array(ax.get_single(AX[:website])).first} if Array(ax.get_single(AX[:website])).any?), + }.each_with_object({}) { |(k, v), h| + h[k] = Array(v).first + }.reject { |k, v| v.nil? || v == "" } +end+ |
+
+ + + +96 +97 +98 +99+ |
+
+ # File 'lib/omniauth/strategies/open_id.rb', line 96 + +def callback_phase + return fail!(:invalid_credentials) unless openid_response && openid_response.status == :success + super +end+ |
+
+ + + +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56+ |
+
+ # File 'lib/omniauth/strategies/open_id.rb', line 34 + +def dummy_app + lambda { |env| + req = Rack::Request.new(env) + root_uri = "#{req.scheme}://#{req.host_with_port}/" + + [ + 401, + { + "WWW-Authenticate" => Rack::OpenID.build_header( + identifier: identifier, + return_to: callback_url, + trust_root: .trust_root || %r{^(https?://[^/]+)}.match(callback_url) { |m| m[1] }, + required: .required, + optional: .optional, + method: "post", + immediate: .immediate, + trust_root: .trust_root.call(root_uri), + ), + }, + [], + ] + } +end+ |
+
+ + + +79 +80 +81 +82 +83 +84+ |
+
+ # File 'lib/omniauth/strategies/open_id.rb', line 79 + +def get_identifier + f = OmniAuth::Form.new(title: "OpenID Authentication") + f.label_field("OpenID Identifier", .identifier_param) + f.input_field("url", .identifier_param) + f.to_response +end+ |
+
+ + + +58 +59 +60 +61 +62+ |
+
+ # File 'lib/omniauth/strategies/open_id.rb', line 58 + +def identifier + i = .identifier || request.params[.identifier_param.to_s] + i = nil if i == "" + i +end+ |
+
+ + + +101 +102 +103 +104 +105 +106 +107 +108+ |
+
+ # File 'lib/omniauth/strategies/open_id.rb', line 101 + +def openid_response + unless @openid_response + openid = Rack::OpenID.new(lambda { |env| [200, {}, []] }, [:store]) + openid.call(env) + @openid_response = env.delete("rack.openid.response") + end + @openid_response +end+ |
+
+ + + +64 +65 +66+ |
+
+ # File 'lib/omniauth/strategies/open_id.rb', line 64 + +def request_phase + identifier ? start : get_identifier +end+ |
+
+ + + +110 +111 +112 +113 +114 +115 +116 +117 +118 +119+ |
+
+ # File 'lib/omniauth/strategies/open_id.rb', line 110 + +def sreg_user_info + sreg = ::OpenID::SReg::Response.from_success_response(openid_response) + return {} unless sreg + { + "email" => sreg["email"], + "name" => sreg["fullname"], + "location" => sreg["postcode"], + "nickname" => sreg["nickname"], + }.reject { |k, v| v.nil? || v == "" } +end+ |
+
+ + + +68 +69 +70 +71 +72 +73 +74 +75 +76 +77+ |
+
+ # File 'lib/omniauth/strategies/open_id.rb', line 68 + +def start + openid = Rack::OpenID.new(dummy_app, [:store]) + response = openid.call(env) + case env["rack.openid.response"] + when Rack::OpenID::MissingResponse, Rack::OpenID::TimeoutResponse + fail!(:connection_failed) + else + response + end +end+ |
+
+
+
+
|
+
| Tokens to Remember | +
+ |
+
|---|---|
| Works with JRuby | +
+ |
+
| Works with MRI Ruby 3 | +
+ |
+
| Works with MRI Ruby 2 | +
+ |
+
| Source | +
+ |
+
| Documentation | +
+ |
+
| Compliance | +
+ |
+
| Style | +
+ |
+
| Support | +
+ |
+
| Enterprise Support | +
+ đĄSubscribe for support guarantees covering all FLOSS dependencies! đĄTidelift is part of Sonar! đĄTidelift pays maintainers to maintain the software you depend on! đ @Pointy Haired Boss: An enterprise support subscription is ânever gonna let you downâ, and supports open source maintainers! |
+
| Comrade BDFL đī¸ | +
+ |
+
+... đ |
+
+ |
+
Install the gem and add to the applicationâs Gemfile by executing:
+ +$ bundle add omniauth-openid
+
+
+If bundler is not being used to manage dependencies, install the gem by executing:
+ +$ gem install omniauth-openid
+
+
+omniauth-openid is cryptographically signed, and has verifiable SHA-256 and SHA-512 checksums by
+stone_checksums. Be sure the gem you install hasnât been tampered with
+by following the instructions below.
Add my public key (if you havenât already, expires 2045-04-29) as a trusted certificate:
+ +gem cert --add <(curl -Ls https://raw.github.com/omniauth/omniauth-openid/main/certs/pboling.pem)
+
+
+You only need to do that once. Then proceed to install with:
+ +gem install omniauth-openid -P MediumSecurity
+
+
+The MediumSecurity trust profile will verify signed gems, but allow the installation of unsigned dependencies.
This is necessary because not all of omniauth-openidâs dependencies are signed, so we cannot use HighSecurity.
If you want to up your security game full-time:
+ +bundle config set --global trust-policy MediumSecurity
+
+
+NOTE: Be prepared to track down certs for signed gems and add them the same way you added mine.
+ +âĻ
+ +Use the strategy as a middleware in your application:
+ +require "omniauth-openid"
+require "openid/store/filesystem"
+
+use Rack::Session::Cookie
+use OmniAuth::Strategies::OpenID, store: OpenID::Store::Filesystem.new("/tmp")
+
+
+Then simply direct users to /auth/open_id to prompt them for their OpenID identifier. You may also pre-set the identifier by passing an identifier parameter to the URL (Example: /auth/open_id?openid_url=yahoo.com).
A list of all OpenID stores is available at http://github.com/openid/ruby-openid/tree/master/lib/openid/store/
+ +If OpenID is one of several authentication strategies, use the OmniAuth Builder:
+ +require "omniauth-openid"
+require "openid/store/filesystem"
+
+use OmniAuth::Builder do
+ provider :open_id, store: OpenID::Store::Filesystem.new("/tmp")
+end
+
+
+You may pre-configure an OpenID identifier. For example, to use Googleâs main OpenID endpoint:
+ +use OmniAuth::Builder do
+ provider :open_id, nil, :name => 'google', :identifier => 'https://www.google.com/accounts/o8/id'
+end
+
+
+Note the use of nil, which will trigger ruby-openidâs default Memory Store.
+ +Please contribute some documentation if you have the gumption! The maintainerâs time is limited, and sometimes the authors of PRs with new options donât update the this readme. đ
+ +See SECURITY.md.
+ +If you need some ideas of where to help, you could work on adding more code coverage,
+or if it is already đ¯ (see below) check issues, or PRs,
+or use the gem and think about how it could be better.
We so if you make changes, remember to update it.
See CONTRIBUTING.md for more detailed instructions.
+ +See CONTRIBUTING.md.
+ +Everyone interacting with this projectâs codebases, issue trackers,
+chat rooms and mailing lists agrees to follow the .
Made with contributors-img.
+ +</a>
+ +This Library adheres to .
+Violations of this scheme should be reported as bugs.
+Specifically, if a minor or patch version is released that breaks backward compatibility,
+a new version should be immediately released that restores compatibility.
+Breaking changes to the public API will only be introduced with new major versions.
Yes. But Iâm obligated to include notesâĻ
+ +SemVer should, but doesnât explicitly, say that dropping support for specific Platforms
+is a breaking change to an API.
+It is obvious to many, but not all, and since the spec is silent, the bike shedding is endless.
++ +dropping support for a platform is both obviously and objectively a breaking change
+
To get a better understanding of how SemVer is intended to work over a projectâs lifetime,
+read this article from the creator of SemVer:
As a result of this policy, and the interpretive lens used by the maintainer,
+you can (and should) specify a dependency on these libraries using
+the Pessimistic Version Constraint with two digits of precision.
For example:
+ +spec.add_dependency("omniauth-openid", "~> 3.1")
+
+
+See CHANGELOG.md for a list of releases.
+ +The gem is available as open source under the terms of
+the MIT License .
+See LICENSE.txt for the official Copyright Notice.
You made it to the bottom of the page,
+so perhaps youâll indulge me for another 20 seconds.
+I maintain many dozens of gems, including this one,
+because I want Ruby to be a great place for people to solve problems, big and small.
+Please consider supporting my efforts via the giant yellow link below,
+or one of the others at the head of this README.
| Version | +Supported | +
|---|---|
| 2.x | +â | +
| 1.x | +â | +
To report a security vulnerability, please use the
+Tidelift security contact.
+Tidelift will coordinate the fix and disclosure.
If you are interested in support for versions older than the latest release,
+please consider sponsoring the project / maintainer @ https://liberapay.com/pboling/donate,
+or find other sponsorship links in the README.
Available as part of the Tidelift Subscription.
+ +The maintainers of this library and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source packages you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers for the exact packages you use. Learn more.
+ +Provides strategies for authenticating to providers using the OpenID v2 standard, which is deprecated, and very old. It is not for the modern OpenID Connect (OIDC) standard. For OpenID Connect (OIDC) check out: omniauth/omniauth_openid_connect
+ +| Tokens to Remember | +
+ |
+
|---|---|
| Works with JRuby | +
+ |
+
| Works with MRI Ruby 3 | +
+ |
+
| Works with MRI Ruby 2 | +
+ |
+
| Source | +
+ |
+
| Documentation | +
+ |
+
| Compliance | +
+ |
+
| Style | +
+ |
+
| Support | +
+ |
+
| Enterprise Support | +
+ đĄSubscribe for support guarantees covering all FLOSS dependencies! đĄTidelift is part of Sonar! đĄTidelift pays maintainers to maintain the software you depend on! đ @Pointy Haired Boss: An enterprise support subscription is ânever gonna let you downâ, and supports open source maintainers! |
+
| Comrade BDFL đī¸ | +
+ |
+
+... đ |
+
+ |
+
Install the gem and add to the applicationâs Gemfile by executing:
+ +$ bundle add omniauth-openid
+
+
+If bundler is not being used to manage dependencies, install the gem by executing:
+ +$ gem install omniauth-openid
+
+
+omniauth-openid is cryptographically signed, and has verifiable SHA-256 and SHA-512 checksums by
+stone_checksums. Be sure the gem you install hasnât been tampered with
+by following the instructions below.
Add my public key (if you havenât already, expires 2045-04-29) as a trusted certificate:
+ +gem cert --add <(curl -Ls https://raw.github.com/omniauth/omniauth-openid/main/certs/pboling.pem)
+
+
+You only need to do that once. Then proceed to install with:
+ +gem install omniauth-openid -P MediumSecurity
+
+
+The MediumSecurity trust profile will verify signed gems, but allow the installation of unsigned dependencies.
This is necessary because not all of omniauth-openidâs dependencies are signed, so we cannot use HighSecurity.
If you want to up your security game full-time:
+ +bundle config set --global trust-policy MediumSecurity
+
+
+NOTE: Be prepared to track down certs for signed gems and add them the same way you added mine.
+ +âĻ
+ +Use the strategy as a middleware in your application:
+ +require "omniauth-openid"
+require "openid/store/filesystem"
+
+use Rack::Session::Cookie
+use OmniAuth::Strategies::OpenID, store: OpenID::Store::Filesystem.new("/tmp")
+
+
+Then simply direct users to /auth/open_id to prompt them for their OpenID identifier. You may also pre-set the identifier by passing an identifier parameter to the URL (Example: /auth/open_id?openid_url=yahoo.com).
A list of all OpenID stores is available at http://github.com/openid/ruby-openid/tree/master/lib/openid/store/
+ +If OpenID is one of several authentication strategies, use the OmniAuth Builder:
+ +require "omniauth-openid"
+require "openid/store/filesystem"
+
+use OmniAuth::Builder do
+ provider :open_id, store: OpenID::Store::Filesystem.new("/tmp")
+end
+
+
+You may pre-configure an OpenID identifier. For example, to use Googleâs main OpenID endpoint:
+ +use OmniAuth::Builder do
+ provider :open_id, nil, :name => 'google', :identifier => 'https://www.google.com/accounts/o8/id'
+end
+
+
+Note the use of nil, which will trigger ruby-openidâs default Memory Store.
+ +Please contribute some documentation if you have the gumption! The maintainerâs time is limited, and sometimes the authors of PRs with new options donât update the this readme. đ
+ +See SECURITY.md.
+ +If you need some ideas of where to help, you could work on adding more code coverage,
+or if it is already đ¯ (see below) check issues, or PRs,
+or use the gem and think about how it could be better.
We so if you make changes, remember to update it.
See CONTRIBUTING.md for more detailed instructions.
+ +See CONTRIBUTING.md.
+ +Everyone interacting with this projectâs codebases, issue trackers,
+chat rooms and mailing lists agrees to follow the .
Made with contributors-img.
+ +</a>
+ +This Library adheres to .
+Violations of this scheme should be reported as bugs.
+Specifically, if a minor or patch version is released that breaks backward compatibility,
+a new version should be immediately released that restores compatibility.
+Breaking changes to the public API will only be introduced with new major versions.
Yes. But Iâm obligated to include notesâĻ
+ +SemVer should, but doesnât explicitly, say that dropping support for specific Platforms
+is a breaking change to an API.
+It is obvious to many, but not all, and since the spec is silent, the bike shedding is endless.
++ +dropping support for a platform is both obviously and objectively a breaking change
+
To get a better understanding of how SemVer is intended to work over a projectâs lifetime,
+read this article from the creator of SemVer:
As a result of this policy, and the interpretive lens used by the maintainer,
+you can (and should) specify a dependency on these libraries using
+the Pessimistic Version Constraint with two digits of precision.
For example:
+ +spec.add_dependency("omniauth-openid", "~> 3.1")
+
+
+See CHANGELOG.md for a list of releases.
+ +The gem is available as open source under the terms of
+the MIT License .
+See LICENSE.txt for the official Copyright Notice.
You made it to the bottom of the page,
+so perhaps youâll indulge me for another 20 seconds.
+I maintain many dozens of gems, including this one,
+because I want Ruby to be a great place for people to solve problems, big and small.
+Please consider supporting my efforts via the giant yellow link below,
+or one of the others at the head of this README.
| t |