1
votes

Im using the Knock gem (https://github.com/nsarno/knock) for JWT based authentication in my Rails 5 application. The authentication token generated auto expires after one day. Is there any way i can either prevent the auto expiration of the token or prolong the expiration ?

Thanks

1

1 Answers

2
votes

Yes you can define how long the token should be valid with Knock. First you need to install the initializer:

$ rails generate knock:install

This will generate the initializer file in config/initializers/knock.rb

Than you need to define how long the token should be valid. For example if the token should be valid for 7 days you simply have to set the lifetime to 7 days:

config.token_lifetime = 7.days

or if the token should life "forever" you can set the lifetime to nil:

config.token_lifetime = nil