# MongoDB temporary access

[Temporary access overview](/docs/concepts/temporary-access) covers target setup, connection methods, and credential handling.

MongoDB uses [client-encrypted delivery](/docs/concepts/temporary-access#provider-tiers) (tier 2): unlike
Postgres, MySQL, and Redis — where the target stores a client-computed verifier
verbatim — MongoDB's `createUser` **hashes the password server-side**, and there
is no supported way to inject a precomputed SCRAM credential. So the plaintext
can't stay on the consumer's machine the way it does for the tier-1 databases.
MongoDB takes the same shape as [AWS](/docs/guides/dynamic-aws): the credential is **encrypted to
the consumer before it comes back**.

You register one **cluster** as a target, with the database leased users get
access to and an access level. seekrit provisions with an admin `mongodb://`
credential (the wrapped admin secret) that needs `userAdmin` on that database.
Access levels map to MongoDB's built-in roles — `read` (read-only) or
`readWrite` — on the target database, or you supply an explicit `roles` array for
`custom`.

Minting works like this:

1. The machine that will use the credential generates an **ephemeral P-256
   keypair locally** and sends seekrit **only the public key**, plus a TTL.
2. The broker **generates a random password**, connects to MongoDB over its wire
   protocol (with the admin credential decrypted transiently in the DO), and runs
   `createUser` with the preset roles.
3. The broker **wraps the resulting credential to your public key** (the same
   `wd1.` envelope used for DEK grants) and returns only the ciphertext.
4. Your machine unwraps it with the private key it never shared:

```
eval "$(seekrit mongodb lease prod-app --ttl 1h)"
mongosh "$MONGODB_URI"
```

The control plane only ever relays ciphertext, and only your private key can
unwrap it. The broker sees the password transiently (it generates it and runs
`createUser`), the scoped exception tier 2 makes — the same trade the tier-1
providers make for their *admin* credential.

> **Note:** **Revocation is real.** Unlike AWS/SSH, a MongoDB lease is ended by dropping
>   the user: the broker's alarm runs `dropUser` at expiry, and revoking a lease
>   drops it immediately. Registered customer provisioners also support MongoDB
>   through the native driver. For hosted execution, `mongodb+srv://` admin URLs
>   are not supported; register an explicit `host:port`.

For provisioning through the Atlas Administration API, see [MongoDB Atlas](/docs/guides/dynamic-mongodb-atlas).

See the [CLI reference](/docs/reference/cli) and [API reference](/docs/reference/api) for commands and endpoints.
