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

Google Workspace Super Admin Assignment Notifier

Audits Google Workspace privileged role assignments to detect unauthorized super admin escalations and enforce zero-trust least-privilege standards.

Categories
BusinessCloud

The Google Workspace Super Administrator role grants unrestricted control over enterprise identity, emails, shared drives, device policies, and security configurations. Privilege escalation, rogue administrators, or accidental role grants can expose an enterprise to total tenant takeover. This sentinel continuously interrogates the Google Workspace Admin SDK Directory API, monitors privileged role assignments, and immediately alerts Security Operations Center (SOC) teams on Slack whenever super admin accounts exceed baseline counts.

How it works

  1. Scheduled triggering: Executes hourly at minute 0 (0 * * * *) or triggers on-demand via manual execution and security webhooks.
  2. Role assignment discovery: Queries the Google Workspace Directory API (/admin/directory/v1/customer/{customerId}/roleAssignments) using an OAuth2 service token.
  3. Privilege filtering: Filters all active role assignments matching _SUPER_ADMIN_ROLE and extracts assignee identifiers.
  4. Condition evaluation: An io.kestra.plugin.core.flow.If task evaluates whether super_admins_count exceeds max_tolerated_super_admins.
  5. Slack alert dispatch: Sends a high-priority incident payload via SlackIncomingWebhook listing active administrator IDs and counts.
  6. Audit trail logging and return: Emits operational execution logs and returns a structured compliance manifest for auditing.

Architecture diagram

flowchart TD
  A[hourly_super_admin_audit Schedule Trigger] --> B[scan_super_admin_roles Python Script]
  B --> C[check_super_admin_threshold Flowable If]
  C -- Admins > Threshold --> D[notify_slack_security_team Webhook]
  C -- Compliant Baseline --> E[log_super_admin_audit Log]
  D --> E
  E --> F[export_super_admin_manifest Return]

Use cases

  • Privilege escalation detection: Immediately detect when a compromised account or insider assigns the super administrator role to an unauthorized user.
  • Zero-trust governance: Enforce least-privilege policies by maintaining a strictly bounded count of emergency break-glass administrator accounts.
  • SOC2 compliance evidence: Maintain verifiable automated audit trails proving continuous monitoring of root-level administrative access.

Inputs

Name Type Default Description
customer_id STRING my_customer Google Workspace Directory API customer identifier, defaults to current authenticated domain.
alert_on_new_super_admin BOOL true Whether to dispatch alerts when the number of super administrators exceeds organizational baselines.
max_tolerated_super_admins INT 3 Maximum allowable count of privileged super admin assignments before triggering incident alerts.

Expected outputs

  • {{ outputs.scan_super_admin_roles.vars.total_role_assignments }}: Total number of role assignments evaluated in the Google Workspace domain.
  • {{ outputs.scan_super_admin_roles.vars.super_admins_count }}: Number of active users assigned the super admin role.
  • {{ outputs.scan_super_admin_roles.vars.super_admins_details }}: Serialized JSON list of super admin assignment records.
  • {{ outputs.export_super_admin_manifest.value }}: Structured dictionary containing the consolidated privileged access audit report.

Prerequisites

  • Outbound HTTPS network access from Kestra execution workers to admin.googleapis.com.
  • Google Cloud Service Account with domain-wide delegation and OAuth2 scope https://www.googleapis.com/auth/admin.directory.rolemanagement.readonly.
  • Incoming Slack Webhook configured for security incident alerting.

Secrets

  • GOOGLE_WORKSPACE_ADMIN_TOKEN: OAuth2 access token or bearer credential authorized to query the Google Workspace Admin SDK.
  • SLACK_WEBHOOK_URL: Slack Incoming Webhook endpoint URL used for sending security alerts.

Quick start

  1. Define GOOGLE_WORKSPACE_ADMIN_TOKEN and SLACK_WEBHOOK_URL in your Kestra Secret storage.
  2. Import this workflow into your Kestra instance under the company.security namespace.
  3. Configure max_tolerated_super_admins with your organizational policy threshold (e.g., 2 or 3).
  4. Execute a manual test run to inspect privileged role assignments and verify notification delivery.

Common pitfalls and troubleshooting

  • Domain-wide delegation setup: Service accounts require domain-wide delegation enabled in the Google Workspace Admin Console to query role assignments.
  • Customer ID resolution: Using my_customer automatically targets the Google Workspace account associated with the service account credentials; verify proper account binding if managing multiple domains.
  • Token expiration: Ensure access tokens refreshed via Google Cloud OAuth2 service credentials have valid lifespans or utilize automated token refresh wrappers.

How to extend

  • Automated role revocation: Add a task that calls the Google Workspace Directory API to automatically revoke unauthorized super admin role assignments upon detection.
  • SIEM forwarder integration: Ship audit telemetry directly into Google Chronicle, Splunk, or Datadog for centralized security event correlation.
  • Multi-tenant Google Workspace audit: Loop across multiple customer IDs using a Kestra ForEach task to audit international subsidiary domains.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.