WestKeys

WestKeys

Handling TOTP

Currently building authentication for a mobile app, and the flow goes as follows:

User inputs phone # > User receives TOTP SMS > User inputs TOTP > User is logged in

Would you store TOTP in DB or in memory (ETS or GenServer)?

Most Liked

benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

Database. It lets you run multiple versions of your app easily, and if your app goes offline, that doesn’t nuke people’s code.

GenServers / ets are a great way to store ephemeral state or cache values. TOTP codes are short lived but not ephemeral.

Exadra37

Exadra37

It means that if you store them in memory and your server goes off or restarts before the user receives the TOPT and inputs it, then the application will not recognize the valid TOPT and the user is forced to repeat the process.

benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

Definitely a separate table. You want to track individual issuances of these codes.

Last Post!

thinkingcat

thinkingcat

Do we also store the secrets from the TOTP algorithm in the same table or separate? Thanks!!

EDIT: just found this and it suggests that we would store it in a separate table:

https://github.com/dashbitco/bytepack_archive/blob/main/apps/bytepack/lib/bytepack/accounts/user_totp.ex

super helpful reference in case anyone else needs it!

Where Next?

Popular in Questions Top

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 records...
New
vonH
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
ovidiubadita
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
lastday4you
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
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New

Other popular topics Top

hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New
AstonJ
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
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
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New

We're in Beta

About us Mission Statement