feat(auth): add functions to help with removal of esri_auth cookie #774
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.
In an upcoming release, the
esri_auth
clear-text cookie will be removed in favor of an encryptedesri_aopc
cookie that client's can not read.To get a token from the
esri_aopc
cookie, the app needs to call/oauth2/platformSelf
, passing in the client_id and redirect_uri of the app for which they want an app-specific token to be issued.This is exposed as
platformSelf(clientId, redirectUri, portal?) -> {username: "jsmith", token: "aj8csja..."}
If the app has a token from another app (i.e. it is passed auth information via "postMessage") then the app can exchange that token for a token that is specific to the app.
For example - a Dashboard that is iframed into a Hub Site may get passed an
ICredential
viapostMessage
, but that credential contains a token for the Hub application.To exchange that for a token that's specific to the Dashboard app, it can use the
/oauth2/exchangeToken
end-point, which is wrapped in to REST-JS asexchangeToken(currentToken, clientId, portal) -> {token: "ashda898ds..."}
Finally, to streamline checking if the current user has access to the app, and if the app should present a "Viewer" UX, there is the
/oauth2/validateAppAccess
end point, which is wrapped asvalidateAppAccess(token, clientId) -> {valid: true, viewOnlyUserTypeApp: false}
This is also exposed in the
UserSession
object assession.validateAppAccess(clientId) -> {valid: true, viewOnlyUserTypeApp:false}
These functions are all specifically for Esri "Platform" applications hosted on *.arcgis.com or within an Enterprise Portal. Other apps will receive errors calling these functions.