thiagomajesk

thiagomajesk

Hi! I’ve been thinking about converting an existing app that uses Pow Auth to Liveview and was wondering if anyone had any success integrating both of them recently…

I tried collecting some context from the Pow repository but I don’t think the lib has provided any official support for it just yet (read more here). Since this is an old issue and the maintainer is a little absent from the repository recently, someone suggested that the addition of the on_mount/1 and attach_hook/4 callbacks could help on this front. However, it seems there are already some unanswered questions from one of the oldest issues about how exactly the lib should deal with the active WebSocket connection.

After studying the LiveBeats app repository for a little while, it seems that these problems are already solved with the new auth generator. However, upon looking at what mix phx.gen.auth generates, I’m not super thrilled about maintaining the 19 new files for a simple authentication solution.

Any thoughts?

Showing Posts 1 to 5

Kurisu

Kurisu

I haven’t done anything with LiveView yet, but I also wondered if I could integrate Pow into it when I make the jump. So I saved in my bookmarks this link that seems interesting to me: How to connect Pow and Live View in your Phoenix project - DEV Community.

Please, I haven’t tried it but maybe it will be useful to you since you are already in the process…

I think this thread will be really usefull for us all that like Pow as their favorite authentication library. I hope it leads to a simple and reliable solution.

Please let us know what works for you.

thiagomajesk

thiagomajesk OP

Yeah, I’ve read this post before… If you look at the comments you’ll see that the author was considering migrating over to phx.gen.auth because of some session handling issues. A lot has changed since early 2021 though and I’d like to know if anyone has actually made any progress on that front.

I don’t remember the details but I recall that Pow is designed (or at least defaults to) a very aggresive session renewal model which means that your solution may miss an important aspect - the fact that Pow session may become invalid during the LiveView lifecycle resulting in allowing a user that’s actually logged out to act like he’s authenticated.

Also, and again not sure if it’s correct so please correct me if I’m wrong, aforementioned session renewal in Pow is based on recreating session every half an hour or so and since you can’t do that from LiveView without a HTTP request you’ll end up aleays expiring session if your app routes are live.

The problem is that phx.gen.auth seems a good fit for cases where you want flexibility, but the amount of code it generates does not justify its use for more traditional and simple use cases.

derek-zhou

derek-zhou

That’s why I prefer Guardian over Pow or phx.gen.auth. It is a good middle ground balancing ease of use and flexibility.

thiagomajesk

thiagomajesk OP

I haven’t used Guardian, but after looking at the repo README it seems it’s a little bit less mature/polished than Pow. I’ll take a deeper look at it when I can. Out of curiosity, are you using it in production with LiveView? (I couldn’t find a lot of examples online or documentation about it online yet).

derek-zhou

derek-zhou

You can look here
https://github.com/derek-zhou/liv

It is a hobby project and does not use even have user registration. However, it is liveview and it is using guardian. It is also a bit unorthodox because everything, even the login form, is in liveview.

I have use Guardian in the full capability in other projects but not in LiveView. I don’t think there would be any trouble to use the full Guardian with liveview though. The U/I layer and the authentication layer are independent.

— All posts loaded —

Where Next? Top

Trending in Discussions Top

AstonJ
As the title says, please share what you’ve been up to with Elixir. Whether that’s been learning it, looking into it, making stuff with i...
2977 94592 917
New
cblavier
Hey there, It’s been more than a year since we started using LiveView as our main UI library and building a whole library of UI componen...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
heathen
Quite interesting article Google brought me. Didn’t find any mentions about it here. What do you think in general? Would you use togethe...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
AstonJ
Since we have deprecated our Erlang sections (as we have dedicated Erlang Forums now) let’s add this thread for those who’d like to post ...
New
maennchen
:warning: Security advisory: Decimal DoS vulnerability A vulnerability has been published for decimal where very large exponents can cau...
New

Other Trending Topics Top

JesseHerrick
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
marciok
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
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
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
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews