Basic implementation of URLCredentialStorage #2334
Merged
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.
A basic implementation of URLCredentialStorage, mainly oriented to
credentials for the session. It is an in-memory storage and ignores any
usage of permantent or synchronizable persistency. This should cover
many usage cases, and should allow to built on top of it.
Includes tests.
Known differences with macOS:
I tried to run the set of test against macOS (10.14.5) and found a couple of weird results (I run the tests in a playground, so that might cause interesting behaviours).
.permanent
credentials are only stored in-memory (so they are equivalent to.forSession
). Each operating system might have their own permanent storage, so each implementation might be different (or not exist at all). This can be tackled after this basic implementation is reviewed, and in a per-OS strategy.URLCredentialStorage()
in macOS will not return a storage that can store credentials (not even.forSession
ones). In the tests I decided to useURLCredentialStorage.shared
since it will work on macOS, but makes the tests harder to read, because you have to implicitely clean.setDefaultCredential(…)
, sets it as default..synchronizable
credential in macOS. I imagine the playground I was using might not have the right permissions for the iCloud Keychain. However, in the implementation, the.synchronizable
credentials are added to the in-memory storage, and are removed only when providing the special key.