Skip to content

Just-In-Time Access

Manage temporary elevated access for policy-restricted operations with time-limited grants.

Overview

Just-In-Time (JIT) access is a mechanism that grants temporary, time-limited access privileges for operations restricted by the policy engine. When an operator requests elevated access and an administrator approves it, operations with the specified role are permitted only for the designated period.

plaintext
Operator → access request → [pending]
                              ↓ (admin approves)
                            [approved] → ExpiresAt set
                              ↓ (expiration)
                            [expired]

Workflow

1

Request Access

bash
nefia access request \
  --role admin \
  --hosts "prod-*" \
  --duration 1h \
  --reason "deploy hotfix"
FlagDescriptionDefault
--roleRole name to request(required)
--hostsHost pattern (glob)(required)
--durationValidity period1h (configurable)
--reasonReason for the request(optional; can be made required in config)
2

View Request List

bash
nefia access list
nefia access list --status pending
StatusDescription
pendingAwaiting approval
approvedApproved (active)
deniedDenied
expiredExpired
revokedManually revoked
3

Approve

bash
nefia access approve <request-id>

Once approved, ExpiresAt is set, and operations with the specified role and host pattern are permitted until that time.

4

Deny

bash
nefia access deny <request-id> --reason "production access not needed"
5

Revoke

To revoke privileges before expiration:

bash
nefia access revoke <request-id>

Integration with the Policy Engine

JIT works in conjunction with the policy engine:

  1. The policy engine evaluates at command execution time
  2. The policy denies the operation
  3. The JIT manager checks for active grants
  4. If a valid grant exists, the operation is permitted (JITGranted = true)

Host pattern matching follows filepath.Match semantics:

  • prod-* — all hosts starting with prod-
  • web-?? — hosts with two characters following web-
  • * — all hosts

Configuration

yaml
jit:
  enabled: true
  default_duration: 1h      # Default validity period
  max_duration: 8h           # Maximum validity period
  require_reason: false      # Require a reason
  webhook_name: ""           # Webhook name for JIT event notifications

Auditing and Notifications

All JIT operations are recorded in the audit log:

OperationAudit Type
Request createdOpJITRequest
ApprovedOpJITApprove
DeniedOpJITDeny
RevokedOpJITRevoke

When a webhook is configured, notifications are sent for each event.

Caching

The JIT manager caches grants in memory for 30 seconds for performance. The cache can be manually refreshed with InvalidateCache().

Storage

Grants are persisted in JSONL format at <state-dir>/jit/requests.jsonl. File locking ensures safe concurrent access from multiple CLI processes.