dropoutkiddo

dropoutkiddo

Api Pow authorization token validity time

Hi,
I’ve created authorization for my external api identical as in the POW docs https://hexdocs.pm/pow/api.html.
My question is, how to set token validity time for this api authorization?
I set:
credentials_cache_store:
{Pow.Store.CredentialsCache, ttl: :timer.minutes(28800), namespace: “credentials”},
session_ttl_renewal: :timer.minutes(30),
cache_store_backend: Pow.Store.Backend.EtsCache
in the main config and it’s working for the CMS part of the project but not for the external api part.
Anybody can help me? Thanks in advance.

Marked As Solved

danschultzer

danschultzer

Pow Core Team

You’ll have to set it in the store config options, as you are calling the Pow.Store.CredentialsCache directly. :credentials_cache_store is only used in Pow.Plug.Session plug.

So do this instead:

store_config
|> Keyword.put(:ttl, :timer.minutes(28800))
|> CredentialsCache.put(access_token, {user, [renewal_token: renewal_token]})

Or if you want to use the same setting as in your config:

{_store, opts} = Config.get(config, :credentials_cache_store, nil) || raise "No `:credentials_cache_store` config option set"

store_config
|> Keyword.merge(opts)
|> CredentialsCache.put(access_token, {user, [renewal_token: renewal_token]})

I strongly encourage you to keep the TTL much shorter than what you got. OWASP recommends the following:

Common idle timeouts ranges are 2-5 minutes for high-value applications and 15-30 minutes for low risk applications.

Where Next?

Popular in Questions Top

srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call th...
New
dotdotdotPaul
Okay, I'm having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I'm sure I'...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 record...
New
New
Kagamiiiii
Student & New to elixir. Nice language. I want to convert a english character, e.g. “a”, which is stored in a variable, to it’s asci...
New
script
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this "1000" What is the ...
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list....
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New

Other popular topics Top

JDanielMartinez
Hi! May someone helps me, please! I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
New
sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
977 41022 311
New
senggen
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
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
_russellb
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
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New

We're in Beta

About us Mission Statement