AshAuthentication with non-Postgres Data Layers?

I am writing a small "microservice" which takes a JSON post from an internal system and does a side effect (i.e. validates it, processes it based on if CAD drawings in a directory exist or not, then leaves a custom CSV in a directory being watched by vendor software). I have it working without Ash (just using OpenAPISpex and phx gen.auth api keys) but I need to rewrite it so the release will run as a Windows Service for performance reasons (don't ask!! 😰) and thought this would be a great very easy way to start learning some Ash resources, actions, and json_api at least on a simple easy project! The API and side effect generating stuff works great (simple/embedded data layer) I just need to add api key authentication so I added AshAuthentication. Looking at the code it seems agnostic to the data layer but every example online all assumes AshPostgres and this may be the only way to get it to work. This service is not publicly-accessible and of course HTTPS is used but I still want some sort of key to be checked even if the hash is stored in an env var and read by runtime config then checked. Or in SQLite data layer or a JSON/CSV file or something. I just don't want to add the complexity of adding PGSQL on Windows to this simple deployment.
4 Replies
ZachDaniel
ZachDaniel•3mo ago
What I would say is that it is built to be generic across data layers, but only really tested/vetted on postgres and sqlite and even sqlite I don't think anyone has shipped to prod with that but worst case if you try it you'll find some things that we'll need to fix
yyy66133
yyy66133OP•3mo ago
Yes SQLite should be way easier for me to get working natively on Windows I guess by installing their CLI... although I haven't used Windows since I think 2005 and don't even know how package management works there. I'm going to give it a go and report back. Thanks for your fast help! I think I saw that mise at least partially works on Windows so I should be able to get Erlang/Elixir to work in a VM to be able to bake the release. Anyway yes I will report back and thanks!
barnabasj
barnabasj•3mo ago
wsl2 + dockerdesktop works pretty well on windows. depending on your usecase
yyy66133
yyy66133OP•3mo ago
@barnabasj Thanks for the advice, I had thought about that since I use Docker for pretty much everything. The performance reason that I mentioned has to do with the huge number of CAD files on the specialized Windows box that need searched each request. They have grown to the point that it takes >45 sec/request to enumerate with Path.wildcard over SMB (from my Linux Docker host). When I test similar Rust code running locally it takes about 3 seconds. I would have to profile to be sure but if Windows dockerdesktop is like Mac there is a pretty severe penalty to access the filesystem from the container running in the VM. I hope I have enough time to profile b/c it is an interesting idea and would prefer running in a docker container! Thanks!

Did you find this page helpful?