Skip to content

[EDFI-2780] Enable Entra machine user - #243

Open
adiaz-msdf wants to merge 9 commits into
mainfrom
EDFI-2780_Entra_MachineUser
Open

[EDFI-2780] Enable Entra machine user#243
adiaz-msdf wants to merge 9 commits into
mainfrom
EDFI-2780_Entra_MachineUser

Conversation

@adiaz-msdf

@adiaz-msdf adiaz-msdf commented Jul 2, 2026

Copy link
Copy Markdown

Summary

This PR makes the Admin App API accept machine-to-machine (service) tokens issued by Microsoft Entra ID, alongside the Keycloak/Auth0 tokens it already supported.

  • Previously, the API's authentication guard only understood the JWT claim format that Keycloak and Auth0 produce, so a service authenticating through Entra ID was always rejected. The guard now recognizes Entra's token format as well it knows where each identity provider puts the client identifier and the permission grants, and treats them equivalently. The security rules themselves are unchanged: a machine token still must be issued for the expected audience and carry the login:app permission, and existing Keycloak logins (both human and machine) behave exactly as before.

  • The change is contained to a single file the API's authentication guard plus a new unit test suite covering Entra tokens, the Keycloak regression case, and rejection of tokens lacking the required permission.

@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown

Test Results

  5 files  ±0  152 suites  +1   3m 36s ⏱️ -1s
783 tests +5  783 ✅ +5  0 💤 ±0  0 ❌ ±0 
859 runs  +5  859 ✅ +5  0 💤 ±0  0 ❌ ±0 

Results for commit 9eabd54. ± Comparison against base commit 98f0023.

♻️ This comment has been updated with latest results.

@adiaz-msdf
adiaz-msdf requested a review from Copilot July 28, 2026 15:49
@adiaz-msdf
adiaz-msdf marked this pull request as ready for review July 28, 2026 15:50
@adiaz-msdf adiaz-msdf changed the title DRAFT [EDFI-2780] Enable Entra machine user [EDFI-2780] Enable Entra machine user Jul 28, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Admin App API’s AuthenticatedGuard to recognize Microsoft Entra ID–issued machine-to-machine JWTs in addition to the Keycloak/Auth0 formats already supported, and adds Jest unit tests for the new token shapes.

Changes:

  • Expand bearer-token claim parsing to support Entra conventions (aud array, client id via azp/appid, permissions via roles).
  • Preserve existing Keycloak/Auth0 behavior by keeping the original “explicit client_id implies machine token” signal.
  • Add a new unit test suite covering Entra machine tokens, aud as an array, Keycloak regression, and missing-permission rejection.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
packages/api/src/auth/login/authenticated.guard.ts Extends bearer JWT parsing/authorization to support Entra machine-token claim formats while keeping existing provider behavior.
packages/api/src/auth/login/authenticated.guard.spec.ts Adds unit tests validating Entra + Keycloak machine token authorization behavior and expected rejections.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/api/src/auth/login/authenticated.guard.ts
Comment thread packages/api/src/auth/login/authenticated.guard.spec.ts
Comment thread packages/api/src/auth/login/authenticated.guard.ts Outdated
adiaz-msdf and others added 2 commits July 28, 2026 11:21
- Exclude Entra delegated scp from machine login:app grant sources
- Add unit test for Entra v1.0 appid-shaped machine token
- Rename Auth0Payload to AccessTokenPayload

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants