dimitarvp
Hey everybody! ![]()
I am looking for the auth framework that can help me with a project, given these specifics:
- There are no public sections or pages. Non-authenticated users can only land on the home page and they cannot go anywhere else before signing in.
- You cannot just sign up. An admin has to invite you first and you get a link in your email inbox that allows you to then sign up. The classic sign up model is either out of the question, or as a compromise it can be implemented only if the new account has to be approved by an admin before being able to sign in.
- As per above: there should be admins and users and admins can approve user accounts.
- The framework should allow for more roles than admin and user in the future – but I am guessing I have to study how can an authorization library work with the chosen framework or homegrown solution instead.
- The framework should in general be extensible in a non-bloated way, meaning if I want to customize something it does I shouldn’t have to copy several files 200+ lines long and then apply 3-line diffs to them. I know this is a very tough thing to do, it’s just that I would gladly take it if it was out there.
I looked at both Coherence and Pow. Also entertained the idea of Guardian with my own code on top.
Notes about Coherence:
- Coherence seems to carry a lot of file baggage with it and integrates very tightly with
myapp_webwhich I don’t like and I don’t have the time to untangle properly into a separateauthapp inside an umbrella. I definitely could do it in theory but I have no guarantee that it’s only an 1-2 hour job which is scaring me and thus I haven’t tried that yet. - I suffered a problem with it caching the user model so aggressively that a linked
belongs_toobject was never really invalidated and reloaded and was thus showing wrong data on the pages. I was forced to instruct Coherence to copy its controllers inside the project and to then overwrite how they load the user model. Result: no caching at all, every page incurs a reload of the user itself and its linked object. Basically defeated the really neat idea that the Coherence author had.
This is definitely my bad and not of Coherence! But in the 10 minutes I tried to find a solution, I failed. - It does indeed support invitations but I admit I haven’t tried to disable normal sign up and gate it behind an invitation only. So I am not sure if my desired use-case is supported out of the box, if it’s possible with a small effort, or would be a hassle to achieve (but still possible).
/CC @smpallen99, the author of Coherence.
Notes about Pow:
- A bit smaller than Coherence but basically has the same problem of file baggage and no umbrella-friendly installer (namely no option to generate an entirely separate app inside an umbrella). I really don’t know why library/framework authors don’t make this a first-class citizen in their mix tasks, it would be very highly appreciated!
- Didn’t seem to capture my use case about being able to invite users and not allow them to sign in before approved by an admin. I liked the author’s response when I asked him – what he proposed sounded easy enough – it’s just that in a startup scenario you really cannot get distracted with customizing frameworks when you are building an MVP. You either have to use ready-baked solutions or know exactly what you are doing when customizing (and thus still do it very quickly). Every hour counts in these conditions.
/CC @danschultzer, the author of Pow.
Admittedly I am not an expert in both of these and sadly the time is really not right for me to indulge in weeks-long toy projects to inform myself properly.
Finally, I looked into Guardian because I used it before. It’s really easy and minimastlic to start with and is currently the decision I lean to (in combination with comeonin and my own DB model for invitations). Not really sure if it wouldn’t quickly get harder than Coherence and Pow though.
Don’t get me wrong. I am not lazy. I am open to devote to one framework and then become an expert – subsequently it’s likely I would be contributing to it as well. But right now I am really pressed with time and I am looking for a practical advice before pulling the trigger.
Any advice and battle stories are appreciated. Thanks for your consideration! ![]()
Trending in Questions
Other Trending Topics
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 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
danschultzer
Just a sidenote: Pow installer can be used easily in umbrella setups. You have to run
mix pow.ecto.install -r MyApp.Repoin your ecto app andmix pow.phoenix.install -r MyApp.Repoin your phoenix app.It’s impossible to know what kind of umbrella setup a project is, so this can’t be done automatically. However I think it would be useful to show a notice about how to do this when running
pow.installin the umbrella app root.I almost exclusively work with umbrella apps myself
dimitarvp
Great tidbits! I will try those.
As for an installer, I would think something like
mix pow.install --umbrella --new_app pow_authcould be enough? I don’t mean that your installer has to parse the structure of the umbrella app, no – I mean that with some more CLI options as you showed above, the Pow installer can just create an entirely separate app inside the umbrella that’s exclusively used for authentication with Pow?Sorry if I am misunderstanding.
EDIT: I keep forgetting that eventually you do have to edit your web app’s
router.exfile though.danschultzer
Unfortunately that would require that Pow also creates a Phoenix app which is outside the scope of the Pow mix tasks. Most of the time you would want to have you sign in and registration views the same place as your default Phoenix app.
dimitarvp
I understand. But as an unfortunate side effect any auth library one picks up becomes a strongly entrenched dependency inside your web app’s files which you cannot easily replace if something else is serving you better down the line.
danschultzer
True. It’s been something I’ve experienced with other authentication libraries for Elixir/Phoenix, so I’ve tried to make a very transparent API for Pow that makes it easier to replace if something fits better down the line. The goal has been to have as few files as possible generated or modified, and make any developer understand how Pow works by taking it step by step to e.g. enable extensions, or modify templates.
With umbrella apps it’s possible to limit this, but you’ll have to work with multiple Phoenix apps, endpoints, cross check sessions, etc, and at that point a detached authentication server may make more sense.
MrDoops
Outside of Pow and Guardian, the other authentication library/framework I’ve liked in this space is Phauxth. There’s been some recent updates, and the code is easy to read and well documented, so at least worth reading through if you’re planning on spinning your own authentication solution.
I’ve got a greenfield application scoped out that will need similar admin-invite capabilities, so I’m interested to see what solution you work out.
nsweeting
If you’re willing to accept a token-based approach, I created Authex. It has support for authentication + authorization, is pretty minimal in its approach, and is umbrella friendly. It may work depending on your needs.
https://github.com/nsweeting/authex
smpallen99
I’m really interested in what you don’t like? Are you not using the standard web structure?
Yes that is the downside of caching the user data. I’ve never come across the issue of a stale belongs_to, but completely understand the issue. The choices are either fetch the preloaded user schema on each request, or calling the API to update the cache.
BTW, if you want to fetch the user on each request, you could to that with a plug pretty easy. No changes to Coherence.
and then put that plug after the coherence plugs in each of your pipelines
Yes it is. Just don’t install the registerable option. This way, new accounts are either created somewhere in your app, or by sending them an invitation.
BTW, I have just overhauled custom controllers. The generated controllers are now < 10 lines long, with all the supporting actions and helpers overridable.
Thanks for sharing your experience with Coherence.
dimitarvp
Apologies to everyone for the silence, I will respond properly when I get some free time somewhere in the next 24h.
jordiee
https://github.com/AppDoctorIo/accesspass
My library should be able to cover all your use cases as it offers a vast amount of customization via a behavior. There are still some github issues I want to get to in the future that would make it an even better fit but it absolutely can do everything your looking for now in a fairly easy way. I should note that it is for api authentication and would still need a ui built around it. I made it for my project https://appdoctor.io . I currently only allow new accounts with a provided beta code. You can do much the same thing via your email strategy mentioned.
Here is a post I did a while back going into more detail on why I made it:
https://medium.com/appdoctor/accesspass-yet-another-elixir-authentication-library-7ea59734a49
and any pull requests/contribution is VERY welcome!
A big plus at least for me is ease of use in a new project. It provides a drop in plug and macro to handle everything in 3 lines of code for auth.
Also mind you this solution was originally not made to be open sourced so a lot of the current github issues deal with braking away from what I had as original defaults.