feat: add OAuth2 bearer token authentication support#332
Merged
Conversation
Add api_bearer_token parameter as an alternative to API key pair authentication. When a bearer token is provided, the module uses OAuth2 Bearer authentication instead of HTTP Signature, and the cryptography library is not required. This enables OIDC workload identity flows where AAP issues JWT tokens that Intersight validates as OAuth2 bearer tokens, supporting zero-trust and sovereign cloud deployments without static API keys. Changes: - Add api_bearer_token to intersight_argument_spec with env fallback - Branch IntersightModule.__init__ to skip key loading for bearer auth - Branch intersight_call to use Authorization: Bearer header - Update doc fragment with new parameter documentation - Add unit tests for bearer token auth path - Update existing broken key test for new validation flow
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.
Summary
Add
api_bearer_tokenas an alternative authentication method alongside existing API key pair authentication. When a bearer token is provided, modules useAuthorization: Bearer <token>instead of HTTP Signature auth, and thecryptographyPython library is not required.Motivation
This enables OAuth2/OIDC workload identity flows where automation platforms (e.g., Ansible Automation Platform) issue short-lived JWT tokens that Intersight validates as OAuth2 bearer tokens. This supports:
Changes
plugins/module_utils/intersight.py: Addapi_bearer_tokentointersight_argument_spec, branchIntersightModule.__init__to skip key loading for bearer auth, branchintersight_callto use Bearer authorization headerplugins/doc_fragments/intersight.py: Document newapi_bearer_tokenparameter with conditional requirement notestests/unit/test_bearer_token_auth.py: 5 new unit tests covering bearer token auth path, validation, and backward compatibilitytests/unit/test_v3_api_keys.py: Update existing test for new validation flowUsage
Backward Compatibility
api_key_id+api_private_keywork unchangedapi_key_idandapi_private_keyare now conditionally required (only whenapi_bearer_tokenis not provided)