Hi everyone,
I’ve been following the blog posts and quickstart guides for building an Angular SPA with a NestJS backend, and everything is working great so far. However, I have a few concerns regarding security and would appreciate some guidance:
How can I ensure that the JWT access_token
is coming from the intended browser and hasn’t been stolen?
In the past, I relied on HTTP-only cookies for this purpose. When a user logged in, I generated and signed the token on my backend, then stored a random string as an HTTP-only cookie associated with the token in cache. Every time the user sent a request with the JWT access_token
, I validated both the token and the cookie in the cache to ensure they matched before allowing access.
Now, I see that the Angular SDK’s HttpInterceptor
automatically appends the access_token
to requests. Is there a way to hook into the login process or modify the behavior to reintroduce a similar cookie-based validation system?
Do I need to intercept the login response from the authorization server on my backend, create the HTTP-only cookie there, and then redirect the user back to the Angular SPA?
Or is there a newer, recommended approach to ensure the token is being used securely and from the intended browser?
Thanks in advance for your help!