Silent Renew process doesn't always start with a protected route
See original GitHub issueDescribe the bug
When using AutoLoginGuard
globally, rather than manually using CheckAuth
or similar, the silent renew process fails to start until after the user has been reauthenticated at least one time. This leads to the user being redirected to the login page when navigating between secured routes, even after they’ve previously been authenticated.
Once the user has been logged in a second time, the silent renew process usually behaves as intended.
To Reproduce
Steps to reproduce the behavior:
First ensure you have setup AutoLoginGuards
on all routes. Personally, I did something similar to the following:
const appRoutes: Routes = [
{path: '', pathMatch: 'full', redirectTo: 'home'},
{path: 'unauthorized', component: UnauthorizedComponent},
{
path: 'home',
canActivate: [AutoLoginGuard],
loadChildren: () => import('./modules/home/home.module').then(m => m.HomeModule)
}
{path: '**', component: PageNotFoundComponent}, // Wildcard route for a 404 page
];
Also ensure silent renew is setup:
export function configureAuth(oidcConfigService: OidcConfigService) {
return () =>
oidcConfigService.withConfig({
stsServer: environment.identity_url,
redirectUrl: window.location.origin,
postLogoutRedirectUri: window.location.origin,
clientId: environment.client_id,
scope: environment.scope, // must have offline_access scope
responseType: 'code',
silentRenew: true,
useRefreshToken: true,
logLevel: LogLevel.Debug,
});
}
- Open the WebApp
- Clear all site data
- Refresh the page (which should cause the user to be authenticated)
- Open the console and notice silent renew is not running
- Wait for the login to timeout and then navigate to another secured route. This should force another sign in.
- Once the second authentication process has completed, you should be able to open the console and see the silent renew running. If the silent renew process does not start, I’ve had luck with clearing the cache and refreshing multiple times.
Expected behavior The silent renew process should always run as soon as the user has been successfully authenticated (and silent renew is enabled).
Desktop (please complete the following information):
- OS: Windows 10
- Browser: All tested chromium-based browsers (Edge and Chrome)
- Versions: Edge 90.0.818.46, Chrome 91.0.4472.77
Additional context Add any other context about the problem here.
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (2 by maintainers)
We fixed this in V12. We are currently in a testing phase and will release V12 afterwards.
@FabianGosebrink thanks for the fast response 😊 I wasn’t sure if it was related, but I’m glad it will be fixed in v12! 😄