home / projects / meridian-iam-lab

Meridian IAM Lab

A workforce identity and access management lab for a made-up 200-person company: HR-driven joiner/mover/leaver automation, role-based access with segregation-of-duties rules, MFA and Conditional Access as code, just-in-time privileged access, access recertification and identity detections.

Case study

IAM · Entra ID · Python

Overview

Built a complete workforce IAM lab for a fictional 200-person company, designed to show how the pieces fit together and where they break. HR is the source of truth: a joiner/mover/leaver engine reconciles an HR feed against a directory snapshot, applies role-based access, enforces segregation-of-duties rules, and disables leavers with session revocation and a retention window. The same design is implemented twice — once as offline Python tooling against deterministic synthetic data, and once as PowerShell, Conditional Access policy and Sentinel KQL that deploy to a Microsoft Entra ID tenant through Microsoft Graph. Design docs, runbooks and a control mapping sit alongside the code.

Problem

Identity lifecycle work is usually the least testable part of a security programme. Joiner/mover/leaver processes live in spreadsheets and ticket queues, access accumulates because nobody removes it, and the risky edge cases — duplicate employee IDs, a truncated HR feed, a rehire, a leaver who still has an active session — are exactly the ones that are hard to rehearse in a production tenant. Without a safe environment and a known answer key, there is no way to tell whether the automation is correct or merely running.

Constraints

  • The offline half must run with no cloud account and no runtime dependencies beyond the Python standard library
  • All data must be deterministic and fictional, with no credentials anywhere in the repository
  • Automation must fail safe: bad rows are quarantined, mass terminations abort, runs are idempotent
  • Privileged access must be just in time, and Conditional Access must be deployable without locking out administrators
  • Every control needs a written rationale and a mapping to a recognised framework

Approach

The design starts from a role catalog that is the single source of truth for job titles, departments, business roles, entitlements and birthright access, with segregation-of-duties rules stored separately and evaluated at three points: role design, provisioning and review. A deterministic data generator produces the baseline and day-30 HR feeds, the application entitlement export and the answer key, seeding known defects so accuracy can be measured rather than asserted. The Python tooling then processes the feed, analyzes an access export into findings and a reviewer worksheet, and simulates remediation to a before/after comparison. For the cloud side, PowerShell scripts mirror the same group and lifecycle model against Entra ID, eight Conditional Access policies are stored as JSON and deployed report-only by default, PIM assignments and audits cover privileged roles, and eight Sentinel KQL rules map identity behaviours to MITRE ATT&CK.

Key decisions

Fail-safe controls in the lifecycle engine

Reasoning: A bulk disable caused by a malformed feed is worse than a delayed one. Invalid or duplicate rows are quarantined for human review, a 5% disable threshold trips a circuit breaker with exit code 2, a truncated feed is refused outright, and state writes are atomic with an append-only audit log. Re-running the same feed produces zero actions, which makes retries safe.

Alternatives considered:

  • Best-effort processing of malformed rows (silently provisions the wrong access)
  • Trusting the feed and relying on backups (a bulk termination still revokes every session before it is noticed)

Report-only Conditional Access with break-glass gating

Reasoning: Identity policy is the one place where a correct change can still take the company offline. Every policy is deployed in report-only mode first, and enforcement is blocked unless two break-glass accounts exist, so the rollout can be measured against real sign-in logs before it can deny anyone.

Alternatives considered:

  • Enforcing immediately after import (no evidence, no rollback path)
  • A single emergency account (one lost credential away from a lockout)

An answer key generated with the defects

Reasoning: The same generator that seeds the orphans, dormant accounts, privilege creep and SoD violations also emits the ground truth, so the analyzer can be scored exactly instead of judged by spot checks. The results state their own limitation: they show the tooling does what it was built to do, not how it copes with a genuinely messy export.

Alternatives considered:

  • Hand-written expected findings (drifts from the data as soon as it changes)
  • No baseline (no way to distinguish a missed finding from a clean export)

Tech stack

Python 3.10+uvMicrosoft Entra IDMicrosoft GraphPowerShell 7Sentinel KQLNIST 800-53ISO 27001

Result & impact

Provisioning
200 of 200 accounts from the HR feed; a second run produces 0 actions
Day-30 changes
6 joiners (3 enabled, 3 pre-boarded), 8 movers, 4 leavers disabled, 4 deleted after retention
Safety tests
3 invalid rows quarantined; mass-termination and truncated-feed tests abort with no changes
Access review
Seeded defects all found with 0 false positives; 93 findings before remediation, 0 after
Coverage
30 pytest tests, 23 business roles, 6 SoD rules, 8 Conditional Access policies, 8 KQL detections
Governance
20 controls mapped to NIST 800-53, ISO 27001:2022, SOC 2 and SOX ITGC, plus 8 runbooks

The lab demonstrates the full identity lifecycle as one reviewable system: access arrives from HR on day 0, changes safely on day 30, is recertified with a default-deny decision, and what survives is watched by detections that map to real adversary behaviour.

Learnings

  • Fail-safe automation is mostly about refusing to act: quarantine, thresholds and truncation checks prevent the failures that matter more than missed provisioning.
  • Segregation of duties has to be enforced at design and review time, not just when access is granted, or conflicts reappear through role changes.
  • A generated answer key makes detection accuracy measurable, and stating its limits honestly is more useful than a clean-looking success rate.
  • Report-only mode turns a policy change into an experiment with evidence, which is the only safe way to roll out Conditional Access.

Additional context

The repository is at github.com/wmouton/meridian-iam-lab under the MIT licence, with the setup, architecture, lifecycle rules, RBAC model, review procedure and control mapping in docs/.

CI exercises the offline half end to end, including lint, the full demo run and the lockfile check; the PowerShell, Conditional Access policies and KQL rules only receive static checks, so they need testing in a lab tenant before use. The repository contains no credentials, and every script honours -WhatIf.

All projects

Tags

#iam#entra-id#identity#detection

Related

shares a tag