Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

oauth

Package Overview
Dependencies
Maintainers
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

oauth

  • 1.1.0
  • Rubygems
  • Socket score

Version published
Maintainers
9
Created
Source

OAuth 1.0 Logo by Chris Messina, CC BY-SA 3.0, via Wikimedia Commons Yukihiro Matsumoto, Ruby Visual Identity Team, CC BY-SA 2.5

Ruby OAuth

OAuth 1.0 is an industry-standard protocol for authorization.

This is a RubyGem for implementing both OAuth 1.0 clients and servers in Ruby applications. See the sibling oauth2 gem for OAuth 2.0 implementations in Ruby.

New EOL Policy

Versions 1.x will be EOL no later than April, 2025. Versions 0.6.x will be EOL no later than April, 2024. Versions 0.5.x will be EOL no later than April, 2023.

This will facilitate dropping support for old, dead, and crusty versions of Ruby.

Non-commercial support for the oldest version of Ruby (which itself is going EOL) will be dropped each year in April.

Please upgrade to version 1.1. The only breaking change in 1.x is dropping old Rubies.

Status

Projectbundle add oauth
1️⃣name, license, docsRubyGems.org License: MIT RubyDoc.info
2️⃣version & activityGem Version Total Downloads Download Rank Source Code Open PRs Closed PRs
3️⃣maintenance & lintingMaintainability Helpers Depfu Contributors Style Kloc Roll
4️⃣testingOpen Issues Closed Issues Supported Heads MacOS Windows
5️⃣coverage & securityCodeClimate CodeCov Coveralls Security Policy CodeQL Code Coverage
6️⃣resourcesDiscussion Get help on Codementor Chat Blog Blog
7️⃣spread 💖Liberapay Patrons Sponsor Me Tweet @ Peter 🌏 👼 💻

Installation

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

$ bundle add oauth

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

$ gem install oauth

OAuth for Enterprise

Available as part of the Tidelift Subscription.

The maintainers of OAuth2 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 of the exact packages you use. Learn more.

Security contact information Security Policy

To report a security vulnerability, please use the Tidelift security contact. Tidelift will coordinate the fix and disclosure.

For more see SECURITY.md.

Compatibility

Targeted ruby compatibility is non-EOL versions of Ruby, currently 2.7, 3.0, and 3.1. Ruby is limited to 2.7+ in the gemspec, and this will change with minor version bumps, while the gem is still in 0.x, in accordance with the SemVer spec.

The main branch now targets 1.x releases, for Ruby >= 2.7. See v0.6-maintenance (EOL April, 2024) branch for Ruby >= 2.4. See v0.5-maintenance (EOL April, 2023) branch for Ruby >= 2.0.

NOTE: No further releases of version < 1.0.x are anticipated.

Ruby Engine Compatibility Policy

This gem is tested against MRI, and to a lesser extent, against JRuby, and Truffleruby. Each of those has varying versions that target a specific version of MRI Ruby. This gem should work in the just-listed Ruby engines according to the targeted MRI compatibility in the table below. If you would like to add support for additional engines, first make sure Github Actions supports the engine, then submit a PR to the correct maintenance branch as according to the table below.

Ruby Version Compatibility Policy

If something doesn't work on one of these interpreters, it's a bug.

This library may inadvertently work (or seem to work) on other Ruby implementations, however support will only be provided for the versions listed above.

If you would like this library to support another Ruby version, you may volunteer to be a maintainer. Being a maintainer entails making sure all tests run and pass on that implementation. When something breaks on your implementation, you will be responsible for providing patches in a timely fashion. If critical issues for a particular implementation exist at the time of a major release, support for that Ruby version may be dropped.

Ruby OAuth VersionMaintenance BranchEOL🚂 CompatibilityOfficial 💎Unofficial 💎Incidental 💎
1️⃣1.0.xmainRails 6, 72.7, 3.0, 3.1sorry, not sorrynope
2️⃣0.6.xv0.6-maintenance04/2024Rails 5, 6, 72.7, 3.0, 3.12.5, 2.62.4
3️⃣0.5.xv0.5-maintenance04/2023Rails 2, 3, 4, 5, 6, 72.7, 3.0, 3.12.1, 2.2, 2.3, 2.4, 2.5, 2.62.0
4️⃣olderN/AyesterdayBest of luck to you!Please upgrade!noop

NOTE: Once 1.0 is released, the 0.x series will only receive critical bug and security updates. See SECURITY.md

🚂 NOTE: See notes on Rails in next section.

Basics

This is a ruby library which is intended to be used in creating Ruby Consumer and Service Provider applications. It is NOT a Rails plugin, but could easily be used for the foundation for such a Rails plugin.

This gem was originally extracted from @pelle's oauth-plugin gem. After extraction that gem was made to depend on this gem.

Unfortunately, this gem does have some Rails related bits that are optional to load. You don't need Rails! The Rails bits may be pulled out into a separate gem with the 1.x minor updates of this gem.

Extensions

Usage

We need to specify the oauth_callback url explicitly, otherwise it defaults to "oob" (Out of Band)

callback_url = "http://127.0.0.1:3000/oauth/callback"

Create a new OAuth::Consumer instance by passing it a configuration hash:

oauth_consumer = OAuth::Consumer.new("key", "secret", site: "https://agree2")

Start the process by requesting a token

request_token = oauth_consumer.get_request_token(oauth_callback: callback_url)

session[:token] = request_token.token
session[:token_secret] = request_token.secret
redirect_to request_token.authorize_url(oauth_callback: callback_url)

When user returns create an access_token

hash = { oauth_token: session[:token], oauth_token_secret: session[:token_secret] }
request_token = OAuth::RequestToken.from_hash(oauth_consumer, hash)
access_token = request_token.get_access_token
# For 3-legged authorization, flow oauth_verifier is passed as param in callback
# access_token = request_token.get_access_token(oauth_verifier: params[:oauth_verifier])
@photos = access_token.get("/photos.xml")

Now that you have an access token, you can use Typhoeus to interact with the OAuth provider if you choose.

require "typhoeus"
require "oauth/request_proxy/typhoeus_request"
oauth_params = { consumer: oauth_consumer, token: access_token }
hydra = Typhoeus::Hydra.new
req = Typhoeus::Request.new(uri, options) # :method needs to be specified in options
oauth_helper = OAuth::Client::Helper.new(req, oauth_params.merge(request_uri: uri))
req.options[:headers]["Authorization"] = oauth_helper.header # Signs the request
hydra.queue(req)
hydra.run
@response = req.response

More Information

  • RubyDoc Documentation: RubyDoc.info
  • Mailing List/Google Group: Mailing List
  • GitHub Discussions: Discussion
  • Live Chat on Gitter: Join the chat at https://gitter.im/oauth-xx/oauth-ruby
  • Maintainer's Blog: Blog

Contributing

See CONTRIBUTING.md

Contributors

Contributors

Made with contributors-img.

Versioning

This library aims to adhere 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. Compatibility with a major and minor versions of Ruby will only be changed with a major version bump.

As a result of this policy, you can (and should) specify a dependency on this gem using the Pessimistic Version Constraint with two digits of precision.

For example:

spec.add_dependency "oauth", "~> 1.1"

License

The gem is available as open source under the terms of the MIT License License: MIT. See LICENSE for the [Copyright Notice][copyright-notice-explainer].

Contact

OAuth Ruby has been created and maintained by a large number of talented individuals. The current maintainer is Peter Boling (@pboling).

Comments are welcome. Contact the OAuth Ruby mailing list (Google Group) or GitHub Discussions.

FAQs

Package last updated on 29 Aug 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc