aadii104
In CSR we usually pass token with the request for backend verification, and we do this process by extracting the token from localStorage in the browser.
But in SSR we don’t have a browser or storage how can I pass a token to backend for verification?
If not tokens what are other possible solutions?
Thanks.
Trending in Questions
Hey guys,
I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly
Do you guys have any suggestions what is the best prac...
New
Hello!
Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app.
I creat...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
I’m trying to set up Emacs with elixir-ls via lsp-mode and credo via Flycheck. This should mostly be preconfigured as Flycheck picks up c...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
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
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #blog-post
- #elixirconf-us
- #elixir-ls
- #ai
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 9- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
idi527
By SSR do you mean server side rendering? If so, why don’t you just pass the user info necessary for rendering without any authentication?
aadii104
Yes, SSR is server-side rendering.
I have to deliver a customized home page based on the userId or something, also I’ll be needing SSR to serve the inner pages (i.e after login). so without auth, calling data and injecting in HTML won’t be a possible solution.
idi527
Since it’s server-side, don’t you already have direct access to the user data needed for rendering? Just query the database …
aadii104
Yes, I agree.
It would be helpful if you can elaborate sir.
I was thinking of cookies first, but if user blocks then whole system will go down.
later I found that usually when the user blocked cookies you would always store his data server-side and then use a token of sort in every URL
That’s why you see old PHP applications use Example Domain
But I am not sure to use them and couldn’t find a good approach for same.
NobbZ
Do not do this!
You give away session hijacking for free with such a system.
Just explain your users why cookies are necessary. Even the most paranoid people will enable them if you assure them, that they are used for authentication only.
In Europe you are even allowed to do that without telling the user (as long as you do not write to the cookie before the user actually tries to log in), but most sites simply tell the user.
In general, you will store an encrypted and signed chunk of data in the cookie, perhaps using a
Phoenix.Token. In many cases its just the current users id, which you will use to retrieve the users details from the database as necessary (maybe in a plug that uses assigns then?).aadii104
Yes thanks @NobbZ , I understand that people will normally accept, but I wanna try something more solid.
What about sessionId, keeping IP Addresses of recently logged devices. I am able to see a problem with my RAM as I will be needed to keep a extra huge amount of data ( user * 3) in RAM, for fast access.
Any suggestions for same?
NobbZ
Using cookies is the most solid approach. You do not want to use anything else in the browser.
If you have other clients, feel free to otherwise sent the token from the client to the server in the request body, but do yourself a favor and never send it as part of the URL.
You’ll see only one IP shared for all workstations in my office, do you want to treat all of them the same? Do not do this, this is a very bad idea as long as IPv4 is still a thing.
aadii104
As stated in question, I am looking for the approach for SSR auth part, so I just cannot get token for initial first request.
and actually, I didn’t know this thing, lack of knowledge in area.
Thanks
NobbZ
Thats why I said, when you do not use a browser, but when you talk about Client and Server Side Rendering, then you probably do use a browser. So consider it a notabene.
So the cookie approach is the most clean thing for a pure Server Side solution.
But perhaps you could use a mixed approach.
Use JavaScript to send requests, authenticate them as you wish, render the full page on the server and when received from the JS client, just fully replace the page. But you need to do a lot to have a working browser history or to maintain UX during load times on small bandwiths or high latency connections. Well, to be honest, the very same problems you have with full client side renderings in general…