Skip to content
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

VITE_SESSION_SECRET #24

Closed
binajmen opened this issue Dec 19, 2022 · 6 comments
Closed

VITE_SESSION_SECRET #24

binajmen opened this issue Dec 19, 2022 · 6 comments

Comments

@binajmen
Copy link
Contributor

Thank you for this great utility!

In utils/auth.ts, you use:

secrets: [clientEnv.VITE_SESSION_SECRET],

According to the security notes in https://vitejs.dev/guide/env-and-mode.html#env-files:

Since any variables exposed to your Vite source code will end up in your client bundle, VITE_* variables should not contain any sensitive information.

Isn't it concerning or did I misunderstand something?

@OrJDev
Copy link
Owner

OrJDev commented Dec 19, 2022

I also think that it should not be prefixed with vite, but solid docs do prefix it (making it public to the client) so I'm not sure which is the correct answer?

@binajmen
Copy link
Contributor Author

Yes I noticed the same in the Solid documentation. I think this is wrong and could (do?) leak the session secret. I'll move this to serverEnv and see how it goes.

@OrJDev
Copy link
Owner

OrJDev commented Dec 19, 2022

Yes I noticed the same in the Solid documentation. I think this is wrong and could (do?) leak the session secret. I'll move this to serverEnv and see how it goes.

Make sure you separate the auth client and the session storage otherwise the client will try to parse server env variables (causing an error to be thrown on the browser), move the session storage to server/auth.ts if you do decide to do that

@binajmen
Copy link
Contributor Author

It works well, thanks for the above tip 😉 – I was not aware everything under /server is not bundled to the client!

I'm pretty sure this should be the default. I don't have time right now to "hack" myself and see how I could retrieve the session secret. Although, based on Vite documentation, the session secret is (most probably) leaked with the current setup.

@OrJDev
Copy link
Owner

OrJDev commented Dec 19, 2022

Ye i think so too,
feel free to make a pr with the above tip or I will do so tomorrow

@tanjunior
Copy link

maybe include https://github.com/t3-oss/t3-env as part of the addon?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants