Skip to content

Commit

Permalink
Merge pull request supabase#193 from bdlukaa/encryption-default-value
Browse files Browse the repository at this point in the history
Documentation about encryption
  • Loading branch information
dshukertjr committed Aug 22, 2022
2 parents a0e221b + 0570af0 commit a172948
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions README.md
Expand Up @@ -26,7 +26,7 @@ Supabase is an open source Firebase alternative. We are a service to:

## Features

- [x] Null-safety
- Null-safety

| Platform | Email Auth | Provider Auth | Database | Realtime | Storage |
| -------- | :--------: | :-----------: | :------: | :------: | :-----: |
Expand Down Expand Up @@ -327,9 +327,20 @@ Supabase.instance.client.auth.signInWithProvider(

### Custom LocalStorage

As default `supabase_flutter` uses [`hive`](https://pub.dev/packages/hive) plugin to persist user session. However you can use any other plugins by creating a `LocalStorage` impl.
As default, `supabase_flutter` uses [`hive`](https://pub.dev/packages/hive) to persist the user session. Encryption is disabled by default, since an unique encryption key is necessary, and we can not define it. To set an `encryptionKey`, do the following:

For example, we can use `flutter_secure_storage` plugin to store the user session in a secure storage.
```dart
void main() {
// set it before initializing
HiveLocalStorage.encryptionKey = 'my_secure_key';
Supabase.initialize(...);
}
```

**Note** the key must be the same. There is no check if the encryption key is correct. If it isn't, there may be unexpected behavior. [Learn more](https://docs.hivedb.dev/#/advanced/encrypted_box) about encryption in hive.


However you can use any other methods by creating a `LocalStorage` implementation. For example, we can use [`flutter_secure_storage`](https://pub.dev/packages/flutter_secure_storage) plugin to store the user session in a secure storage.

```dart
// Define the custom LocalStorage implementation
Expand Down Expand Up @@ -359,7 +370,7 @@ Supabase.initialize(
);
```

You can use `EmptyLocalStorage` to disable session persistance:
You can also use `EmptyLocalStorage` to disable session persistance:

```dart
Supabase.initialize(
Expand Down

0 comments on commit a172948

Please sign in to comment.