Secure Storage
SecureAuthStorage is the ready-to-use AuthStorage implementation for Flutter apps, wrapping flutter_secure_storage.
import 'package:authyra_flutter/authyra_flutter.dart';
await Authyra.initialize(
client: AuthyraClient(
providers: [...],
storage: SecureAuthStorage(),
),
);
No configuration is required for most apps. It selects the platform-native encrypted store automatically:
| Platform | Backend |
|---|---|
| iOS / macOS | Keychain |
| Android | EncryptedSharedPreferences (Android Keystore) |
| Web | localStorage with Web Crypto AES-GCM, per-origin key |
| Linux | libsecret (Secret Service) |
| Windows | DPAPI (CryptProtectData) |
Custom platform options
Pass flutter_secure_storage's own option classes to tune behaviour per platform:
SecureAuthStorage(
aOptions: const AndroidOptions(
encryptedSharedPreferences: true,
resetOnError: true, // wipe rather than crash on decryption failure
),
)
Android setup
minSdkVersion must be 18 or above in android/app/build.gradle:
android {
defaultConfig {
minSdkVersion 18
}
}
Web setup
No extra configuration. flutter_secure_storage on web uses the browser's SubtleCrypto API with a key scoped to your origin.
What gets stored
SessionManager persists one entry per signed-in account under session:{userId}, plus a small index for the active account. Every entry contains that account's AuthSession JSON, including access and refresh tokens, so the underlying encryption matters: don't swap in a plaintext implementation.
See also
- Storage →
- AuthStorage API →
- Custom Storage guide →, for non-Flutter runtimes