feat: add credentialsManager.clearAll() for full credential and key wipe - #930
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. 🗂️ Base branches to auto review (3)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| request: MethodCallRequest, | ||
| result: MethodChannel.Result | ||
| ) { | ||
| credentialsManager.clearAll() |
There was a problem hiding this comment.
@utkrishtsahu clearAll underhood calls keychain for swift it can fail is it the same case for android? can keystore fail?
There was a problem hiding this comment.
Good catch — yes, on Android clearAll() can throw: it only swallows DPoPException internally, while crypto.deleteAllKeys() / storage.removeAll() can still throw (keystore errors). I've wrapped the call in try/catch and report the failure via result.error(...), matching the iOS handler, and added a test for the failure path.
|
|
||
| @testable import auth0_flutter | ||
|
|
||
| class CredentialsManagerClearAllMethodHandlerTests: XCTestCase { |
There was a problem hiding this comment.
minor test build optimization. lets make it final class
|
|
||
| > 💡 `clearAll()` is a more thorough wipe than `clearCredentials()`: | ||
| > | ||
| > - `clearCredentials()` removes the stored credential entries only. On iOS/macOS it deletes the credentials, DPoP thumbprint, and session-expiry entries; on Android it clears the credentials store. |
There was a problem hiding this comment.
Let's mention clearApiCredentials as well here?
There was a problem hiding this comment.
Added a bullet for clearApiCredentials in the comparison.
📋 Changes
Adds a new
clearAll()method to the credentials manager for a full wipe of stored credentials and the underlying encryption keys, across Android and iOS/macOS. This exposes Auth0.Android v4'sSecureCredentialsManager.clearAll()and Auth0.swift v3'sCredentialsManager.clearAll()through the Flutter API. Additive change — existing APIs are unaffected.Public API (
auth0_flutter)Future<void> clearAll()to theCredentialsManagerinterface andDefaultCredentialsManager.Platform interface (
auth0_flutter_platform_interface)clearAll()toCredentialsManagerPlatform.credentialsManager#clearAllmethod-channel constant and itsMethodChannelCredentialsManagerimplementation (returnsvoid; no throw on null).Android native
ClearAllRequestHandlerroutescredentialsManager#clearAlltoSecureCredentialsManager.clearAll(); registered inAuth0FlutterPlugin.iOS/macOS native
CredentialsManagerClearAllMethodHandlerroutes toCredentialsManager.clearAll(); registered inCredentialsManagerHandler(Methodenum + provider).clearAll()vsclearCredentials()— these are intentionally distinct on both platforms (verified against the native SDK sources):clearCredentials()removes only the stored credential entries (plus biometric session).clearAll()additionally removes the encryption keys — on Android the crypto key pair and the DPoP key; on iOS/macOS every entry in the credentials store plus the DPoP key pair.Because
clearAll()deletes all entries in the underlying store, consumers are advised not to share that store (customsharedPreferencesNameon Android, orstoreKey/accessGroupon iOS/macOS) with unrelated app data.Docs
EXAMPLES.md: new "Clear all credentials and encryption keys" section documenting usage and the difference fromclearCredentials().V3_MIGRATION_GUIDE.md: additive note describingclearAll()and the distinction.🎯 Testing
Unit tests added
auth0_flutter_platform_interface— method-channel contract tests forclearAll(method_channel_credentials_manager_test.dart): dispatchescredentialsManager#clearAll, maps account/userAgent, and throwsCredentialsManagerExceptionon aPlatformException.auth0_flutter—credentials_manager_test.dart:DefaultCredentialsManager.clearAll()forwards to the platform. Mockito mocks regenerated for this test only.ClearAllRequestHandlerTest.kt: verifiesSecureCredentialsManager.clearAll()is called and the handler returnssuccess(null).CredentialsManagerClearAllMethodHandlerTests.swift: verifies the SDK full-wipe is invoked (deleteAllEntries), producesnilon success and aFlutterErroron failure.SpyCredentialsStoragegained adeleteAllEntries()implementation (the protocol's default just asserts).Verified locally
flutter test(VM):auth0_flutter153/153 pass;auth0_flutter_platform_interfacepass except the pre-existing environment-dependent UTC-timezone test incredentials_test.dart(passes in CI).flutter analyze:auth0_flutter_platform_interfaceclean;auth0_flutterhas no new issues.