🔐 Fix Admin Portal token refresh via offline_access#1551
Merged
vladislav-kir merged 5 commits intomainfrom Apr 8, 2026
Merged
Conversation
Root cause: the OIDC login was never requesting openid/profile/offline_access, so SSW.Identity never issued a refresh token and the Blazor WASM auth stack had to fall back to hidden-iframe silent renew — which fails on an unattended kiosk (third-party cookies, no user interaction) and bounces the user to login. Now that SSW.IdentityServer#348 adds offline_access to the AdminPortal client's allowed scopes, we can request it here and let the platform's built-in AuthorizationMessageHandler do its job. No custom retry logic needed — oidc-client-ts handles silent refresh-token renewal transparently. - Add openid/profile/offline_access to Local:Scopes (appsettings + staging) - Delete RetryAuthorizationMessageHandler (120 lines) — its "force refresh" path was a no-op because IAccessTokenProvider.RequestAccessToken() doesn't force-refresh in Blazor WASM; it just returns the cached token - Restore CustomAuthorizationMessageHandler and narrow its request scopes to just ssw-rewards-api (the only scope the API needs on outbound calls) Net: -117 lines. Closes #1522
Fresh-login test that intercepts /connect/token and asserts refresh_token is present in the response body. Provides end-to-end verification of the #1522 fix once AdminUI is running locally against staging identity.
Extends the verification test to POST the captured refresh_token back to /connect/token with grant_type=refresh_token — directly exercising the same exchange that oidc-client-ts performs when the access token nears expiry. Proves the full refresh flow works server-side without waiting.
vladislav-kir
approved these changes
Apr 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1522
Why
The Admin Portal kiosk leaderboard loses its session after the access token expires. Root cause: the OIDC login was never requesting
openid/profile/offline_access, so SSW.Identity never issued a refresh token and the Blazor WASM auth stack had to fall back to hidden-iframe silent renew — which fails on an unattended kiosk (third-party cookies, no user interaction) and bounces the user to login.What
Let the platform do its job.
oidc-client-ts(used under the hood by Blazor WASM'sAuthorizationMessageHandler) already handles silent refresh-token renewal transparently — it just needs a refresh token to work with.openid/profile/offline_accesstoLocal:Scopes(appsettings.json+appsettings.staging.json)RetryAuthorizationMessageHandler(120 lines). Its "force refresh on 401 and retry" path was a no-op anyway:IAccessTokenProvider.RequestAccessToken()doesn't force-refresh in Blazor WASM — it just returns the cached token, thenewToken.Value != token.Valueguard never passes, and it falls through to throw → login redirect. So none of those lines were actually fixing refreshCustomAuthorizationMessageHandler(thin 15-line subclass of the platform'sAuthorizationMessageHandler) and narrow its outbound scopes to justssw-rewards-apiNet: -117 lines.
SSW.IdentityServer must be deployed to production before this PR merges.
This PR depends on SSWConsulting/SSW.IdentityServer#348 (merged), which adds
offline_accessto thessw-rewards-admin-portalclient'sAllowedScopes. Until that change ships to prod, requestingoffline_accessfrom the client will be denied and no refresh token will be issued — meaning the prod Admin Portal would regress to its current broken-refresh behaviour.Order:
/connect/tokenissuesrefresh_token, grant exchange worksVerification
Layered verification pyramid
POST /connect/tokengrant exchange works — returns freshaccess_token+id_token(committed Playwright testrefresh-token.verify.spec.ts)kiosk-overnight.long.spec.ts)7h soak test results — 14/14 checkpoints passing
Every 30 minutes, the test:
/api/Leaderboard/GetMobilePaginatedcalls, asserts all 2xx/connect/tokenrefresh-token grants (silent renewals)performance.memory.usedJSHeapSizeWhat this proves
Last refreshedis 1–2 seconds old at every checkpoint — the 60s timer has fired ~2,950 times without a stutterBefore this fix: kiosk broke after ~1 hour (the first access_token expiry).
After this fix: 2,958 consecutive successful refreshes across 7 hours.
This is conference-ready.
Test plan
/connect/tokenresponse includesrefresh_tokenrefresh_tokengrant exchange returns freshaccess_token(verified via Playwright POST)