Skip to content

Add GitLab CI/CD support to Connect-PnPOnline -FederatedIdentity#5395

Merged
gautamdsheth merged 1 commit into
pnp:devfrom
fabianhutzli:feature/gitlab-federated-identity
Jul 14, 2026
Merged

Add GitLab CI/CD support to Connect-PnPOnline -FederatedIdentity#5395
gautamdsheth merged 1 commit into
pnp:devfrom
fabianhutzli:feature/gitlab-federated-identity

Conversation

@fabianhutzli

Copy link
Copy Markdown
Contributor

Type

  • Bug Fix
  • New Feature
  • Sample

Summary

Extends Connect-PnPOnline -FederatedIdentity to support GitLab CI/CD pipelines, alongside the existing GitHub Actions and Azure DevOps support. This lets users authenticate to SharePoint/Microsoft Graph from a GitLab pipeline using GitLab's OIDC id_tokens feature and a federated credential trust on the Entra ID app registration, without needing to store a client secret or certificate in GitLab.

Modified cmdlets

  • Connect-PnPOnline — no parameter changes. The existing -FederatedIdentity switch parameter set now also recognizes a GitLab CI/CD context. As with GitHub Actions, -ClientId and -Tenant must be supplied explicitly (GitLab has no equivalent of Azure DevOps' service-connection auto-lookup).

Implementation notes

  • TokenHandler.GetFederatedIdentityTokenAsync gains a third detection branch, alongside the existing GitHub Actions (ACTIONS_ID_TOKEN_REQUEST_URL/ACTIONS_ID_TOKEN_REQUEST_TOKEN) and Azure DevOps (SYSTEM_OIDCREQUESTURI) branches. GitLab CI is detected via the GITLAB_CI environment variable combined with the presence of GITLAB_OIDC_TOKEN.
  • Unlike GitHub Actions and Azure DevOps, no HTTP round-trip is required to obtain GitLab's own OIDC token: GitLab's id_tokens pipeline feature mints the JWT directly into the configured job variable at job start. The pipeline must define it under that exact name:
    id_tokens:
      GITLAB_OIDC_TOKEN:
        aud: api://AzureADTokenExchange
  • Documentation included
  • Developed with AI assistance
  • Tested in GitLab CI

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.
@gautamdsheth gautamdsheth merged commit 9362ae1 into pnp:dev Jul 14, 2026
5 checks passed
@gautamdsheth

Copy link
Copy Markdown
Collaborator

Thanks @fabianhutzli , awesome stuff . It has been merged , much appreciated !!

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.

2 participants