Skip to content

Commit 01cd930

Browse files
author
Kadi Kraman
committed
Add token storage recommendations
1 parent 8347079 commit 01cd930

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,10 @@ Some authentication providers, including examples cited below, require you to pr
416416
> [strongly recommend](https://github.com/openid/AppAuth-Android#utilizing-client-secrets-dangerous) you avoid using static client secrets in your native applications whenever possible. Client secrets derived via a dynamic client registration are safe to use, but static client secrets can be easily extracted from your apps and allow others to impersonate your app and steal user data. If client secrets must be used by the OAuth2 provider you are integrating with, we strongly recommend performing the code exchange step on your backend, where the client secret can be kept hidden.
417417
418418
Having said this, in some cases using client secrets is unavoidable. In these cases, a `clientSecret` parameter can be provided to `authorize`/`refresh` calls when performing a token request.
419-
g
419+
420+
#### Token Storage
421+
422+
Recommendations on secure token storage can be found [here](./docs/token-storage.md).
420423
421424
#### Maintenance Status
422425

docs/token-storage.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
## Token Storage
2+
3+
Once the user has successfully authenticated, you'll have a JWT and possibly a refresh token that need to be stored securely.
4+
5+
❗️ __Do not use Async Storage for storing sensitive information__
6+
7+
Async Storage is the simplest method of persisting data across application launches. However, it is _unencrypted_ key-value store and so should not be used for token storage.
8+
9+
__DO use Secure Storage__
10+
11+
React Native does not come bundled with any way of storing sensitive data, however there are pre-existing solutions for both platforms.
12+
13+
### iOS - Keychain Services
14+
Keychain Services allows you to securely store small chunks of sensitive info for the user. This is an ideal place to store certificates, tokens, passwords, and any other sensitive information that doesn’t belong in Async Storage.
15+
16+
### Android - Secure Shared Preferences
17+
Shared Preferences is the Android equivalent for a persistent key-value data store. Data in Shared Preferences is not encrypted by default. Encrypted Shared Preferences wraps the Shared Preferences class for Android, and automatically encrypts keys and values.
18+
19+
In order to use iOS Keychain services or Android Secure Shared Preferences, you either can write a bridge yourself or use a library which wraps them for you and provides a unified API at your own risk.
20+
21+
## Related OSS libraries
22+
23+
- [react-native-sensitive-info](https://github.com/mCodex/react-native-sensitive-info)
24+
- [redux-persist-sensitive-storage](https://github.com/CodingZeal/redux-persist-sensitive-storage)
25+
- [react-native-keychain](https://github.com/oblador/react-native-keychain)
26+
- [rn-secure-storage](https://github.com/talut/rn-secure-storage)

0 commit comments

Comments
 (0)