Add explicit session revocation capability for Entra ID Leaver workflows#174
Add explicit session revocation capability for Entra ID Leaver workflows#174
Conversation
Co-authored-by: blindzero <13959569+blindzero@users.noreply.github.com>
Co-authored-by: blindzero <13959569+blindzero@users.noreply.github.com>
Co-authored-by: blindzero <13959569+blindzero@users.noreply.github.com>
Co-authored-by: blindzero <13959569+blindzero@users.noreply.github.com>
Co-authored-by: blindzero <13959569+blindzero@users.noreply.github.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6da541f4be
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Pull request overview
Adds an explicit, opt-in “revoke sign-in sessions” capability to IdLE so Leaver workflows can force sign-out/refresh-token invalidation (initially implemented for Entra ID via Microsoft Graph revokeSignInSessions), without changing the semantics of IdLE.Step.DisableIdentity.
Changes:
- Introduces a new built-in step
IdLE.Step.RevokeIdentitySessionsinIdLE.Steps.Commonand adds it to the step metadata catalog. - Extends the Entra ID provider/adapter with capability
IdLE.Identity.RevokeSessionsand aRevokeSessionsimplementation backed byPOST /users/{id}/revokeSignInSessions. - Adds tests and updates provider docs + a Leaver workflow template example to include session revocation.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Steps/Invoke-IdleStepRevokeIdentitySessions.Tests.ps1 | New Pester tests covering the built-in revoke-sessions step behavior. |
| tests/Providers/EntraIDIdentityProvider.Tests.ps1 | Adds capability assertion + tests for provider RevokeSessions behavior. |
| src/IdLE.Steps.Common/Public/Invoke-IdleStepRevokeIdentitySessions.ps1 | Implements the new provider-agnostic step handler. |
| src/IdLE.Steps.Common/Public/Get-IdleStepMetadataCatalog.ps1 | Registers required capability metadata for the new step type. |
| src/IdLE.Steps.Common/IdLE.Steps.Common.psm1 | Exports the new step function from the module. |
| src/IdLE.Steps.Common/IdLE.Steps.Common.psd1 | Adds the new step function to FunctionsToExport. |
| src/IdLE.Provider.EntraID/Public/New-IdleEntraIDIdentityProvider.ps1 | Advertises IdLE.Identity.RevokeSessions and implements provider method RevokeSessions. |
| src/IdLE.Provider.EntraID/Private/New-IdleEntraIDAdapter.ps1 | Adds adapter method RevokeSignInSessions calling Graph endpoint. |
| examples/workflows/templates/entraid-leaver-offboarding.psd1 | Updates the Leaver template to include a “RevokeActiveSessions” step. |
| docs/reference/providers/provider-entraID.md | Documents new capability and permission requirements + behavior notes. |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…ep registry entry Co-authored-by: blindzero <13959569+blindzero@users.noreply.github.com>
Co-authored-by: blindzero <13959569+blindzero@users.noreply.github.com>
Implementation Plan: Add optional session revocation for Entra ID during Leaver flows
IdLE.Identity.RevokeSessionsto Entra ID providerRevokeSignInSessionsin Entra ID adapterRevokeSessionsin Entra ID providerIdLE.Step.RevokeIdentitySessionsin IdLE.Steps.CommonSummary
Successfully implemented optional session revocation for Entra ID Leaver workflows with all feedback addressed:
Key Features
IdLE.Step.RevokeIdentitySessionsPOST /users/{id}/revokeSignInSessionsDesign Principles
Original prompt
This section details on the original issue you should resolve
<issue_title>Add optional session revocation for Entra ID during Leaver flows</issue_title>
<issue_description>## Summary
Today,
IdLE.Provider.EntraIDimplementsDisableIdentityby only settingaccountEnabled=falsevia Microsoft Graph. It does not revoke existing sign-in sessions / refresh tokens. For Leaver and security-oriented workflows this can leave active sessions running until tokens expire.Add a new, explicit and configurable Step Type to revoke sign-in sessions for an identity (initially for Entra ID), without changing the existing semantics of
IdLE.Step.DisableIdentity.Problem statement
DisableIdentitycurrently only performs:PATCH /users/{id}with payload{ accountEnabled: false }Current behavior (code evidence)
In
src/IdLE.Provider.EntraID/Public/New-IdleEntraIDIdentityProvider.ps1,DisableIdentity:accountEnabledaccountEnabled = $falseIdLE.ProviderResultwithChangedThere is no call to Graph
revokeSignInSessions, nor any adapter method that would implement it.Desired behavior
Provide a dedicated and opt-in mechanism to revoke sessions, suitable for Leaver workflows:
IdLE.Step.RevokeIdentitySessions(name can be bikeshedded, see below)POST /users/{id}/revokeSignInSessions.Important: Do not change
IdLE.Step.DisableIdentitybehavior by default. Session revocation should be explicit in the workflow.Proposed design
1) New capability
Add a new normalized capability name:
IdLE.Identity.RevokeSessionsRationale:
2) Provider contract extension (non-breaking)
Providers may implement the method:
RevokeSessions([string] $IdentityKey, [object] $AuthSession)If not implemented, the step should fail with a clear “capability not supported by provider” error (consistent with existing capability checks).
3) Entra ID provider implementation
Extend
IdLE.Provider.EntraID:RevokeSignInSessions($UserId, $AccessToken)POST {BaseUri}/users/{id}/revokeSignInSessionsRevokeSessions($IdentityKey, $AuthSession)IdLE.ProviderResultwithOperation='RevokeSessions'4) New step module implementation
In
IdLE.Steps.Common(or a suitable step module):IdLE.Step.RevokeIdentitySessionsWith.Provider(required)With.IdentityKey(required)With.AuthSessionName(optional, existing pattern)With.AuthSessionOptions(optional, existing broker routing)Providershashtable by nameIdLE.Identity.RevokeSessionsRevokeSessions(...)Changed+ details5) Workflow usage example
Leaver workflow would become:
Permissions / prerequisites
Document the required Graph permissions for session revocation (delegated/app-only), e.g.:
User.RevokeSessions.All(and/or other permissions accepted by Graph forrevokeSignInSessions), plus whatever is already required for user resolution.Notes:
Acceptance criteria
IdLE.Step.RevokeIdentitySessionsexists and is discoverable in step metadata/catalog.IdLE.Identity.RevokeSessions.💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.