Conversation
ForgeRock iOS SDK 4.4.1 Release
Fixed privacy manifest file in the SDK's modules
ForgeRock iOS SDK 4.5.0 Release
ForgeRock iOS SDK 4.6.0 Release
Similar to android SDK 's Config.getInstance().getTokenManager() to get token manager instance
Similar to Android SDK's TokenManger.clear() method
Similar to Android SDK's TokenManger.persist(AccessToken) method
|
Hi @yuxiang-midships thanks for raising this PR. Can you please provide more information on the use cases you want to cover by making the Token manager and the "persist token method" public? |
|
Hi George, Thank you for taking a look at this. We are using FRSession instead of FRuser to have more control over different authentication tree through out the mobile apple CIAM journeys. At the same time, we have Oauth2 flows that will need to be supported. For the android SDK, we can get around and achieve the logic we want as we can access: Config.getInstance().getSessionManager().getTokenManager() which allow us to access on android the tokenManager. We can then use the exchangeToken, clear and persist method in the token manager class to achieve using FR session for invoking AM trees and then use the tokenID to do oauth2 flows. However when it come to the iOS SDK, we are not able to access the token manager and use the equivalent method. Therefore we modified the iOS SDK as illustrated in the commits to allow iOS sdk to have the same feature as the android SDK We make the token manager and the ouath2 client in the token manager public. and we also make the clearCredential method in token manager public. Lastly we added the persist method to the token manager. |
|
Hi there, Thanks for your reply. I will be actively reviewing this on the current Sprint. I am assuming this is related with the support case: |
|
Hey @yuxiang-midships and team, one more clarification.
This is correct through the use of FRSession.authenticate you can control the use of the func handleNode(token: Token?, node: Node?, error: Error?) {
if (token == nil) && (node == nil) && (error == nil) {
print("All nil indicates a noSession=true completed Journey")
self.updateStatus()
return
}
if error != nil {
print(error!)
return
}
self.currentNode = node
if let _ = token {
print("Session only Journey is now complete")
FRUser.currentUser?.getAccessToken(completion: { user, error in
DispatchQueue.main.async {
self.updateStatus()
}
})
} else {
if node == nil {
return
}
for callback: Callback in node!.callbacks {
}
}
}So basically after getting the Same logic applies to Android |
|
Hi George, You are absolutely correct that after using FRSession, we can use FRUser to exchange for Oauth2 Access token. However two of our clients are also using AM trees to carryout extra authentication at a transaction level (not session level). In the flow we implemented, we have custom OAuth 2 scripts that enable issuance of special scoped access token where the mobile end can use to invoke certain high risk transactions if the customer pass certain trees. The issue we faced is that when FRsession finish an AM tree, upon receiving a new SSO Token, the SDK behaviour will always override the existing session with the new session, similarly when using FRUser to exchange for token, new access token will override the existing access token. This behaviour is not we wanted, because we want to retain the session level access token (we dont care about the SSO token, it can be forgotten after access token exchange). So we manage to find a work around by using the Token manger interface in android where before we invoke the special transaction level AM trees, we first cache the session level access token to memory and then invoke the clear credential method. This makes the SDK entering a clean state. After the special transaction level AM tree is finished via FRSession and node handing, we exchange for the special scoped token directly via tokenmanger.oauth2client and give it to the mobile app for a one time use (this access token do not enter keychain) and then we set back the cached session level access token back to the SDK via the token manager interface persist method. This allows the mobile app to continue to use the session level access token for other non risky APIs This workaround can be achieved without any SDK modification in android, but in IOS we have to make a few lines of code change as shown in this PR. Also some additional things that we manage to achieve with this workaround
On midships's point of view, we understand why the SDK has implemented these logic. Therefore rather than modifying those logic at FRUser or FRSession level, we just modified certain interface/method to be exposed (in this case the token manager) such that the client can build their own Ping SDK wrapper classes using those interface and methods to bring out the behaviour they want (not alot of effort as most of the complicated things are still solved by the SDK). In our perspective, this will allow client that have very standard use cases to just use FRUser and FR session. For clients that have more non-standard use cases, they can use FR session for interaction with AM tress and token manger to handle Oauth/ODIC/refreshing of access token/storing of access token to secured storage. |
george-bafaloukas-forgerock
left a comment
There was a problem hiding this comment.
Hello @yuxiang-midships and team, thank you very much for submitting this request and providing these clarifications.
Can I please ask you to have a look on the comments and also make sure that any follow up commits are done using "Verified" account status. Please let us know if you need details on how to set up a "Verified" key.
Last but not least, can you please add some tests for the proposed changes?
Kind regards,
George Bafaloukas
| public struct TokenManager { | ||
|
|
||
| var oAuth2Client: OAuth2Client | ||
| public var oAuth2Client: OAuth2Client |
There was a problem hiding this comment.
Add code doc for the public oAuth2Client
| Browser.currentBrowser = nil | ||
| } | ||
|
|
||
| public func persistToken(token: AccessToken) { |
There was a problem hiding this comment.
add code doc for the persistToken method
vahancouver
left a comment
There was a problem hiding this comment.
Left some comments to address
PS: the commits need to be signed
|
|
||
| /// TokenManager class is a management class responsible for persisting, retrieving, and refreshing OAuth2 token(s) | ||
| struct TokenManager { | ||
| public struct TokenManager { |
There was a problem hiding this comment.
Please update the copyright header to reflect the latest changes year
| var oAuth2Client: OAuth2Client? | ||
| /// TokenManager instance for FRAuth to perform any token related operation | ||
| var tokenManager: TokenManager? | ||
| public var tokenManager: TokenManager? |
There was a problem hiding this comment.
Please update the copyright header to reflect the latest changes year
| /// - oAuth2Client: OAuth2Client instance for OAuth2 token protocols | ||
| /// - keychainManager: KeychainManager instance for secure credentials management | ||
| public init(oAuth2Client: OAuth2Client, keychainManager: KeychainManager) { | ||
| init(oAuth2Client: OAuth2Client, keychainManager: KeychainManager) { |
There was a problem hiding this comment.
was public meant to be removed here?
Hi Ping SDK Team,
Yuxiang here from Midships. I am raising this pull request to show some changes we are doing to support some of our clients for Ping SDK integration. These change on iOS SDK is to allow certain feature available on the Android SDK to be also available on the iOS SDK.
Summary:
Feel free to reach out to me for more details and why some clients will need these changes.
Best regards
Yuxiang
Associate Director, Midships