doorkeeper icon indicating copy to clipboard operation
doorkeeper copied to clipboard

pass application into AccessToken#create method

Open stereoscott opened this issue 2 years ago • 5 comments

This avoids refetching the application object from the database when it's referenced inside of attributes_for_token_generator. Closes #1574

stereoscott avatar Jun 06 '22 22:06 stereoscott

I thought it should be cached if already called :thinking: Also I;m wondering if we could break any existing ORM extension with such changes. Have to think

nbulaj avatar Jun 07 '22 07:06 nbulaj

I thought it should be cached if already called 🤔 Also I;m wondering if we could break any existing ORM extension with such changes. Have to think

In my case the application passed into the method was initially fetched by name, but within theAccessToken model it fetches by ID so it missed the query cache.

It's likely this hasn't come up before because for the built-in implementation where tokens are being generated via Doorkeeper::ApplicationsController the application is fetched by the application_id provided in the params. Not sure of other use cases where the application object may not be fetched by ID and if those warrant this change.

stereoscott avatar Jun 07 '22 13:06 stereoscott

OK, analyzed some source code and I think it should be fine. Thanks!

nbulaj avatar Jun 21 '22 07:06 nbulaj

Aha, tests shows some issues

nbulaj avatar Jun 23 '22 06:06 nbulaj

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Sep 21 '22 00:09 stale[bot]