EDM-5200: use OIDC password grant in api_module and imagebuilder_module - #67
Merged
Conversation
api_module.py::set_auth() and imagebuilder_module.py::_set_auth_headers() still built HTTP Basic Auth headers from username/password, so every module built on FlightctlAPIModule (and the image builder modules) failed to authenticate against OIDC-only Flight Control servers -- the same bug already fixed for the inventory plugin in EDM-4977. Extract the OIDC discovery + password-grant flow into a shared helper plugins/module_utils/oidc_auth.py and switch both modules to it: when username/password are given (and no token), perform the grant and send a Bearer token. No code path sends Basic Auth anymore. The inventory plugin's _oidc_password_grant() now delegates to the same helper, removing the duplicated auth logic. Tests: new test_oidc_auth.py covers the shared helper; api/imagebuilder tests assert Bearer-not-Basic and base-host stripping with regression guards; inventory OIDC tests re-point the open_url patch to the shared module. Full unit suite: 249 passed. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
EfratIfergan
marked this pull request as ready for review
August 24, 2026 09:19
SiddarthR56
approved these changes
Aug 26, 2026
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.
EDM-5200: OIDC password grant in api_module.py / imagebuilder_module.py
Problem
The inventory plugin was fixed in PR #62 (EDM-4977) to use the OIDC password
grant instead of HTTP Basic Auth, but the same
username/password→ Basic Authpattern still existed in the shared module utilities:
plugins/module_utils/api_module.py::set_auth()built anAuthorization: Basic <base64>header directly.plugins/module_utils/imagebuilder_module.py::_set_auth_headers()did the same.As a result, every module built on
FlightctlAPIModule(flightctl_resource,flightctl_resource_info,flightctl_certificate_management,flightctl_enrollment_config_info) and the image builder modules authenticatedwith Basic Auth against OIDC-only Flight Control servers and failed.
Fix
Extract the OIDC discovery + password-grant logic into a shared helper and have
the module utilities use it:
plugins/module_utils/oidc_auth.py—fetch_auth_config(),select_oidc_provider(),oidc_password_grant()(behavior identical to theinventory plugin's OIDC flow from EDM-4977).
api_module.py::set_auth()andimagebuilder_module.py::_set_auth_headers()—when
username/passwordare given (and no token), perform the OIDC passwordgrant and send a
Bearertoken. No code path emits Basic Auth.Behavior change
username/passwordnow triggers an OIDC password grant rather than Basic Auth.This is intentional and matches the inventory plugin (EDM-4977) — it fixes auth
against OIDC-only servers.
Known considerations
flightctl_hostpointing at the image-builder service, so OIDC discovery targets<image-builder-host>/api/v1/auth/config. This assumes that host serves (or isfronted by the same gateway that serves) the Flight Control auth config endpoint
— the common single-gateway deployment model. Please confirm this holds for your
image-builder deployment topology.
Tests
tests/unit/plugins/module_utils/test_oidc_auth.pycovers the shared helper(provider selection, discovery, password-grant payload, error paths, ca_path
propagation).
test_api_module.py/test_imagebuilder_module.pyupdated: Bearer token on thewire, base-host stripping, and regression guards that no Basic Auth is ever sent.
Rollback
Revert this commit. The change is isolated to
plugins/module_utils/oidc_auth.py(new),
api_module.py,imagebuilder_module.py, and their unit tests.🤖 Generated with Claude Code