MarkHarper
An upcoming authentication solution for Phoenix
Just came across this article today. I’m interested to see what people think. I’m currently using Pow, but it’s nice to know that a solution with a generator is coming in the future.
Trending in Discussions
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...
New
@chrismccord : I just saw the Extract AGENTS.md from Phoenix.new into phx.new generator commit to the phoenix project.
My initial shotgu...
New
I was working on an Ecto migration and I needed a timestamp. So, for the nth time, I looked up the different data types for timestamps, a...
New
Just a general thread to post chat/news/info relating to AI/ML stuff that may be relevant for Nx now or in the future. Got anything to sh...
New
I just stumbled on a newly redesigned elixir-lang.org. :tada: It looks like @Software_Mansion did the work, and I think it is generally a...
New
There has been a thread to discuss the Stack Overflow Developer Survey on this forum every year since 2018, so here’s yet another one for...
New
Fly’s CEO posted this recently - Turn And Face The Strange · The Fly Blog
It says that Fly is going all-in on sprites, which is a worry ...
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
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
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
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
@hugobarauna and I (Alex Koutmos) have been hard at work on writing a book on Nerves that takes you from simply blinking LEDs to building...
New
There are three potential reasons for members of this forum to have a look at https://vutuv.de
You are tired or annoyed of LinkedIn.
Yo...
New
Latest Phoenix Threads
Chat & Discussions>Discussions
Latest on Elixir Forum
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
- #elixirconf-us
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #hex
- #performance











First 9 of 9 Posts
bennelsonweiss
I am uncertain how I feel about generators-to-roll-your-own being the “blessed” (
mix phx.gen.auth) authentication solution for Phoenix.As José covers, a library/framework solution for authentication that meets all needs is really hard to get right (and he would know far better than I), but the trade-off of not being able to easily update what was generated if there are vulnerabilities or improvements seems pretty huge.
I don’t have any better solution, and this looks like a perfectly reasonable approach to a tough problem, but I’m a little uncomfortable if the standard solution for the community becomes roll-your-own.
danschultzer
Interesting! Looking forward to see this in action.
Auth is so implementation specific that a scaffold makes sense, but I agree with @bennelsonweiss that rolling your own is risky if you are new to auth and security.
Even after years of dealing with this I still introduce vulnerabilities and miss things
AstonJ
Whoo hoo this is great!
An authentication system like this could be awesome for Phoenix, in fact it has been at the very top of my Phoenix wishlist for some time now!
josevalim
I want to add a small remark on the “easily”. Updating on the library approach is not necessarily easy because the library may have moved to a new major version, it may have fixed bugs you were relying on, or it now depends on a dependency you are not ready to update yet.
When we did security releases with Devise, we had to provide patches/diffs for many versions back, because people were stuck on previous versions for many reasons. I would say applying a patch/diff is most likely the simplest way to fix a security issue, because you want to do the minimal change ASAP, and updating the package may bring unrelated changes unless you are running on the latest version and you just need to bump the patch release.
So from this particular perspective, I actually don’t worry about the generator approach. Especially because I expect the generators to be less prone to bugs due to the much smaller surface area.
My main concern with the generator approach is developers modifying the generated code in unsafe ways, which would be harder to do if the code is in a lib.
bennelsonweiss
That’s very true, and good insight into the problems a library like Devise would have.
When I said “not being able to easily update what was generated” I intended to suggest you would be able to “update” what was generated but that it’ll have to be a more complicated process of communicating where a problem is and how to fix it rather than being able to actually fix the problem yourself.
However it being a complicated process is always true to some extent because even if you can fix the library/framework you need to communicate the need to upgrade to your users, and they need to actually upgrade (which as you point out can itself be complicated).
I didn’t mean to imply that library/framework upgrades- particularly around critical functionality like authentication- are ever easy.
I actually didn’t highlight that issue because any solution with hooks or other mechanisms of extensibility also seem to me like they would probably provide ample places for people to introduce vulnerabilities.
Do you think it would be a lot more of an issue with generators than in something like Devise?
PJextra
Will this authentication work out-of-the-box with LiveView and Phoenix Channels or do we need to handle that ourselves?
josevalim
You will have to do it yourselves. I am actually working on a LV app and the only view I felt necessary porting to LiveView was the setting pages. There isn’t much LV can do for things like login page.
PJextra
Fantastic!
That’s greatly appreciated. My question was based on some discussions I saw ongoing reading existing authentication frameworks and LiveView and the need to adjust and make it work with LiveView. I must confess I still didn’t dig into this topic but I guess this is something worth to explain in documentation in a way that even a not experienced developer would understand clearly for some standard scenarios.
In fact, simplicity, or better, making things obvious, is one of the greatest advantages of the Elixir Ecosystem!
PS: I code as a hobby and Elixir ecosystem is being one of my best partners during this Corona virus times staying at home. Kudos for that!
darkblueorange
Hello all
I don’t really know where to post this.
Some redirections of
mix phx.gen.authare done via|> redirect(to: "/")In these functions:
As I built a new Elixir app from scratch, my home page is located at
Routes.page_path(conn, :index), which is not always “/”, as I configured my Endpoint with a subpath (using :static_url) to be behind a reverse proxy.So I had to change in all mentioned functions
|> redirect(to: "/")by
|> redirect(to: Routes.page_path(conn, :index))I don’t know if makes sense to scaffold with
Routes.page_path(conn, :index)from the beginning.Awesome work besides that. As the rest of Elixir of course