Skip to content

Repository files navigation

Rack::OpenID

VersionDownloads TodayCI Supported BuildCI Unsupported BuildCI Style BuildCI Coverage BuildCI Heads Build


Liberapay Goal ProgressSponsor Me on GithubBuy me a coffeeDonate on PolarDonate to my FLOSS or refugee efforts at ko-fi.comDonate to my FLOSS or refugee efforts using Patreon


Provides a more HTTP-ish API around the ruby-openid library.

Installation

Install the gem and add to the application's Gemfile by executing:

$ bundle add rack-openid2

If bundler is not being used to manage dependencies, install the gem by executing:

$ gem install rack-openid2

Usage

You trigger an OpenID request similar to HTTP authentication. From your app, return a "401 Unauthorized" and a "WWW-Authenticate" header with the identifier you would like to validate.

On competition, the OpenID response is automatically verified and assigned to env["rack.openid.response"].

Rack Example

MyApp=lambdado |env|
ifresp=env["rack.openid.response"]caseresp.statuswhen:success
...
when:failure
...
else[401,{"WWW-Authenticate"=>'OpenID identifier="http://example.com/"'},[]]endendenduseRack::OpenIDrunMyApp

Sinatra Example

# Session needs to be before Rack::OpenIDuseRack::Session::Cookierequire'rack/openid'useRack::OpenIDget'/login'doerb:loginendpost'/login'doifresp=request.env["rack.openid.response"]ifresp.status == :success"Welcome: #{resp.display_identifier}"else"Error: #{resp.status}"endelseheaders'WWW-Authenticate'=>Rack::OpenID.build_header(:identifier=>params["openid_identifier"])throw:halt,[401,'got openid?']endendenable:inline_templates
__END__
@@ login
<form action="/login" method="post">
<p>
<label for="openid_identifier">OpenID:</label>
<input id="openid_identifier" name="openid_identifier" type="text" />
</p>
<p>
<input name="commit" type="submit" value="Sign in" />
</p>
</form>

General Info

Primary NamespaceRack::OpenID
gem nameruby-openid2
code triageOpen Source Helpers
documentationon Github.com, on rubydoc.info
expert supportGet help on Codementor
... 💖Liberapay PatronsSponsor MeFollow Me on LinkedInFind Me on WellFound:Find Me on CrunchBaseMy LinkTreeFollow Me on Ruby.SocialTweet @ Peter💻🌏

TODO

  • 1 failing test (skipped)
  • rewrite tests with minitest/spec

🌈 Contributors

Current maintainer(s):

Special thanks to:

and contributors to original rack-openid:

Contributors

Made with contributors-img.

🪇 Code of Conduct

Everyone interacting in this project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

📌 Versioning

This Library adheres to Semantic Versioning 2.0.0. 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.

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, 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("rack-openid2","~> 2.0")

See CHANGELOG.md for list of releases.

📄 License

The gem is available as open source under the terms of the MIT LicenseLicense: MIT.

See LICENSE.txt for the official Copyright Notice.

🤑 One more thing

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.

Buy me a latte

About

Provides a more HTTPish API around the ruby-openid library

Resources

Code of conduct

Contributing

Security policy

Stars

5 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages