assaf / rack-oauth2-server

LOOKING FOR MAINTAINER — OAuth 2.0 Authorization Server as a Rack module
http://documentup.com/assaf/rack-oauth2-server/
MIT License
231 stars 76 forks source link

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

Open mulderp opened 11 years ago

mulderp commented 11 years ago

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 commented 11 years ago

The names of the Gems might become:

etc.

bploetz commented 11 years ago

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....

mulderp commented 11 years ago

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 commented 11 years ago

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 commented 11 years ago

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

assaf commented 11 years ago

Moneta looks really interesting