Skip to content

feat(azure): add OIDC/Workload Identity Federation authentication support#11389

Open
mdoukan wants to merge 5 commits into
prowler-cloud:masterfrom
mdoukan:master
Open

feat(azure): add OIDC/Workload Identity Federation authentication support#11389
mdoukan wants to merge 5 commits into
prowler-cloud:masterfrom
mdoukan:master

Conversation

@mdoukan
Copy link
Copy Markdown

@mdoukan mdoukan commented May 29, 2026

Description

This PR implements Azure OIDC (Workload Identity Federation) authentication support, resolving #11386.

The Azure provider previously only supported static AZURE_CLIENT_SECRET. In production environments where static secrets are prohibited by security policy, Prowler was unusable. This PR adds a new --oidc-auth mode using short-lived JWT tokens.

Changes

  • arguments.py: Add --oidc-auth CLI flag as a new mutually exclusive authentication mode
  • exceptions.py: Add AzureOIDCTokenMissingError exception (error code 2024)
  • azure_provider.py:
    • Add oidc_auth parameter to __init__, validate_arguments, setup_session, setup_identity, test_connection
    • Add check_oidc_creds_env_vars() static method
    • Use ClientAssertionCredential with a lazy token callback (reads AZURE_FEDERATED_TOKEN, falling back to AZURE_OIDC_TOKEN)
    • Identity type reported as Service Principal (OIDC)
  • tests/providers/azure/azure_provider_test.py: Add TestAzureProviderOIDCAuth class with 7 unit tests

Usage

export AZURE_CLIENT_ID="00000000-0000-0000-0000-000000000000"
export AZURE_TENANT_ID="00000000-0000-0000-0000-000000000000"
export AZURE_FEDERATED_TOKEN="eyJra..."  # or AZURE_OIDC_TOKEN

prowler azure --oidc-auth

Notes

  • No new dependencies required — ClientAssertionCredential is already part of azure-identity
  • The existing --sp-env-auth mode is unchanged
  • Token is read lazily on each credential refresh, supporting short-lived OIDC tokens

Closes #11386

AlexanderSanin and others added 2 commits May 25, 2026 17:20
…heck

Projects covered by an organisation-level Cloud Logging sink with
includeChildren=True were incorrectly reported as FAIL because the
service only queried project-scoped sinks.

Changes:
- Add `include_children: bool = False` field to the `Sink` model so
  org/folder-level sinks can be distinguished from project-level ones.
- Add `Logging._get_org_sinks()` which fetches sinks for every
  organisation found in the scanned projects and appends them to
  `self.sinks` with `project_id="organizations/<id>"`.
- Update `logging_sink_created.execute()` to pass a project when its
  organisation has an aggregated sink with `includeChildren=True`, even
  if no project-scoped sink exists.
- Add three new test cases covering the org-level-sink PASS path, the
  no-include-children FAIL path, and the project-sink-takes-precedence
  case.
- Fix two existing MagicMock sink tests that did not set
  `include_children`, which would have caused false positives with the
  new logic.

Closes prowler-cloud#11343

Signed-off-by: Oleksandr Sanin <alexaaander.sanin@gmail.com>
…port

Implements Azure provider support for OIDC (Workload Identity Federation)
authentication, enabling Prowler to run in security-strict production
environments where static client secrets are prohibited.

Closes prowler-cloud#11386

Changes:
- Add --oidc-auth CLI flag as a new mutually exclusive authentication mode
- Add AzureOIDCTokenMissingError exception (code: 2024) for missing env vars
- Add check_oidc_creds_env_vars() static method to validate required env vars
- Add oidc_auth parameter to __init__, validate_arguments, setup_session,
  setup_identity and test_connection methods
- Use ClientAssertionCredential with a lazy token callback that reads
  AZURE_FEDERATED_TOKEN (falling back to AZURE_OIDC_TOKEN) at runtime
- Identity type reported as 'Service Principal (OIDC)' for OIDC sessions
- Add TestAzureProviderOIDCAuth test class with 7 unit tests covering
  missing env vars, token fallback, successful session setup and
  test_connection flow

Usage:
  export AZURE_CLIENT_ID="..."
  export AZURE_TENANT_ID="..."
  export AZURE_FEDERATED_TOKEN="eyJra..."  # or AZURE_OIDC_TOKEN
  prowler azure --oidc-auth
@mdoukan mdoukan requested a review from a team as a code owner May 29, 2026 09:30
@github-actions github-actions Bot added the provider/azure Issues/PRs related with the Azure provider label May 29, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 29, 2026

Conflict Markers Resolved

All conflict markers have been successfully resolved in this pull request.

@github-actions github-actions Bot added the community Opened by the Community label May 29, 2026
AlexanderSanin and others added 3 commits May 29, 2026 13:25
…tests

- Run black on logging_service.py and logging_sink_created.py to satisfy
  the sdk-code-quality CI check (collapsed single-arg call, wrapped long
  ternary).
- Add changelog entry for the logging_sink_created false-FAIL fix.
- Add two unit tests for Logging._get_org_sinks(): one verifying that
  org-level sinks are fetched when projects have an organisation, and one
  confirming nothing is added when no organisation is present. These cover
  the 10 previously uncovered lines flagged by Codecov.

Signed-off-by: Oleksandr Sanin <alexaaander.sanin@gmail.com>
# Conflicts:
#	prowler/CHANGELOG.md
@github-actions github-actions Bot added the provider/gcp Issues/PRs related with the Google Cloud Platform provider label May 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community Opened by the Community provider/azure Issues/PRs related with the Azure provider provider/gcp Issues/PRs related with the Google Cloud Platform provider

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Workload Identity Federation (OIDC) authentication for Azure provider

2 participants