Shimano
Confused with SolidStart and context provider
I am afraid that I don't quite understand you - as I've said I am a noob.
Would you recommend using sessions rather than context for auth? My idea was that I have a token and some user info stored in storage (I am using cookieStorage from solid-primitives).
User tries to login, the server makes a request to a backend service (a simple REST API with JWT auth). If it succeedes - the creds are valid - a JWT is returned and thus saved into cookies.
Logout is simple - auth cookies are wiped and the user is redirected to the login page.
When an authorized request to the REST API needs to be made, I just get it from the auth provider - if there is a token stored - and call it with that. I haven't thought about token validity expiring midway - meaning the token is valid for the page load but then becomes expired and the call to the backend is made - will work on that later if it comes to it.
I wanted to use SSR for isolating the REST API since even the "public APIs" could be abused and the REST API calling some external services could be abused. This way I have only the frontend server exposed - yes the user can still abuse it somewhat but not the API directly.
I am planning to implement another auth method directly for the API using a special token and I will expose selected endpoints - all of which will be secured by the API token auth.
28 replies
Confused with SolidStart and context provider
Also I cannot find the docs for
redirect
anywhere... 🤔
Only in https://docs.solidjs.com/solid-start/advanced/session but I get that the docs are still beta...28 replies
Confused with SolidStart and context provider
In desperation I've tried to work with sessions - it kinda works too but it won't redirect me using the
throw redirect("/")
. Dunno but I will try it with a provider instead of sessions.
If you have an example how to use it with session, I would appreciate that very much aswell!28 replies