Replies: 1 comment 1 reply
-
|
this is the copy of #379. When I see that discussions are also set up for the repo I decided to migrate it to here |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
as far as I understand
acts_as_token_authentication_handler_fordoes 2 things. First, it does addauthenticate_#{entity.name_underscore}_from_tokenmethod. Second, uses one of these methods as a controller filter.This approach becomes a problem when an app supports more than one authentication method. Our app needs to decide the authentication method using the headers on the request. We have a filter with the name
authenticate_user_with_multiple_system!. This method actually authenticates the user either with JWT, doorkeeper or devise. However when we useacts_as_token_authentication_handler_formethod another filter is automatically added. I believe that the api of this gem would be more flexible and beneficial ifacts_as_token_authentication_handler_formethod only defines the filter hooks and application developer use the filter method explicitly later on.Below I share a code snippet to demonstrate the auth logic with more than one authentication method
With the current API
authenticate_user_from_tokenorauthenticate_user_from_token!methods runs no matter what. We can skip it usingskip_before_actionbut I believe that usingauthenticate_user_from_tokendirectly is way more explicit.My current workaround (Actually I dont try this yet but I believe that it should work)
Beta Was this translation helpful? Give feedback.
All reactions