Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add renew() to Credentials Manager [SDK-4300] #772

Merged
merged 3 commits into from Jun 9, 2023

Conversation

Widcket
Copy link
Contributor

@Widcket Widcket commented Jun 9, 2023

  • All new/changed/fixed functionality is covered by tests (or N/A)
  • I have added documentation for all new/changed functionality (or N/A)

馃搵 Changes

This PR adds a new method renew() to the Credentials Manager, that allows to renew the stored credentials in a thread-safe way.

credentialsManager.renew { result in
    switch result {
    case .success(let credentials):
        print("Renewed credentials: \(credentials)")
    case .failure(let error):
        print("Failed with: \(error)")
    }
}

This new method also supports Combine and async/await.

馃幆 Testing

Besides adding a slew of unit tests, this method was tested manually with Xcode 14.2 (14C18) using an iPhone simulator running iOS 16.2.

@Widcket Widcket added the review:large Large review label Jun 9, 2023
@Widcket Widcket requested a review from a team as a code owner June 9, 2023 13:03
///
/// - [Refresh Tokens](https://auth0.com/docs/secure/tokens/refresh-tokens)
/// - [Authentication API Endpoint](https://auth0.com/docs/api/authentication#refresh-token)
public func renew(parameters: [String: Any] = [:], headers: [String: String] = [:], callback: @escaping (CredentialsManagerResult<Credentials>) -> Void) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we pass scope here? Is it because we renew anyway if the scope is different?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If a developer wants to downscope, we already have the credentials() method available, which will force-renew in that case. However, I'm not entirely convinced of the usefulness of this downscoping feature given that the CM does not support multiple sets of credentials, therefore it will overwrite the current credentials with the downscoped ones. So the AT with the full scopes will not be stored anymore. Something to consider for the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And we already expose the auth API client method renew(), that supports downscoping as well (with no storage involved).

Copy link

@stevehobbsdev stevehobbsdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@Widcket Widcket merged commit d3d27bc into master Jun 9, 2023
9 checks passed
@Widcket Widcket deleted the feature/credentials-manager-renew branch June 9, 2023 13:46
@Widcket Widcket mentioned this pull request Jun 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants