-
-
Notifications
You must be signed in to change notification settings - Fork 18
feat(maevsi_stack#90): postgraphile in library mode #1513
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Happy new year and happy for some early feedback. 😄 |
|
Ok, so here we are, it's Hacktober! 🥳 I've looked into this and collected some more experience with setting up OAuth in Nuxt with lucia for a @ninjaneers/nearbuy demo. So, regarding JWTs: in general, I'd like to implement some session logic. Users should be able to log out of sessions started on devices they may not control anymore and admins should be able to lock users out in case of misbehavior. maevsi currently checks JWTs server side exactly for this reason, to be able to quit sessions server-side. It's apparent that this is a wyld combo which likely shouldn't be around for too long any more. By now, https://github.com/Hebilicious/authjs-nuxt is not maintained anymore. AuthJs has a native Nuxt integration coming, but I don't really see their seemingly preset database schema fit the existing schema for maevsi. Also it isn't merged yet, atinux/nuxt-auth-utils is a little too custom still for production, not too many eyes verifying security on it, I think. So, just by an incremental addition without a major rewrite, even being able to keep postgraphile as-is, the following should be working:
This should be fairly straight-forward. Sounds good? Am I missing something? Let's talk about it in this Hacktober 😁 |
db8592b to
95ec293
Compare
📚 Description
This PR introduces postgraphile in library mode together with revisited authentication logic. Both concepts are closely coupled.
contains #1512
🦾 ToDos short
👀 what's working?
💬 Discussion
I'd have liked to keep it a bit smaller.
about postgraphile
v4.18 requires grapql 15 or below, while other project dependencies already require graphql 16. Therefore, i decided to give postgraphile 5 a shot. Note that it comes with quite some differences and is only beta at the moment. The ruru graphiql is cool though. 😄
about auth library
I decided to go forward with authjs-nuxt, since lucia is quite low level. Also, lucia dropped jwt support completely and I disagree a bit with their reasoning.
Reg. authjs & authjs-nuxt: Damn, this is all so work in progress. But I guess you're used to it (nuxt3 migration 👀). At least, it brings support for what we want (credentials, maigc link, oauth), although the user model and api around it feels kind of dirty.
about frontend only development
We need to figure out what this means for (frontend only?) development. A bundled postgraphile library and authentication means that you can't connect so easily from local to production maevsi anymore, because we don't want to expose the actual database.
Also, oauth2 requires secrets that we also don't want to expose.
I think, we could create a setup where the graphql endpoint and the auth endpoints are proxied to the actual production maevsi and only other routes are handled locally. Together with a stateless jwt session this should solve our issues (for now?), unless our local backend starts to require secrets that are not to be exposed in an unencrypted jwt. I doubt that tbh.
And if we see issues with that approach, we could still introduce a dedicated api backend on top of postgraphile.
about jwt storage
Just a side note. I'm actually a bit confused why jwt tokens are stored in database. Isn't the purpose of them to work stateless without db lookups? Doesn't really matter to the PR, but i was wondering 🤔 If you think that's worth a discussion, let's make a issue for it
📝 Checklist
Example github config for reference