keycloak-angular icon indicating copy to clipboard operation
keycloak-angular copied to clipboard

Configurable minValidity for addTokenToHeader/getToken

Open sharebear opened this issue 4 years ago • 2 comments

Bug Report or Feature Request (mark with an x)

- [ ] bug report -> please search for issues before submitting
- [x] feature request

Desired functionality.

In my application we have the following structure

AngularFrontend --> OrchestrationMicroservice --> BackendMicroservice

The orchestration service propagates the JWT that comes in from angular to the backend service for authentication. One part of this orchestration ends up in N+1 calls to the backend and "often" takes over 5-10 seconds for clients with lots of data. When this happens, if the token was close to expiring at the start of the call to the orchestration service, calls to the backend start failing with "Token is not active" error messages.

Looking through the code while updateToken has a parameterisable minValidity, getToken (called by addTokenToHeader) hardcodes the minValidity to 10 seconds.

I would like some kind of configuration (probably an initOption) to allow me to configure which minValidity is passed to updateToken when used from addTokenToHeader, this would allow me to bump the minimum validity to 20 or 30 seconds and avoid these intermittent failures that currently happen at random for the end users.

sharebear avatar Jan 15 '20 11:01 sharebear

I'm well aware that re-architecting the application to avoid the N+1 lookup and therefore the long requests would be a "better" solution, but there's no budget for that scale of rewrite compared to making use of a parameter that already exists, just a little hidden.

sharebear avatar Jan 15 '20 11:01 sharebear

I am a proponent of this feature, it makes sense that we streamline this across the library. It might be that in the next version the KeycloakService will go away, but we are not sure about that yet so I am adding this to the v9 milestone.

jonkoops avatar Jul 22 '20 14:07 jonkoops