SpoonWood
Hello Everyone,
We are using LiveView to build a feature that displays some information in the admin dashboard of our Application, but we are not quite sure how to secure the websocket against access of non registered users.
Is the socket secure if we are using a signing salt and a Session key, having installed LiveView the exact Way thats recommended on Hexdocs.pm (we are using LiveView 0.8.1 currently)
Thank you very much in Advance
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
Hi everyone,
I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding.
I sta...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
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
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
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
Other Trending Topics
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
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
Hi everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #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
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #hex
- #security











Showing Posts 17 to 8- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
daveboo
So, it would be unwise to have live routes behind this pipeline then?
scope “/”, MyAppWeb do
pipe_through [:browser, :visitor, :redirect_if_user_is_authenticated]
josevalim
Using the route helpers is better because:
That said, this will just work too:
<%= link "Logout", to: Routes.user_session_path(@socket, :delete), method: :delete %>.leductam
After read the docs about links , I’ve changed the template and now no need to pass @conn:
<li><%= link "Logout", to: "/users/logout", method: :delete %></li>But I still misunderstand why the default template _user_menu.html.eex in mix phx.gen.auth use @conn at:
<%= link "Logout", to: Routes.user_session_path(@conn, :delete), method: :delete %>Btw, I got the worth information at the commit Add security considerations section to docs.
LostKobrakai
You should be able to generate the url just fine with both a conn or a socket. It just can’t be a
live_patchorphx-clickaction, but it must be a proper http call to the server to log the user out.leductam
Thank for your instant feedback, but the current logout link in template is:
<%= link "Logout", to: Routes.user_session_path(@conn, :delete), method: :delete %>Then could we put the @conn to session at the login (as the usual) and use @conn in Liveview (mount(_, session, socket)) to put assigns to render the Logout link?
Imagine that we stand somewhere in Liveview and need the precisely way to perform logout action.
josevalim
The logout action should still be a regular controller action since LiveView cannot set cookies/session.
leductam
I’m using the LiveView and also approach phx.gen.auth.
The web execute login as usual, but how can we logout by using UserAuth.logout_user from LiveView (no @conn)? As there is the logout templates that are rendered underneath LiveView’s template.
josevalim
Here are the changes to enable this feature on top mix phx.gen.auth: Set the live_socket_id on login and disconnect on logout · dashbitco/mix_phx_gen_auth_demo@1eebcae · GitHub
It is really straight-forward and it is per session (i.e. it doesn’t disconnect all sessions, only the current one).
josevalim
You can also disconnect just one of the sessions. All you have to do is identify the connections per session token rather than user id. That’s what I am submitting to
mix phx.gen.auth.Exadra37
Sorry I missed that the signature of
mount/3ismount(params, session, socket)… I am feeling a bit stupid now