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

oauth2-provider

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

oauth2-provider

  • 0.0.19
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

oauth2-provider

Simple OAuth2 provider code extracted from hashblue.com

Details

  • Implements draft 11 of the oauth2 spec
  • Handles the authorization_code and password grant types
  • Supports ActiveRecord and Mongoid

Usage Instructions

In your Gemfile:

gem 'oauth2-provider', :git => 'git@github.com:freerange/oauth2-provider.git'

If you're using ActiveRecord, grab the schema out of spec/schema.rb, and run the migration.

To dish out authorization codes you will need to implement something like this:

class AuthorizationController < ApplicationController
  include OAuth2::Provider::Rack::AuthorizationCodesSupport

  before_filter :authenticate_user!
  before_filter :block_invalid_authorization_code_requests

  def new
    @client = oauth2_authorization_request.client
  end

  def create
    if params[:yes].present?
      grant_authorization_code(current_user)
    else
      deny_authorization_code
    end
  end

end
    

And add a couple of routes:

match "/oauth/authorize", :via => :get, :to => "authorization#new"
match "/oauth/authorize", :via => :post, :to => "authorization#create"

oauth2-provider will handle requests to /oauth/access_token to handle conversion of authorization codes to access tokens.

FAQs

Package last updated on 05 Sep 2011

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