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

Once expired code will not reach refreshTokens #14

Open
dunatron opened this issue Dec 12, 2019 · 7 comments
Open

Once expired code will not reach refreshTokens #14

dunatron opened this issue Dec 12, 2019 · 7 comments

Comments

@dunatron
Copy link

on L 33 of index.js you have logic like this
if (!token) {
return next();
}

If the token were to expire in the client, the client will not send it along with the request meaning there is no token and refreshTokens would never be hit?

@dunatron
Copy link
Author

If a cookie has expired, the browser does not send that particular cookie to the server with the page request; instead, the expired cookie is deleted.
https://superuser.com/questions/356265/what-do-browsers-do-with-expired-cookies

@benawad
Copy link
Owner

benawad commented Dec 12, 2019

which branch?

@dunatron
Copy link
Author

@dunatron
Copy link
Author

sorry here
https://github.com/benawad/graphql-express-template/blob/23_cookies/index.js
try setting the cookie age for like 2 minutes
e.g.

const JWT_TOKEN_MAX_AGE = 1000 * 60 * 2; // 2 minutes
module.exports.JWT_TOKEN_MAX_AGE = JWT_TOKEN_MAX_AGE;

@dunatron
Copy link
Author

I have tested the logic in my own branch, and once the token expires its not sent. I believe this is different from browser to browser.
https://github.com/dunatron/Re_Houser/blob/apollo-3.0/server/src/index.js

perhaps this needs re-thought?

@benawad
Copy link
Owner

benawad commented Dec 12, 2019

I set the expiration to the same as the refresh token, so I think it should work in that case.

But I think it's better to rework the logic to check if the refresh token is there even if the token is not.

@dunatron
Copy link
Author

I think the issue would still remain the same and once expired it too can potentially no longer be sent. I guess there is not too much you can do under those circumstances, no token, then re-auth. Your logic is actually fine as long as the browser/client does not delete the cookie once expired

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