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

Example is insecure by default #16

Closed
Clee681 opened this issue Dec 6, 2020 · 2 comments
Closed

Example is insecure by default #16

Clee681 opened this issue Dec 6, 2020 · 2 comments

Comments

@Clee681
Copy link

Clee681 commented Dec 6, 2020

Hello,

IIUC, the server will accept any JWT.

const profile = token ? jwt.decode(token) : false;
// omitted code
authenticated: !!profile

If so, this is a big security vulnerability in what seems to be one of the most widely cited examples of implementing auth for Sapper applications. I think we should update the example to use jwt.verify.

@sylvain-reynaud
Copy link

The token isn't verified on backend in his code.
I guess you should use jwt.verify in the backend to avoid spreading the access token secret on 2 different servers. In this way using jwt.decode on the server-side is ok.

@antony
Copy link
Owner

antony commented Feb 6, 2021

Yes - as you've noticed this is a vastly simplified example. I'm not here to teach JWT best practices, we could go into all sorts of detail about how to verify authenticity, expire, renew, etc!

It's important to keep things as simple as possible so that the code is easy to understand. Decoding an entire JWT to set an authenticated boolean is also not particularly useful :)

If you're using JWT in your app - it's essential to understand what a JWT is and how it works, but that's out of scope for this example :)

@antony antony closed this as completed Feb 6, 2021
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