tezvyn:

Why store auth tokens in Keychain, not UserDefaults?

Source: interviewintermediate

WHAT IT TESTS: secure credential storage. OUTLINE: UserDefaults is an unencrypted plist readable from backups and on jailbroken devices; use Keychain Services, which stores encrypted items with access control; save with SecItemAdd and read with…

WHAT IT TESTS: whether you know where sensitive data belongs on iOS. ANSWER OUTLINE: UserDefaults persists to an unencrypted property list inside the app sandbox that is included in backups and readable on a compromised or jailbroken device, so secrets do not belong there; the Keychain encrypts items, ties them to the device and an accessibility class, and can require biometrics; you store a token with SecItemAdd, retrieve it with SecItemCopyMatching, and update or delete with SecItemUpdate and SecItemDelete.

Read the original → interview

Get five bites like this every day.

Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.

Why store auth tokens in Keychain, not UserDefaults? · Tezvyn