-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Polymorphic user model associations #1069
Comments
Hi @milgner . Yep, I think it would be nice to have such feature. Moreover, it will help OAuth Token Introspection to add additional info for the response. Feel free to send a PR, but be sure that we wouldn't break backward compatibility for legacy applications. |
Hi @milgner . Any news on this issue? |
It's not so simple as many parts of the Doorkeeper are tied to Resource Owner. I've created a branch with some stubs for polymorphic Resource Owner, currently it has broken test suite and requires some changes. This implementation couldn't be merged to master because of incompatibility issues with old versions of Doorkeeper. So if such feature ever would be released, it requires to be compatible with old versions of the gem. |
Closing this stale issue. If somebody will need it and find this issue, take a look at the branch mentioned above and feel free to send a PR, but keep in mind to do it backward compatible (it must be a configuration option, like |
can you give me example doorkeeper configuration for polymorphic_owner true? undefined method `polymorphic_owner' for #Doorkeeper::Config::Builder:0x000000000b3cc2c8 (NoMethodError) when generate doorkeeper:migration |
@top1st you are using my branch for polymorphic owner or what? Need more details Current Doorkeeper version doesn't support polymorphic owner (in terms of Rails) |
Yes. I am using yours |
Honestly - I don't remember what we have in this branch. And I didn't ever tried it on real project, it's just a stub for those who wants to work on polymorphic associations :) |
guess i need to customize my self , |
i did a poc of this here. the change to look at is here - essentially everything that took a i think that a global config switch could make this approach backwards compatible - essentially the i'm curious though - is the REST api the only "public" api, or does compatibility need to be maintained with the ruby methods as well? |
Yep, many projects that uses Doorkeeper could (and they are!) patch some Doorkeeper internals. GitLab is one of them. So it's not so easy to just change everything and not break any existing project. |
@modosc it requires additional tests, but it's hard to implement them just because AR mixins and models must be reloaded at run-time with a new option. Also many specs reloads Doorkeeper configuration and must be fixed too. I don't sure if somebody could help here |
Implemented in #1355 and would be released with Doorkeeper 5.4 RC (not release ETA for now) |
Just like in this this SO question, I'm using doorkeeper scopes to hand out access tokens for multiple models.
The problem with the accepted answer there is that doorkeeper doesn't persist the information of the model on the token, causing problems with scoping of the
resource_owner_id
column in methods likeAccessToken.revoke_all_for
.Are there any plans to support a polymorphic user model association within doorkeeper? Would you accept a pull request towards to accomplish this? My plan would be to just add a
resource_owner_type
column, adapt the access token mixin and setpolymorphic: true
on the ActiveRecord association. I'd need to investigate the other ORM integrations separately on how to accomplish this but I assume that they have similar features.The text was updated successfully, but these errors were encountered: