danschultzer

danschultzer

Pow Core Team

Pow - Robust, modular, extendable user authentication and management system

None of the current solutions worked well for me, so I went ahead and built a user management system from scratch.

This project took far longer than I initially thought, and I would love to get some help to iron out everything. So please try it out and let me know what you think!

https://github.com/danschultzer/pow
https://hexdocs.pm/pow/

The latest release is a pre release version, but it is running in a production environment (we went away from a Coherence setup).

So what does Pow do (differently)?

Functional configuration

A huge issue with most libraries is the dependency on a global environment configuration. It becomes especially messy when dealing with umbrella apps. Pow handles configuration by passing it as an argument to all method calls (and with plug it’s passed in a private key). There’s also fallback to app-specific environment configuration by using :otp_app like Ecto/Phoenix.

Plug n’ play

Pow exposes only necessary files. It means that even views and templates for Phoenix aren’t generated unless required for customization.

Modular

Pow has been build with clear separation between Ecto, Plug, and Phoenix modules, so if/when deep customization is necessary, you can pull out any part and work with it.

Extendable

Out of the box, Pow does basic user and session management. But Pow has been made to be easy to extend. A reset password, email confirmation and remember me extension ships with it! Extensions are built as a separate system to keep the core of Pow lean and easy to understand.

Security

When working with user authentication, there can be many pitfalls. That’s why your user authentication library should do as much of the work as possible, so you don’t have to think about it. Pow is built with care for recommended best practice, and detailed in the readme.

Transparent

Pow attempts to give the developer full control and understanding of the API for Pow. For example, when you install pow, you’ll have to enable extension support yourself, so you understand the working parts. This it to remove as much “magic” as possible.

And a whole lot more

First 10 of 241 Posts Switch mode

collegeimprovements

collegeimprovements

This looks very very promising.

How does it compare with Established Auth-Servers like KeyCloak or identity-server ?

We are also looking to create an Auth app but couldn’t find anything that can provide OAuth, JWT, QR-Code, Magic Login etc. KeyCloak is not the ultimate solution but it’s good. It would be great if we can have something like that in Elixir-Land. And by far this project along with your phoenix_oauth2_provider seems the closet to it.

danschultzer

danschultzer OP

Pow Core Team

That’s great! I’ve never used KeyCloak or identity-server so I can’t say how Pow compares with them.

However, Pow is built to be very flexible upon the basic user authentication and session handling setup it provides. PowAssent gives multi-provider support (OAuth, et al). You can use Guardian with Pow for JWT. Magic/QR code login could be easily supported with an extension. My philosophy with Pow is to provide a solid and flexible foundation that you could build your app upon, and when needed, you can extract and modify any parts of Pow and add in whatever you need (e.g. maybe you only want to have magic login for your app, or you would like to add two factor authentication).

I got three extensions built into Pow that shows how Pow can be modified: pow/lib/extensions at main · pow-auth/pow · GitHub

If you got any ideas or suggestions for how Pow can improved, please let me know!

collegeimprovements

collegeimprovements

Thanks a lot for amazing work @danschultzer.
It would be really sweet to see an app/tutorial with ex_oauth2_provider + pow + pow_assent.

brightball

brightball

Given the volume of provider options with Ueberauth, how difficult would it be to utilize the existing options with Pow Assent?

I like what I see and I’m going to test out Pow, but in my opinion where Coherence and Ueberauth both suffer is the lack of combining the two. If Pow can be made to work with the Ueberauth strategies then I think there is a strong chance for it to become “the” main auth library for Elixir/Phoenix.

leifericf

leifericf

Seconded! Was thinking the same thing.

danschultzer

danschultzer OP

Pow Core Team

That would be really cool, and after some brief testing, it’s definitely doable to use ueberauth strategies with PowAssent. However I think you will be much better off just using PowAssent strategies exclusively.

Ueberauth would break separation of app configuration built into Pow. Also, PowAssent takes a different approach than Ueberauth, and pushes for removing as much logic as possible from the individual strategies themselves.

The vast majority of strategies in Ueberauth are using the OAuth 1.0 or 2.0 protocol, and it would be much easier (and less code) to build the strategy module than integrating them.

brightball

brightball

Just took the basic setup from the Readme for a test drive and it worked like a charm.

When I got to the extension portion of the setup it gets easy to get sidetracked configuring Swoosh (swoosh, phoenix_swoosh, gen_smtp…the assorted configuration, etc). Personally, I would suggest moving that to a wiki page and simplify the mailer example in the README to the function call printing to the log.

From there, users who are getting setup will be able to see that the extensions work and how they work while knowing that they can plug the parts into any email system they want. Along those lines, it would be beneficial to demonstrate accessing the data parts like the confirmation url or reset link.

If you’re using an external transactional email system where the templates themselves live with the providers (like SendWithUs or systems that exist with the providers themselves or just sending the parts to a queue) that example would be beneficial.

So short version: Don’t tie the onboarding experience of Pow to Swoosh.

danschultzer

danschultzer OP

Pow Core Team

Thanks, I’ve just updated the docs with a simple mailer that only outputs the mail, and it’s much better!

brightball

brightball

Great!

Stepping through it from there, if I follow this part of the docs now it doesn’t actually generate the files.

Now generate the view and template files:

mix pow.extension.phoenix.mailer.gen.templates

This will generate view files in WEB_PATH/views/mailer/ , and html and text templates in WEB_PATH/templates/mailer directory.

It’s also not really clear where this belongs:

Add web_mailer_module: MyAppWeb to the configuration, and you’re set!

It works fine without those though. Leftover documentation?

danschultzer

danschultzer OP

Pow Core Team

I didn’t write that clearly, but that’s fixed now: GitHub - pow-auth/pow: Robust, modular, and extendable user authentication system · GitHub

TLDR: The configuration is the config :my_app, :pow environment, and you need to add the extensions as arguments to generate email templates in the mix task.

I’ll see if it make sense to rework the mix tasks so it can just pick up the extensions configuration variable instead of you having to explicitly state what extensions you want to generate views/templates for.

Where Next?

Trending in Announcing Top

bluzky
You may know https://ui.shadcn.com/, a UI component library for React. I really love it’s design style and components. I’ve built some co...
387 14960 120
New
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
shahryarjb
The Chelekom project is a library of Phoenix and LiveView components generated via Mix tasks to fit developer needs seamlessly. One of i...
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
Damirados
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
ausimian
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
wintermeyer
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

Other Trending Topics Top

type1fool
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
akoutmos
@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
juhalehtonen
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
bjorng
We want to introduce a new native datatype to Erlang: native records. Although replacing all tuple records with native records is not our...
New
spammy
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
alexslade
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

We're in Beta

About us Mission Statement