I have a solution for an authentication system without using refresh token. Please tell me where are the vulnerabilities of this method.
I assume the following:
- Client and Server are on the same domain.
- Client is a browser that support HttpOnly cookie.
- Client is using a Single Page Application.
The steps are:
- User login by making a request to
/api/auth
with the credentials. - Server authenticate the user and send back a Set-Cookie Header with an HttpOnly cookie containing a JWT.
- Client receive and set the HttpOnly cookie. Client also set in Local Storage a variable
logged: true
. - After sometime User reopen the browser. The Single Page Application check if the variable
logged
in Local Storage is== true
. If so check if it still has the HttpOnly cookie by making a request to/api/check-cookie
. - Server respond with
true
if it find the HttpOnly cookie and it is valid. Otherwisefalse
. - Client, if receive
false
from/api/check-cookie
, will prompt the user with the login.
With this approach the JWT can have a long expiration date and there is no need to keep track of refresh tokens.
Am I missing something?