Rails two-legged OAuth provider?

前端 未结 2 1786
悲哀的现实
悲哀的现实 2021-02-06 14:02

I have a rails 2.3.5 application with an API I wish to protect.

There is no user - it is an app to app style webservice (more like an Amazon service than facebook), and

相关标签:
2条回答
  • 2021-02-06 14:36

    I'm not aware of any alternatives to oauth-plugin at the moment, though it is definitely getting long in the tooth and ripe for a replacement. My recommendation is to generate the oauth server from oauth-plugin, then extract the dependencies from the plugin (which are just a couple modules worth of methods) and trash the plugin. Then tweak everything to your needs. 2-legged oauth should not be a big problem since it is simpler than 3-legged anyway, and my feeling is that oauth-plugin is not usable these days without significant modifications anyway.

    The meat of OAuth has long been extracted into the base oauth gem anyway, so the oauth-plugin is sort of in limbo. The architecture makes some heavy-handed assumptions about what authentication system you are using, and the generated code is dated. So to me, oauth-plugin serves more as an example of how to wire everything up rather than something that most sites would want to use out of the box.

    0 讨论(0)
  • 2021-02-06 14:37

    Previously, the only good answer was to hack about in the oauth-plugin to get this subset of the oauth interaction. Since then, the oauth-plugin was refactored, and now you can use it straight up, just by adding the right type of authentication filter to your controller:

    class ApiController < ApplicationController
    
        include OAuth::Controllers::ApplicationControllerMethods
    
        oauthenticate :strategies => :two_legged, :interactive => false
    
        # ...
    
    end
    
    0 讨论(0)
提交回复
热议问题