We've got this document that explains how to set up Keep Me Signed In (KMSI) using Custom Policy: https://learn.microsoft.com/en-us/azure/active-directory-b2c/custom-policy-keep-me-signed-in
OK, great, so we now know how to use (annoyingly complex) XML policy files to set up some UI for a checkbock. But what is this actually doing? Where is the info on this?
- Is it providing the client a new ID Token without re-auth?
- Is it providing a new auth_code?
- Is it using a hidden i-frame?
- How is a refresh actually called/accomplished from the client app? (SPA)
- Is a round-trip to B2C needed and it just doesnt ask the user for creds and redirects them right back to the app? Or is the app able to make a refresh request completely UI/UX silent? If so, how? Where is the API? Is something in MSAL.js needed?
- Why local only? If B2C is the "middle man" IDP, and the tokens it issues are its own (not actually from a social account, of course), then why can't it refresh tokens this way for all account types (local or social)?
My understanding is that, for Implicit Grant, storing Refresh Token was not possible, so keeping a session cookie around and using it to acquire a new session via i-frame with prompt=none
was a HACK to be able to keep a session cookie updated and current.
Here is an article by former MS (now Auth0) identity guru Vittorio: https://auth0.com/blog/oauth2-implicit-grant-and-spa/
He mentions "Renewing Access Tokens" by Refresh Token Rotation. This is described as:
"a feature that invalidates a refresh token and issues a new one whenever it is used to refresh an access token"
This appears to be accomplished by a session cookie and i-frame "hack" (as was used with Implicit Grant), which returns a new authorization code, which (presumably) can be used to get a new Access Token.
Why is this needed when we now have PKCE? Apparently it is still bad to store long-lived Refresh Tokens in the browser, even with PKCE. I found undocumented information that B2C Refresh Tokens for SPA max lifetime is 24 hours (not 90 days, and not configurable).
So are we still doing this session cookie hidden i-frame hack today? Even with PKCE? And is that what B2C KMSI is doing? If so, how is it triggered, and how does my app actually get a new Access Token for use with my API?
Bottom line: I need to keep my users signed and able to access my secured web APIs without re-auth even if they dont open my app again for 100+ days. And ideally this should be accomplished completely silently, no round trip, regardless of whether the account was local or social on the IDP side. Is the B2C KMSI feature the right mechanism for this?