manooohar
How to get session tokens to work across browsers?
Hi everyone,
I created a new live view app and using phx.gen.auth for authentication. How can I achieve the session tokens (cookie) works for only single system/browser.
I can copy the logged in token from dev tools and use in different browser to access page, I don’t want this to happen.
Is there a simple way to do this? Thanks in advance!!!
Marked As Solved
LostKobrakai
You cannot secure your users browser. If a cookie can be copied from (browser) a to b that’s nothing you can do to prevent this. You generally don’t even know if the request comes from a browser in the first place.
What you can look into is not accepting the cookie as valid given some additional checks you do. That’s the fingerprinting mentioned earlier. Simplest would be using IP and/or user agent checks or even more involved browser/js level stuff. All of those come with tradeoffs though. E.g. personal internet access often do not come with a stable IP, user agent strings are easier copied than the cookie, js level checks might change return value, … In the end most of those values also have ways to be set from the client, so can be worked around. Therefore in the end you’re back to “you cannot prevent this, you can only make things harder”.
Also Liked
derek-zhou
If your security team cannot explain to you why, then it is highly likely that they are full of it.
arcanemachine
Isn’t that how every single cookie works? Does your security model really need to include “someone hacked the users’s browser”?
derek-zhou
Then you need to fingerprint the browser. Search for it, there are a few ways to do it.
It may has ethical or legal consequence though.
Last Post!
manooohar
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #hex









