SolidJSS
SolidJS2y ago
49 replies
midnight

JWT to Cookie

I am getting pretty confused on when to use something like @solid-primitives/storage versus vinxi/http to set cookies or if I should use a middleware similar to how sveltekit implements middlewares for locals.

example I am working through is authenticating my user. I have the standard OIDC flow. user clicks the 'login with google' button and is sent to auth.mydomain.com/auth/google/authorize which generates the url sends them to google to signin. The user signs in with google and is send back to auth.mydomain.com/callback/google which validates them in my DB and generates a JWT and sends them back to the location.origin with the url containing the access_token. (example: localhost:3000/#eyJhbG....

I want to take that jwt access_token and set it as the Authorization: Bearer $AUTH_TOKEN and remove the hashed value from the url?

What is the best practice for working with this flow in solidstart? I tried using the useSession but it requires a password and I dont nececarily need the encryption since I have a helper server side called useSession that validates the cookie and if anything is wrong, deletes the cookie and returns an error
Was this page helpful?