Database access expiry sweep
What it does. Revokes every just-in-time database access grant whose Expires time has passed: it drops the grant's database user and firewall rule, marks the grant Expired and clears its stored password. Runs: by itself, as one-time batch jobs that Lattice schedules for each grant's expiry. You can also run it from its menu item. Who looks after it: Database access administrator.
Purpose
A just-in-time grant gives one administrator full control of the environment's database from one IP address for a limited time. The grant's Expires time is only a promise until something removes the access: this sweep is what removes it. Without it, an expired grant keeps its database user and firewall rule, and stays Active on Database access grants.
When it runs
- When a grant is issued. Before Lattice creates a grant, it makes sure a sweep starts no later than the grant's expiry. When none does, it schedules a one-time batch job named Revoke expired just-in-time database access grants for that time, owned by the administrator who requested the grant. A sweep owned by a user who has since been disabled does not count, because the batch service never runs it.
- When a revoke is deferred. When Revoke, or the automatic revoke of your earlier grant when you request a new one, cannot drop the access at that moment, the grant stays Active with Expires moved to now, and a sweep is scheduled to run at once.
- After each run. A run schedules the next sweep at the earliest Expires time of the grants that are still Active, but no sooner than 15 minutes later. When no grant is active, it schedules nothing, so no job keeps running when database access is not in use.
- On demand. System administration > Periodic tasks > Lattice > Run database access expiry sweep.
Configuration and scheduling
There is nothing to set up or schedule: the sweep schedules itself.
| Setting | Where | Default |
|---|---|---|
| How long a grant lasts | Hours in the Request access dialog on Database access grants, or the duration a caller of the database access service asks for; from 1 to 72 hours | 24 hours |
| Retry interval after a failed revoke | Fixed | 15 minutes |
| Run it now | System administration > Periodic tasks > Lattice > Run database access expiry sweep. The dialog has no fields of its own; select OK to run it now, or set Batch processing to Yes under Run in the background to run it as a batch job |
Do not give the sweep a recurrence of your own: the scheduled one-time jobs already run it when a grant expires.
How it works
- A run lists every grant whose Status is Active and whose Expires time has passed.
- For each one, it drops the grant's database user and its firewall rule, then sets Status to Expired and clears the stored password, in a transaction of its own.
- When dropping the access fails, the grant stays Active, the run logs "Failed to revoke expired database access grant for user %1." with the database user, and goes on with the next grant.
- At the end it logs "Database access expiry sweep completed. Grants revoked: %1, failures: %2."
- It schedules the next sweep as described in When it runs. A grant whose revoke failed is already past its expiry, so it is retried 15 minutes later.
Before it can run
- The batch service is running. When Lattice cannot schedule the sweep for a new grant, the grant is not issued.
- The administrator who requested the grant is still an enabled user at its expiry, because the scheduled job runs as that user.
- The license is not checked: removing access is never blocked.
Inputs and outputs
| Reads | Writes |
|---|---|
| The grants on Database access grants that are Active and past Expires | Drops each such grant's database user and firewall rule |
| Sets Status to Expired and clears the stored password | |
| One-time batch jobs Revoke expired just-in-time database access grants for the next sweep |
Monitoring and logs
- System administration > Inquiries > Lattice > Database access > Database access grants: after a grant's Expires time, its Status should read Expired. A grant that is still Active after its Expires time has not been revoked yet.
- System administration > Inquiries > Batch jobs: a waiting Revoke expired just-in-time database access grants job shows when the next sweep runs. A scheduled sweep is removed from the list once it has run; select Batch job history to read its log with the messages above.
When it fails
| Symptom | Cause | Fix |
|---|---|---|
| A grant is still Active after its Expires time, and its sweep's log says "Failed to revoke expired database access grant for user %1." | The database user or firewall rule could not be dropped at that moment | Nothing at first: the next sweep retries it 15 minutes later. If it keeps failing, select Revoke on the grant and read the warning |
| A grant is still Active after its Expires time, and no sweep has run | The batch service is stopped, or the scheduled job is withheld because its owner was disabled | Start the batch service, or run Run database access expiry sweep now |
| "The database access grant %1 could not be revoked now. It stays active until the expiry sweep revokes it." | Revoke could not drop the access | Expected: a sweep was scheduled to run at once. Check the grant's Status a little later |
| Request access fails and no grant appears | The sweep for the new grant could not be scheduled, or the request failed | Check that the batch service is running, then try again |
Effect on the rest of Lattice
- Once a grant is Expired, Show password refuses it, and its database user can no longer sign in.
- Show password already refuses a grant after its Expires time, even before the sweep has run, but the database user itself keeps working until the sweep drops it.
- The sweep touches only grants and their database users. It does not affect integrations or other batch jobs.