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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace JSONObjectPayload with Codable on Credentials [SDK-2958] #549

Merged
merged 6 commits into from
Nov 17, 2021

Conversation

Widcket
Copy link
Contributor

@Widcket Widcket commented Nov 17, 2021

Changes

⚠️ THIS PR CONTAINS BREAKING CHANGES

This PR replaces the conformance of Credentials to JSONObjectPayload with conformance to Codable and uses the newer, non-deprecated methods of NSKeyedArchiver and NSKeyedUnarchiver to archive and unarchive Credentials.

Additionally, the Credentials class was made final.

Care was taken to ensure that credentials archived with Auth0.swift 1.x can be unarchived successfully, and the other way around (in case customers need to downgrade to 1.x). Otherwise, if apps are using the Credentials Manager of Auth0.swift 1.x and then get upgraded to 2.x, the stored credentials will not be readable, essentially logging out all the users.
To maintain compatibility, @objc(A0Credentials) was added back to Credentials, which still needs to inherit from NSObject.

Dropping NSSecureCoding in favor of Codable + the Codable-supporting methods of NSKeyedArchiver and NSKeyedUnarchiver has been ruled out for the sake of this compatibility after doing a spike testing it.

Testing

The backward compatibility of the archived credentials was tested manually in a test app, by:

  • Storing credentials with the Credentials Manager from Auth0.swift 1.38.0 and then reading them back using the Credentials Manager from this PR.
  • Storing credentials with the Credentials Manager from this PR and then reading them back using the Credentials Manager from Auth0.swift 1.38.0.

These tests were performed on both iOS 15 (simulator) and macOS Big Sur.

  • This change adds unit test coverage
  • This change has been tested on the latest version of the platform/language or why not

Checklist

@Widcket Widcket requested a review from a team as a code owner November 17, 2021 02:34
@Widcket Widcket added the review:medium Medium review label Nov 17, 2021
@Widcket Widcket changed the title Make Credentials conform to Codable [SDK-2958] Replace JSONObjectPayload with Codable on Credentials [SDK-2958] Nov 17, 2021
@@ -3,7 +3,8 @@ import Foundation
/**
User's credentials obtained from Auth0.
*/
public class Credentials: NSObject, JSONObjectPayload, NSSecureCoding {
@objc(A0Credentials)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Re-added for backward compatibility of archived credentials.

@Widcket Widcket merged commit 0fd9ebe into beta Nov 17, 2021
@Widcket Widcket deleted the v2/nscoding-credentials branch November 17, 2021 11:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
review:medium Medium review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants