Kabawo

Kabawo

Adding auth to --no-html --no-assets project

Hi. I am new to Elixir and I’m trying to build a REST api as a hobby/ learning project. The recommendation I found in the forums for implementing auth is to go the phx.gen.auth route and amend as necessary to suit REST workflow (I suspect Phoenix.Token would be of help here). Because I generated the project with --no-html --no-assets flags it seems the phx.gen.auth is not available. Can I ask what is the recommended solution in such case? Would I have to add html (I wanted to keep the project lean)? Would I build the auth from scratch using Phoenix.Token (I imagine as a plug)? Or maybe this is too much to implement and properly set up for a beginner? I am not a commercial programmer and I’ve had limited exposure to auth implementations (Python Flask, Flask-RESTful and FastAPI) and following the guides and sample/ toy projects for these technologies adding auth seemed fairly trivial (with the complexity hidden within libraries), so I am quite surprised to hit a bit of a roadblock in Phoenix. Thanks in advance for any help

Marked As Solved

100phlecs

100phlecs

The sooner you get acquainted with Plug and its functions the better off you’ll be, as you’ll see how Phoenix builds on-top of it.

So yes, you would build the Auth from scratch with a Plug using Phoenix.Token.

Here are some guides that I think would be useful as reference.

If you don’t want to roll your own, then guardian may be what you’re interested in using, which can hide some of the implementation details like the previous languages you’ve worked with.

There are other auth libraries to use as well. I can’t vouch for any of them. I’ve not used Guardian before, but looking around the forum Guardian is the one I see come up.

Where Next?

Popular in Questions Top

sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
LegitStack
I’m trying to make a websocket server in Phoenix or raw Elixir. I heard about gun, I think I could use cowboy, but since I’m not that sma...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
lucidguppy
I have a super simple question about elixir - how would I take a file like this foo bar baz and output a new file that enumerates th...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New

Other popular topics Top

chrismccord
As promised, the first release candidate of Phoenix 1.3.0 is out! This release focuses on code generators with improved project structure...
New
JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
vegabook
I’m brand new to Phoenix and I have stripped one of the demo applications to the bone. I just want to get an svg up on the screen. Here i...
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 36128 110
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New
klo
Got a question about when to concat vs. prepending items to list then reversing to achieve appending. So i know lists boil down to [1 | ...
New
komlanvi
Hi everyone, I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 47930 226
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New

We're in Beta

About us Mission Statement