warden-jwt_auth icon indicating copy to clipboard operation
warden-jwt_auth copied to clipboard

Feature Request: Dynamic expiration_time based on request params

Open hmnhf opened this issue 1 year ago • 1 comments

Hello, and thank you for the effort you've put into this useful gem!

In our case, we need to have a different expiration_time set for the generated token based on a request parameter.

Looking through the code, it seems possible to change expiration_time setting to also support a callable object (e.g. a proc) with the request params passed to it similar to the following:

Warden::JWTAuth.configure do |config|
  config.expiration_time = proc { |request_params| request_params['remember_me'] ? 24.hours.to_i : 1.hour.to_i }
  ...
end

Would you be interested in accepting a PR for this feature?

EDIT 1: Just saw https://github.com/waiting-for-dev/devise-jwt/issues/264. This feature could help with that issue as well. EDIT 2: We could also make it based on request headers (instead/as well), not necessarily based on params.

hmnhf avatar Nov 09 '23 18:11 hmnhf