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

keychain keys are not cleared #144

Open
ihassanalattas opened this issue Mar 31, 2021 · 5 comments
Open

keychain keys are not cleared #144

ihassanalattas opened this issue Mar 31, 2021 · 5 comments

Comments

@ihassanalattas
Copy link

When I uninstall the app and reinstall it again the keys are still exists

  • Library setup method: Swift Package Manager.
  • Version of the library: 19.0.0.
  • Xcode version: 12.0 (12A7209).
  • OS version: iOS 14.0.
@evgenyneu
Copy link
Owner

evgenyneu commented Mar 31, 2021

HI @ihassanalattas, thanks for reporting this. I noticed this as well, Keychain is not removed when the app is uninstalled.

@ChrisMarshallNY
Copy link

Is this a bug, or is it the way the keychain is supposed to work? I am not an expert in keychain, so forgive my naiveté.

The keychain is designed to distribute across iCloud, so I assume that it has some persistence.

@evgenyneu
Copy link
Owner

evgenyneu commented Mar 31, 2021

Not sure if it's a bug or a feature of Keychain. It persists locally after the app is removed, so probably not related to iCloud.

@josh150
Copy link

josh150 commented Apr 29, 2021

That's how the Keychain works.

If you want your Keychain values to be tied to an app install you need to add a salt to your key and store that locally. This way you lose access to the key when the app is removed.

The general idea is:

let baseKey = UUID().uuidString
UserDefaults.standard.setValue(baseKey, forKey: "jwtKeyBase")

keychain.set(token, forKey: "jwt-\(baseKey)")

That said, it could be a nice feature for this package to provide this option of a two-stage key.

@bitops
Copy link

bitops commented Oct 20, 2022

This Apple Developer forums thread has more information related to what @josh150 wrote above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants