Skip to content

Add GitLab CI/CD support to federated identity login. Closes #7463#7464

Open
fabianhutzli wants to merge 1 commit into
pnp:mainfrom
fabianhutzli:feature/gitlab-federated-identity
Open

Add GitLab CI/CD support to federated identity login. Closes #7463#7464
fabianhutzli wants to merge 1 commit into
pnp:mainfrom
fabianhutzli:feature/gitlab-federated-identity

Conversation

@fabianhutzli

Copy link
Copy Markdown

Type

  • Bug Fix
  • New Feature
  • Sample

Summary

Closes #7463

Adds GitLab CI/CD support to m365 login --authType federatedIdentity, alongside the existing GitHub Actions and Azure DevOps support. GitLab CI/CD jobs can request an OIDC ID token via the id_tokens keyword; this token is exchanged for an Entra ID access token via the CLI's existing federated token exchange, with no change needed to the exchange logic itself.

This mirrors the equivalent feature already shipped in PnP PowerShell: pnp/powershell#5395

Changes

login

  • New GitLab CI/CD branch in the federated identity flow: detects GITLAB_CI and GITLAB_OIDC_TOKEN environment variables (populated by GitLab's id_tokens CI/CD keyword) and exchanges the OIDC token for an Entra ID access token via the existing federated token exchange — no extra HTTP round-trip needed, since GitLab injects the signed JWT directly into the job variable.
  • Requires --appId and --tenant to be specified explicitly for GitLab CI/CD, matching the existing requirement for Azure DevOps without a service connection.
  • Documentation updated with the required id_tokens YAML configuration and the federated credential issuer/subject requirements for GitLab.

Implementation notes

  • All changes are in src/Auth.ts (provider detection + error message) and src/Auth.spec.ts (3 new tests covering the success path and both validation failures), following the exact pattern already used for GitHub Actions/Azure DevOps in the same file.
  • No new AuthType value needed — federatedIdentity is already provider-agnostic; this only adds a new environment-variable detection branch.
  • Documentation included (docs/docs/cmd/login.mdx updated with GitLab CI/CD example and requirements).
  • Developed with AI assistance
  • Tested (verified end-to-end against a real GitLab CI/CD pipeline with federated login succeeding)

Detects GitLab CI via GITLAB_CI and GITLAB_OIDC_TOKEN (populated by the
id_tokens block in .gitlab-ci.yml) and exchanges that OIDC token for an
Entra ID access token via the existing federated token exchange, alongside
the current GitHub Actions and Azure DevOps support.
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.

Enhancement: Add GitLab CI/CD support to federated identity login

1 participant