Script icon
Process icon
If icon
SlackIncomingWebhook icon
Log icon
Return icon
Schedule icon

Okta Inactive User Deprovisioning Guard

Audits active Okta user accounts to detect dormant accounts exceeding inactivity thresholds, reducing SaaS license waste and security exposure.

Categories
BusinessCloud

Enterprise Identity and Access Management (IAM) teams must maintain strict lifecycle governance over active workforce identities. Orphaned or dormant accounts belonging to departed employees, temporary contractors, or inactive consultants represent both a significant security attack surface and unnecessary SaaS licensing expenditure. This workflow continuously inspects active Okta accounts, flags users who have not logged in within the configured threshold, and alerts IAM security teams to prompt deprovisioning.

How it works

  1. Scheduled triggering: Executes every Monday at 09:00 UTC using a cron schedule trigger (0 9 * * 1) or triggers on-demand via manual execution.
  2. User enumeration: Interrogates the Okta Users API (/api/v1/users?filter=status eq "ACTIVE") using SSWS administrative tokens.
  3. Inactivity inspection: Evaluates .lastLogin timestamps against the current UTC date, falling back to account creation dates for users who have never logged in.
  4. Condition evaluation: An io.kestra.plugin.core.flow.If task evaluates whether inactive_users_count exceeds max_tolerated_inactive_users.
  5. Slack notification: Sends a structured report via SlackIncomingWebhook listing email addresses, user IDs, and elapsed dormant days.
  6. Audit logging and manifest export: Logs summary metrics and returns a structured JSON payload for compliance and audit trail records.

Architecture diagram

flowchart TD
  A[weekly_okta_audit Schedule Trigger] --> B[scan_okta_inactive_users Python Script]
  B --> C[check_inactive_accounts Flowable If]
  C -- Dormant > Tolerance --> D[notify_slack_identity_team Webhook]
  C -- Clean Directory --> E[log_okta_audit_status Log]
  D --> E
  E --> F[export_okta_manifest Return]

Use cases

  • Identity security posture: Eliminate lingering account credentials and reduce exposure to credential stuffing and session hijacking.
  • SaaS license cost optimization: Reclaim expensive Okta, Microsoft 365, and Google Workspace enterprise seats assigned to inactive users.
  • Regulatory compliance audits: Automate evidence generation for SOC2, ISO 27001, and HIPAA identity lifecycle deprovisioning requirements.

Inputs

Name Type Default Description
okta_org_url STRING https://dev-example.okta.com Base domain URL for the target Okta identity management tenant.
inactivity_threshold_days INT 90 Threshold of days without login before an active account is flagged for deprovisioning.
alert_on_inactive_users BOOL true Whether to dispatch alerts when dormant active user accounts are identified.
max_tolerated_inactive_users INT 5 Maximum allowable count of dormant users before triggering an escalation alert.

Expected outputs

  • {{ outputs.scan_okta_inactive_users.vars.total_active_users_audited }}: Number of active Okta users scanned during the audit.
  • {{ outputs.scan_okta_inactive_users.vars.inactive_users_count }}: Number of active accounts exceeding the dormancy threshold.
  • {{ outputs.scan_okta_inactive_users.vars.inactive_users_details }}: Serialized JSON list of dormant accounts with emails and elapsed days.
  • {{ outputs.export_okta_manifest.value }}: Structured dictionary containing the consolidated tenant audit summary.

Prerequisites

  • Outbound HTTPS network access from Kestra workers to the Okta tenant domain.
  • Okta API token (SSWS token) with okta.users.read or Read-Only Administrator role privileges.
  • Slack Incoming Webhook configured for IAM team notifications.

Secrets

  • OKTA_API_TOKEN: Okta administrative API token used for SSWS authentication.
  • SLACK_WEBHOOK_URL: Slack Incoming Webhook URL used for dispatching alert messages.

Quick start

  1. Define OKTA_API_TOKEN and SLACK_WEBHOOK_URL in your Kestra Secret storage.
  2. Deploy this flow under the company.security namespace.
  3. Configure okta_org_url with your company Okta tenant URL (e.g., https://mycompany.okta.com).
  4. Execute a manual run to audit dormant accounts and verify Slack notifications.

Common pitfalls and troubleshooting

  • Service account exemptions: Service accounts and automated bots may not log in via standard web sessions. Ensure service accounts are tagged or excluded by naming conventions.
  • Pagination handling: In large organizations with thousands of employees, use the Okta pagination link header (rel="next") to traverse the full directory.
  • Token permissions: Ensure the API token has sufficient permissions to read user profiles without encountering HTTP 403 Forbidden.

How to extend

  • Automated suspension: Add a Kestra task that issues a POST /api/v1/users/{id}/lifecycle/suspend request to automatically suspend confirmed dormant accounts.
  • Manager verification workflow: Dispatch an interactive Slack approval message to the user's direct manager before executing deprovisioning.
  • HRIS cross-referencing: Cross-reference active Okta users against Workday or BambooHR employee directories to identify unannounced employee terminations.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.