script
Increase token expiry time in guardian jwt
In the Guardian jwt the exp is default set for every newly generate token:
inside claims like this
%{
"aud" => "ChromaticUser:181",
"exp" => 1533199493,
"iat" => 1533197693,
"iss" => "Haitracker",
"jti" => "2e52621c-110a-412d-86e3-f9cb00c145e4",
"pem" => %{},
"sub" => "ChromaticUser:181",
"typ" => "access"
}
Is there any way we can change it(increase it)?. I couldn’t find anything inside documentation
I want to send the token to the user in the email for password reset. And I want to increase its expiry.
Thanks
Marked As Solved
stephane
I think you have to override default ttl :
# with plug
MyApp.Guardian.Plug.sign_in(conn, resource, %{some: "claim"}, ttl: {1, :minute})
# Or directly by encode_and_sign
MyApp.Guardian.encode_and_sign(resource, %{}, ttl: {1, :minute})
Or you can do this globally:
config :your_app, YourApp.Guardian,
# ...
ttl: {1, :minute}
# ...
2
Also Liked
yurko
Should work with ttl option, like ttl: {4, :weeks}. Would be the last parameter to sign_in.
UPD s. example in docs here https://hexdocs.pm/guardian/Guardian.html
1
Popular in Questions
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
I am trying to figure out how Mix knows whether the environment is test, dev, or prod -- where is this set?
Thanks.
New
What is the idiomatic way of matching for not nil in Elixir?
E.g.,
First way:
defp halt_if_not_signed_in(conn, signed_in_account) when...
New
As many of you may have realized by now (sorry for all the posts here) I’ve been working on a db problem where I’m trying to aggregate a ...
New
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
Hey all,
I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
Hi,
I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
To simplify some tasks at work, I wrote and published this package yesterday. It’s a simple macro that enables Access behaviour on struct...
New
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
Other popular topics
Hello, I get Persian date from my client and convert it to normal calendar like this:
def jalali_string_to_miladi_english_number(persi...
New
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1]
15:22:35.803 [error] gen_event {lager_file_backend...
New
What is the proper way to load a module from a file in to IEX?
In the python world, doing something like this pretty standard:
from ....
New
Phoenix 1.4.0 released
Phoenix 1.4 is out! This release ships with exciting new features, most notably
with HTTP2 support, improved deve...
New
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
I would like to know what is the best IDE for elixir development?
New
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
The Elixir Typespec docs show the following syntax for keyword lists in typespecs:
# ...
| [key: type] # keyword lis...
New
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New







