-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose refresh token in MSAL #5137
Comments
@mpbiehn We intentionally do not expose the refresh token on our API surface, and are not likely to change that stance as we are actively working on features which would further protect the refresh token by not returning it to MSAL.js at all. Can you please go into more detail about why biometric login in Cordova requires an RT? |
@tnorling sure, today we aren't using MSAL (msal-react) but would like to soon as part of our Singe Page Application. At a high level, here's what our biometric login flow looks like:
Here's another article that might explain it better - https://developer.okta.com/docs/guides/unlock-mobile-app-with-biometrics/android/main/. I'm open to other options on how to handle biometric login, just haven't found a better option yet. If MSAL doesn't return the refresh token at all in the future, how will MSAL handle refreshing the access token? Doesn't the current version of MSAL use the refresh token (in the background) to do this? |
There's potentially a bigger issue here than just returning refresh tokens. We do not currently support custom storage solutions (i.e. SecureStorage), which means, if I'm understanding your scenario correctly, you would be storing tokens in SecureStorage in addition to the storage used by MSAL.js (local or session storage). If that's the case, I'm not sure I see the value in using SecureStorage at all until we do support custom storage (we do have an item in the backlog to look into this). Furthermore, it sounds like the biometric sign-in doesn't actually require that it return a refresh token but rather just unlocks access to SecureStorage. Do I understand that correctly? If so, once MSAL.js supports custom storage the pattern I would suggest is to unlock SecureStorage and then use the MSAL APIs to acquire an access token - letting MSAL.js reach into SecureStorage and retrieve what it needs. I don't see a reason why your application would need to be aware of the implementation details of acquiring access tokens (getting a refresh token and calling the /token endpoint with it), that is after all what an authentication library like MSAL.js is designed to abstract away from you. |
@tnorling thanks for the quick response. I'm a big fan of MSAL abstracting authentication, big reason why we'd like to use it within our app. :) You are correct in that biometric sign-in unlocks access to SecureStorage. Today, we aren't using MSAL so we are storing the refresh token in SecureStorage. Was thinking of following a similar pattern (not knowing any better) with MSAL but doesn't sounds like that is possible (no refresh token available) in the current version. To be sure I understand your suggested pattern, are you saying once MSAL.js supports custom storage, we would leverage the custom storage vs local or session storage? And we'd leverage MSAL APIs (getting what it needs from the custom storage) to acquire an access token? Any ETA on the backlog item for custom storage or somehow I could follow the progress on this backlog item? Also, any thoughts on how to handle biometric login with MSAL until custom storage is available? This might hold us up from using MSAL. :( |
You can track progress on custom storage in issue #1588, I unfortunately don't know right now when it will be prioritized.
That's correct. We haven't really sat down to design the feature yet but I imagine we would expose some sort of cache interface for you to provide implementations of cache getters and setters, which MSAL.js would then use instead of localStorage and sessionStorage for all cache operations.
I wish I could give you a better answer but unfortunately we don't have any explicit support for Cordova or any other hybrid frameworks at the moment. So while you could try to come up with some sort of workaround in the meantime, it would likely require doing some things we wouldn't endorse and we would not be able to offer much help if you run into issues :/ |
@tnorling thank you for your quick responses, much appreciated! |
Core Library
MSAL.js v2 (@azure/msal-browser)
Wrapper Library
MSAL React (@azure/msal-react)
Public or Confidential Client?
Public
Description
After trying to figure out how to get access to the refresh token in msal-react I came across a few issues and documentation that the refresh token isn't exposed. One consideration for exposing the refresh token is using it to provide a biometric login option within our Cordova Hybrid app. Today we store the refresh token on the device (encrypting it with a biometric challenge) as part of our biometric login flow. Sure would love to have access to the refresh token, unless there's another way to solve this problem that I'm not aware of.
Source
External (Customer)
The text was updated successfully, but these errors were encountered: