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

Hi, why use jwt.decode, not jwt.verify #5

Closed
jet10000 opened this issue May 7, 2020 · 7 comments
Closed

Hi, why use jwt.decode, not jwt.verify #5

jet10000 opened this issue May 7, 2020 · 7 comments

Comments

@jet10000
Copy link

jet10000 commented May 7, 2020

polka()
	.use(
		compression({ threshold: 0 }),
    sirv('static', { dev }),
    cookieParser(),
    (req, res, next) => {
      const token = req.cookies['my-jwt']
      const profile = token ? jwt.decode(token) : false

https://github.com/antony/sapper-authentication-demo/blob/master/src/server.js

Is this safe? The client can construct jwt that can be decoded.

@antony
Copy link
Owner

antony commented May 7, 2020

@jet10000 You should watch the talk. There are no secrets in the Sapper part of the application, because it doesn't do anything secure.

Security and authenticity of tokens is all done on the server side, where secrets are safe.

@antony antony closed this as completed May 7, 2020
@jet10000
Copy link
Author

jet10000 commented May 8, 2020

That mean sapper just share session info between sapper pages and components? all requests api sever need sapper send jwt to api server, and api server self verify jwt and decode jwt info, is that right?

@antony
Copy link
Owner

antony commented May 8, 2020

Your browser sends cookies to the api, the api checks authenticity. Watch the talk :)

@jet10000
Copy link
Author

jet10000 commented May 8, 2020

Sapper official example show blog posts that a json data file , if the posts from api server, so this request by sapper.

Browser(with cookie) -> sapper -> api sever

@antony
Copy link
Owner

antony commented May 8, 2020 via email

@jet10000
Copy link
Author

jet10000 commented May 8, 2020

The only place that can't see the cookie is the Sapper clientside app.

I am a little confused, can you give an example?

@antony
Copy link
Owner

antony commented May 8, 2020 via email

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

2 participants