Leased Secrets
Issue short-lived, per-machine PostgreSQL, MySQL, MariaDB, Supabase, Redis or MSSQL credentials on demand.
Leased secrets create short-lived database or Redis credentials when an authorized machine reads them. Each machine receives its own provider account, password, and expiry, while applications continue to connect with the provider’s normal client libraries.
A leased secret returns connection fields and a credential together: host, port, database, username, and password. Redis returns an empty database field because its ACL users apply to the Redis instance.
#How leased secrets work
You connect a supported provider and choose the access each issued account should receive.
You set the credential lifetime, renewal behavior, and revocation controls.
A machine with project membership and an explicit grant reads the leased secret.
SikkerKey creates a provider account for that machine, stores its password encrypted, and returns the connection fields.
Later reads reuse or renew the credential according to the lease policy.
When the lease ends, the machine is disabled, or the leased secret is deleted, SikkerKey removes the issued provider account.
The provider username is stable for one machine and leased secret, begins with sk_l_, and remains separate from the usernames issued to other machines. Re-minting replaces its password so the previous credential stops authenticating.
Part | Purpose |
|---|---|
Provider connection | Lets SikkerKey create, renew, and remove accounts in the selected database or Redis instance |
Credential shape | Controls the generated password and the access granted to each issued account |
Lease policy | Controls lifetime, renewal, maximum age, and revocation behavior |
Machine grant | Authorizes one machine to request its own leased credential |
Access policy | Evaluates the project’s additional read rules before a credential is issued or returned |
Audit history | Records which machine minted, read, renewed, or lost a leased credential |
#Supported providers
Provider | Issued account | Expiry |
|---|---|---|
PostgreSQL | Login role created for the reading machine | Optional database-enforced VALID UNTIL plus account removal |
PostgreSQL (Supabase) | PostgreSQL login role reached through the Supabase pooler | Optional database-enforced VALID UNTIL plus account removal |
MySQL | User created as username@% | Account removal at lease expiry |
MariaDB | User created as username@% | Account removal at lease expiry |
Redis | Redis 6+ ACL user | ACL user removal at lease expiry |
MSSQL (Microsoft SQL Server) | Login and database user created for the reading machine The database user is mapped to the server login. | Account removal at lease expiry |
Administrative account requirements
PostgreSQL and PostgreSQL (Supabase): CREATEROLE or SUPERUSER, plus permission to apply the configured grants.
MySQL and MariaDB: CREATE USER, ALL PRIVILEGES, or equivalent operator access, plus permission to apply the configured grants.
Redis: an ACL account with the administrative command permissions needed to list, create, update, and delete ACL users.
Microsoft SQL Server: an account with permission to create and drop server logins, terminate their sessions, and create and drop the database user — ALTER ANY LOGIN, ALTER ANY CONNECTION, and ALTER ANY USER, or the sysadmin server role, plus permission to apply the configured grants.
For PostgreSQL (Supabase), enter the 16–32 character lowercase project reference from the Supabase pooler hostname. SikkerKey appends it when connecting through Supavisor while keeping the database role name unchanged.
For Microsoft SQL Server, SikkerKey creates a server-level login and a mapped user in that database, then applies the configured grants to the database user. On revocation, it removes the database user before the server login and retries if SQL Server is temporarily unreachable.
#Prepare the provider connection
SikkerKey can reach the provider two ways. Use a publicly routable hostname when the provider accepts connections from the internet, or route the connection over a tunnel when it does not.
For a public connection, use a hostname that resolves to the provider and accepts connections from SikkerKey. The connection check rejects loopback, private, link-local, and metadata addresses. Configure the provider firewall or network allowlist so SikkerKey can reach the selected port.
Connection security | Behavior |
|---|---|
Encrypted + verified | Encrypts traffic and verifies the provider certificate and hostname. Use a pasted CA certificate for a self-signed or private-CA service. |
Encrypted | Encrypts traffic without verifying the provider identity. This is the default. |
None | Uses an unencrypted provider connection. Use only when another trusted network layer protects the route. |
Use Test connection before creating the leased secret. It confirms network access, credentials, connection security, and the administrative account’s ability to manage provider users.
Reach a provider through a tunnel
A tunnel lets SikkerKey issue credentials for a database that accepts no connections from the internet. A connector runs on a host inside your network and holds a private outbound connection, and SikkerKey reaches the database through the target you declare on it.
When a tunnel is available, selecting the host field offers your tunnels. Choosing one turns the port field into a target picker, and selecting a target fills the host and port from the target’s own definition. The address is resolved on the machine running the connector, so private addresses and internal DNS names are expected here.
Minting, renewal, and revocation all travel over the tunnel. Your applications are unaffected and continue to connect to the database directly on your own network using the returned connection fields.
Tunnels are available on plans that include them, and your plan sets how many tunnels a vault can hold. The option appears when your plan includes tunnels and the vault has one that is installed, approved, and enabled. See Tunnels for setup.
Connection security still verifies the provider certificate against the host recorded on the target. When you use Encrypted + verified, declare the target host as the name the certificate is issued for.
#Create a leased secret
Open the project that should own the leased credential, then open Secrets.
Select the plus button and choose Leased Secret.
Enter a name and select PostgreSQL, PostgreSQL (Supabase), MySQL, MariaDB, Redis, or MSSQL.
Enter the provider host, port, database, administrative username, and administrative password. Redis does not require a database name. To route the connection privately, select a tunnel in the host field and then choose a target.
For PostgreSQL (Supabase), enter the project reference used by the pooler.
Choose the connection security level and add a CA certificate when Encrypted + verified uses a private certificate authority.
Select Test connection and confirm that the connection succeeds.
Continue to Lease & credential.
Choose the generated password shape, configure grants, and set the lease policy.
Review the complete configuration and select Create leased secret.
New leased secrets default to 32-character passwords using uppercase letters, lowercase letters, and numbers. The default lease lasts one hour, renews on reads made within the final 15 minutes, revokes when its machine is disabled, and uses PostgreSQL database-enforced expiry when available.
#Configure issued access
Grants define what each issued provider account can do. Leave the grants field empty to issue a login-only SQL account or a Redis account limited to connection commands.
Use the grant builder
Select Build template to start with Read-only, Read / write, or a broader provider-specific preset. You can then adjust individual privileges and scope before inserting the result.
PostgreSQL can scope grants to a schema, include sequence access, and apply matching default privileges to future tables and sequences.
MySQL and MariaDB scope generated grants to the configured database.
Redis can scope commands to a key pattern and optionally a Pub/Sub channel pattern.
Microsoft SQL Server scopes object privileges to a schema (dbo by default), where they cover current and future objects. CREATE TABLE, CREATE VIEW, and CREATE PROCEDURE privileges are database-scoped.
Write a SQL grant template
For PostgreSQL, MySQL, or MariaDB, use The same placeholder is used for Microsoft SQL Server and is rendered as a safely bracket-quoted database user.{{name}} wherever the issued account should appear. SikkerKey replaces it with the safely quoted provider username during each mint.
GRANT SELECT ON ALL TABLES IN SCHEMA public TO {{name}};For Microsoft SQL Server, schema grants cover both existing and future objects in that schema. The grant builder uses dbo by default; database-scoped CREATE privileges are emitted as separate statements.
GRANT SELECT, INSERT, UPDATE, DELETE ON SCHEMA::[dbo] TO {{name}};Write Redis ACL rules
For Redis, enter the key patterns, channel patterns, and command categories that should follow the issued username and password.
~app:* +@read +@writeOnly the vault owner can create or change a custom grants template because it runs with the configured administrative account. To reduce SQL privileges for accounts that are already active, create a replacement leased secret with the narrower grants and delete the original so its issued accounts are revoked.
#Configure the lease policy
Setting | How it works |
|---|---|
Credential lifetime | Sets how long an issued credential remains active. The minimum is one minute. |
Renew on read | Extends an active credential when its machine reads close to expiry. |
Renew window | Defines how close to expiry a read must occur before renewal. When automatic, SikkerKey uses half the credential lifetime. |
Hard maximum | Caps how long one issued credential can be extended. A later read mints a fresh password after the ceiling is reached. |
Database-native expiry | Adds PostgreSQL VALID UNTIL so PostgreSQL rejects the login at expiry, then SikkerKey removes the role. |
Revoke when machine disabled | Removes the machine’s active account after that machine is disabled. |
Mint fresh on every read | Generates and applies a new password for every successful read instead of reusing the active credential. |
MySQL, MariaDB, and Redis enforce expiry through account removal. If the provider is temporarily unreachable, SikkerKey retries revocation with increasing intervals until the account is removed. Microsoft SQL Server follows the same removal-and-retry model because SQL Server logins do not have a timestamp-based lease expiry.
#Grant a machine access
A read passes through machine authentication, project membership, the explicit secret grant, project lock state, and any attached access policy before SikkerKey contacts the provider.
Add the application machine to the leased secret’s project.
Configure that machine and grant it the leased secret.
Read the secret by its stable secret ID using a SikkerKey SDK or the CLI.
Use the returned host, port, database, username, and password with the provider client.
#Understand reads, renewal, and expiry
Situation | Result |
|---|---|
First read by a machine | Creates the machine’s provider account and returns a new password |
Read while the lease is active | Returns the same credential and records the read |
Read inside the renewal window | Extends expiry when renewal is enabled, up to the hard maximum |
Read after expiry | Mints a fresh password and returns the renewed provider account |
Mint fresh on every read enabled | Replaces the provider password during every read |
Machine disabled with revocation enabled | Removes that machine’s provider account |
Leased secret disabled | Stops minting and serving credentials until it is enabled again |
Lease expires | Removes the provider account; PostgreSQL can also reject it at its own expiry timestamp |
Reuse a credential for the lifetime of an application connection pool. Read again when opening a new pool or when the application needs to refresh an expiring credential.
#Manage an existing leased secret
Open the row menu and select Configure. The leased-secret configuration has four tabs.
Status
Active allows authorized machine reads to mint or return leased credentials.
Disable minting stops new reads. Provider accounts already issued remain active until their lease expires or another revocation event removes them.
Enable minting resumes authorized reads.
Policy
Change the lifetime, renewal window, hard maximum, database-native expiry, machine-disable revocation, or mint-on-every-read behavior, then select Save policy. Existing provider credentials retain their current account and expiry until subsequent reads, renewal, expiry, or revocation applies the new behavior.
Grants
Edit the access template directly or use Build template, then select Save grants. The saved template is used when SikkerKey next mints the provider credential.
Connection
Update the host, port, database, connection security, project reference, or administrative credentials. Re-enter the administrative username and password, select Test connection, and then select Save connection.
A tunnel-routed leased secret keeps its tunnel and target in this tab. Leave them selected when you change anything else, because saving the connection without them returns the leased secret to a direct connection, and a private address is not reachable that way.
When moving to a different provider host or database, create and test a replacement leased secret first. After workloads use the replacement, delete the original so accounts issued in the original provider are revoked with its original connection.
#Delete a leased secret
Deleting a leased secret stops further reads immediately, queues every issued provider account for removal, removes its provider connection and lease configuration, and moves the retained secret record to Trash for 30 days. The same account-removal workflow runs when its project or vault is deleted.
Open the leased secret’s row menu and select Delete.
Review the machines that will lose access.
Confirm the deletion.
SikkerKey retries queued account removal when the provider is temporarily unavailable. Restoring the retained Trash record recovers its name, secret ID, and history in the original project. Create a new leased secret to establish a new provider connection, policy, grants, and credential lifecycle.
Permanent deletion from Trash, or automatic cleanup after 30 days, removes the retained leased-secret record and its history.
#Troubleshoot leased secrets
Symptom | What to check |
|---|---|
Test connection fails | Check the hostname, port, firewall, database name, administrative credentials, provider privileges, and selected connection security. For a tunnel-routed connection, confirm the tunnel is connected and the target is reachable from the connector’s host. |
Host is blocked | A direct connection needs a publicly routable provider hostname; loopback, private, link-local, and metadata addresses are rejected. To reach a provider on a private address, route the connection over a tunnel instead. |
No tunnel appears in the host field | Confirm your plan includes tunnels and that the vault has one that is installed, approved, and enabled with at least one target. |
Certificate verification fails | Confirm the hostname matches the certificate. Paste the issuing CA certificate when the provider uses a self-signed certificate or private CA. Over a tunnel, the certificate is verified against the host recorded on the target. |
Machine receives Access denied | Confirm the machine is approved, enabled, in the project, explicitly granted the leased secret, and allowed by the attached access policy. |
Project is locked | Resolve the project lock before requesting credentials. |
Minting fails | Confirm the administrative account can create or update users and apply the configured grants. Review the audit entry for the failed mint. |
Mint is in progress | Retry shortly; SikkerKey serializes concurrent requests for one machine’s provider account. |
Issued login can connect but lacks access | Review the grants template. An empty SQL template creates a login without database privileges, and empty Redis rules permit only connection commands. |
Renewal does not extend PostgreSQL expiry | Confirm the administrative account can alter the issued role and that the provider connection remains reachable. The current credential stays valid until its existing expiry. |
Disabled machine’s account remains | Confirm Revoke when machine disabled is enabled and the provider is reachable. SikkerKey retries removal when the provider becomes available. |
Leased secret is disabled | Open Configure, then Status, and select Enable minting. |