0.0
The project is in a healthy, maintained state
Provides a more HTTPish API around the ruby-openid2 library
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.0, >= 1.0.2
>= 5, < 6
>= 13
~> 18.2, >= 18.2.1
~> 0.5, >= 0.5.2
>= 1.35.1
~> 0.9, >= 0.9.34
~> 0.0
~> 1.6, >= 1.6.1
~> 1.0, >= 1.0.4
~> 1.0

Runtime

>= 2.2
~> 1.1, >= 1.1.4
~> 3.1, >= 3.1.0
 Project Readme

Rack::OpenID

Version Downloads Today CI Supported Build CI Unsupported Build CI Style Build CI Coverage Build CI Heads Build


Liberapay Patrons Sponsor Me on Github Polar Shield Donate to my FLOSS or refugee efforts at ko-fi.com Donate 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 = lambda do |env|
  if resp = env["rack.openid.response"]
    case resp.status
    when :success
      ...
    when :failure
      ...
    else
      [401, {"WWW-Authenticate" => 'OpenID identifier="http://example.com/"'}, []]
    end
  end
end

use Rack::OpenID
run MyApp

Sinatra Example

# Session needs to be before Rack::OpenID
use Rack::Session::Cookie

require 'rack/openid'
use Rack::OpenID

get '/login' do
  erb :login
end

post '/login' do
  if resp = request.env["rack.openid.response"]
    if resp.status == :success
      "Welcome: #{resp.display_identifier}"
    else
      "Error: #{resp.status}"
    end
  else
    headers 'WWW-Authenticate' => Rack::OpenID.build_header(
      :identifier => params["openid_identifier"]
    )
    throw :halt, [401, 'got openid?']
  end
end

enable :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 Namespace Rack::OpenID
gem name ruby-openid2
code triage Open Source Helpers
documentation on Github.com, on rubydoc.info
expert support Get help on Codementor
... 💖 Liberapay Patrons Sponsor Me Follow Me on LinkedIn Find Me on WellFound: Find Me on CrunchBase My LinkTree Follow Me on Ruby.Social Tweet @ 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 License License: MIT.

See LICENSE.txt for the official Copyright Notice.

🤑 One more thing

You made it to the bottom of the page! If you think maintaining this gem is more difficult than parsing a README, or if you think I've done a bang up job with this gem, please consider supporting my efforts via this link, or one of the others at the head.

Buy me a latte