# Credential storage

> Choose how Chromium protects cookies and saved passwords at rest and stop Keychain prompts.

Chromium encrypts the cookies and saved passwords in your app's profile. [`App::credential_storage`](https://kurogane-rs.org/docs/api/app/app.md#method.credential_storage) chooses where the key comes from:

```rust
use kurogane::{App, CredentialStorage};

fn main() {
    App::new("content")
        .credential_storage(CredentialStorage::Basic)
        .run_or_exit();
}
```

## The two stores

| [`CredentialStorage`](https://kurogane-rs.org/docs/api/app/credentialstorage.md) | Key | Protects |
|---|---|---|
| `System` (default) | the platform's credential store | the profile against anyone without the user's login |
| `Basic` | a fixed key built into Chromium | nothing; it obfuscates |

`System` keeps the key in the Keychain on macOS, kwallet or gnome-keyring on Linux and DPAPI on Windows.

`Basic` is obfuscation and not encryption. Anyone who can read the profile directory can read what it holds.

## When the system store gets in the way

The platform stores grant access to a code identity:

* **macOS.** An unsigned binary has no identity that survives a rebuild. Every run of an unsigned build raises a Keychain prompt.
* **Linux.** A host without a keyring daemon has no store to reach. Chromium then stores the data unencrypted on its own.

Denying the macOS prompt is harmless. Chromium logs `Encryption is not available` and stores the data unencrypted.

Signing your macOS app ends the prompts. See the signing section of `kurogane bundle`. Until then use `Basic` for development builds.

## Use Basic for development only

Keep `System` for release builds and use `Basic` while you develop:

```rust
use kurogane::{App, CredentialStorage};

fn main() {
    let storage = if cfg!(debug_assertions) {
        CredentialStorage::Basic
    } else {
        CredentialStorage::System
    };
    App::new("content").credential_storage(storage).run_or_exit();
}
```

`Basic` suits:

* Unsigned development builds
* Containers and CI
* Headless hosts without a keyring daemon

It doesn't suit a profile holding data worth protecting.

> [!NOTE]
> Debug and release builds use different profiles. A debug build's `Basic` data never mixes with a release build's encrypted data.
