Skip to content

zeroX-tj/rack-oauth2-server

 
 

Repository files navigation

Rack::OAuth2::Server

OAuth 2.0 Authorization Server as a Rack module. Because you don’t allow strangers into your app, and OAuth 2.0 is the new awesome.

tools.ietf.org/html/draft-ietf-oauth-v2-10

Assertions

This is a fork to support assertions. Refer to the original repository for a full readme. To use assertions you need to assign a block to assertion_handler option, below is an example you can use in your rails initializer.

MyApplication::Application.config.oauth.assertion_handler = lambda do |type, token|
  if type == 'facebook'
    facebook = URI.parse('https://graph.facebook.com/me?access_token=' + token)
    user_data = nil
    open(facebook) do |result| 
      user_data = ActiveSupport::JSON.decode(result)
    end
    user = User.from_facebook_data(user_data)
    return user.id.to_s if user
  end
  nil
end

Credits

Adapted by niels vandekeybus to support assertions.

Rack::OAuth2::Server was written to provide authorization/authentication for the new Flowtown API. Thanks to Flowtown for making it happen and allowing it to be open sourced.

Rack::OAuth2::Server is available under the MIT license.

About

OAuth 2.0 Authorization Server as a Rack module

Resources

License

Stars

Watchers

Forks

Packages

No packages published