nebulab / simple_command

A simple, standardized way to build and use Service Objects (aka Commands) in Ruby
http://nebulab.it
MIT License
625 stars 55 forks source link

How to modify default token expiration time #21

Open Nmuta opened 5 years ago

Nmuta commented 5 years ago

Hi, I'm using SimpleCommand in a Rails app with an Angular 7 front end. It all works beautifully and the auth is smooth and great.

I'm doing a very simple implementation similar to the one you have here in Github example.

My question is: how do I adjust the expiration date of the token ? It seems to default to 24 hours ( I think )

Let me know if you can, or point me in the right direction... thanks !

bmorrall commented 4 years ago

Disclaimer: not a member of the SimpleCommand team

SimpleCommand doesn't handle auth or token expiry itself, it's just a utility that provides a safe place to encapsulate that logic, which you are responsible for providing.

It sounds like you came here from a JWT tutorial like I did. You need to set the expiration date of the token when you create it, it's too late by the time you're using SimpleCommand.

Here's an example where a Token is created with an expiry time, from the offical ruby-jwt gem: https://github.com/jwt/ruby-jwt#expiration-time-claim