# SAP HANA temporary access

Issue restricted database users for SAP HANA 2.0 SPS 07 and later or HANA Cloud
through the existing [customer provisioner](/docs/guides/provisioner). Push and
outbound-only polling share the same connection token and customer authorization.

## Connect a database

Choose **SAP HANA** in **Temporary access → Add target**. Select your provisioner,
then enter the tenant database host, its SQL port, and existing roles to grant.
Connect directly to the tenant SQL endpoint, not the system database. Paste a
private CA certificate if needed; TLS certificate and hostname verification are required.

Supply JSON containing `username` and `password` for the management account. It
needs permission to create, alter, and drop users and user groups, grant the selected
roles, and read `SYS.USERS` and `SYS.USERGROUPS`. On HANA Platform this normally
means `USER ADMIN` plus role grant authority; HANA Cloud also uses `CREATE USERGROUP`
and user-group privileges. Do not grant administrative permissions to temporary users.

Restricted users receive only the configured roles. Include HANA's appropriate
`RESTRICTED_USER_JDBC_ACCESS` or `RESTRICTED_USER_ODBC_ACCESS` role when the client
needs its metadata permissions. Enter role names with their exact database case.

The browser encrypts this configuration and login to the provisioner. The driver
is built into the Rust executable: there is no SAP client installation, extra file,
Java process, or additional target configuration in the deployment. For a private CA,
the driver uses temporary public certificate files created and removed automatically
inside the container. It needs a writable OS temporary directory (provided by the
standard image); no persistent volume is needed.

## Lease lifecycle

Each lease creates a disabled user group and a restricted user belonging to it.
The provisioner grants the selected roles and enables access last. The group is
an automatically managed database object, used to verify ownership during cleanup.
It continues to identify the user if the issued password changes.

Cleanup checks group membership, deactivates the user, drops it with `RESTRICT`,
and removes the empty group. HANA refuses group deletion if it still contains
users. Seekrit never uses `CASCADE`; user-owned objects can prevent deletion, in
which case the user remains deactivated and cleanup is retried.

Lease expiry is enforced by scheduled cleanup. Keep the provisioner connected;
this adapter does not set a native `VALID UNTIL` deadline. Effects on active
connections also depend on HANA's deactivation behavior and the client's session.

## CLI and API

Register with `seekrit dynamic target add --name warehouse --config target.json`,
piping the management login JSON on stdin:

```json
{
  "provider": "sap-hana",
  "executor": "remote",
  "provisionerId": "prv_REPLACE_WITH_REGISTERED_ID",
  "settings": {"host": "hana.internal", "port": 30015, "roles": ["APP_READER"]},
  "maxTtlSeconds": 3600
}
```

Use `seekrit dynamic lease <target-id> --ttl 1h` to request access. The lease API
accepts `provider: "sap-hana"`. Existing member and service-token grants apply
without changing the provisioner configuration.

See SAP's [user creation reference](https://help.sap.com/docs/SAP_HANA_PLATFORM/4fe29514fd584807ac9f2a04f6754767/20d5ddb075191014b594f7b11ff08ee2.html)
and [user-group deletion rules](https://help.sap.com/docs/SAP_HANA_PLATFORM/4fe29514fd584807ac9f2a04f6754767/6dc0adae9f4c4ebaa46cbe6b5f636ee7.html).
