Add GitLab CI/CD support to federated identity login. Closes #7463#7464
Open
fabianhutzli wants to merge 1 commit into
Open
Add GitLab CI/CD support to federated identity login. Closes #7463#7464fabianhutzli wants to merge 1 commit into
fabianhutzli wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Type
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 theid_tokenskeyword; 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
loginGITLAB_CIandGITLAB_OIDC_TOKENenvironment variables (populated by GitLab'sid_tokensCI/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.--appIdand--tenantto be specified explicitly for GitLab CI/CD, matching the existing requirement for Azure DevOps without a service connection.id_tokensYAML configuration and the federated credential issuer/subject requirements for GitLab.Implementation notes
src/Auth.ts(provider detection + error message) andsrc/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.AuthTypevalue needed —federatedIdentityis already provider-agnostic; this only adds a new environment-variable detection branch.docs/docs/cmd/login.mdxupdated with GitLab CI/CD example and requirements).