rack-oauth2-server icon indicating copy to clipboard operation
rack-oauth2-server copied to clipboard

Extract different environments (Sinatra, Rails, ... )

Open mulderp opened this issue 12 years ago • 6 comments

In order to make integration of different ORM setups easier (ActiveRecord, ActiveModel, Redis, .. ), a first step might be to separate the environments for Sinatra and Rails.

I did a first preparation in my fork here: https://github.com/mulderp/rack-oauth2-server/tree/extract_envs

This is a strategy that I saw here too: https://github.com/jodosha/redis-store

What do you think? This would most probably evolve into different gems too.

mulderp avatar Apr 10 '13 21:04 mulderp

The names of the Gems might become:

  • oauth2-sinatra
  • oauth2-active_record
  • oauth2-active_model

etc.

mulderp avatar Apr 10 '13 21:04 mulderp

rack-oauth2-server is rack middleware, so it works with any Rack-compliant framework (Rails, Sinatra, etc). What would be in oauth2-sinatra that's not in oauth2-active_record? (Also, ActiveRecord is an implementation of ActiveModel for relational databases, so not sure you need a distinction between the two).

Regardless, if what you're really going for is to make the gem persistence agnostic (and not just hard-wired to MongoDB), you should explore introducing the Repository pattern instead.

http://blog.8thlight.com/mike-ebert/2013/03/23/the-repository-pattern.html

Then you can have Repository implementations for various data stores, either as separate gems, or available in rack-oauth2-server itself, and you simply configure which persistence store you want to use.

My two cents....

bploetz avatar Apr 10 '13 21:04 bploetz

Thanks Brian! The article on the repository pattern looks very helpful indeed.

About the extraction issue, my feeling was that some boilerplate could be removed when working in separate projects (i.e. Sinatra does not need Rails and vice-versa). Maybe it is just that I am new to the codebase that I don't see a simpler way to test the actual Rack middleware vs. the framework boilerplate (which are more integration tests, and maybe some extraction of the test there could help in getting closer to working at an ORM adapter)

mulderp avatar Apr 11 '13 07:04 mulderp

I discovered:

https://github.com/trumant/rack-oauth2-server-active-record/commits/active_record

That looks like having a separate sub-repo for AR interesting, but I need to experiment to understand better.

mulderp avatar Apr 11 '13 20:04 mulderp

Hm.. this looks like an interesting plugin for Rack too to handle storage of tokens: https://github.com/minad/moneta

mulderp avatar Apr 12 '13 16:04 mulderp

Moneta looks really interesting

assaf avatar Apr 13 '13 20:04 assaf