Added Microsoft Entra ID Support for Keyless Auth #1778
+213
−22
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.
Problem
This PR introduces support for Microsoft Entra ID as a keyless authentication method for Azure OpenAI, refactors token handling, and enhances configuration and error management across multiple modules. The changes primarily focus on enabling seamless integration with Azure services, improving token caching mechanisms, and updating the authentication logic. It follows up on some of @thegovind's work [#769, #92] adding support for Azure OpenAI, but now in the new Rust API and without introducing any new dependencies to the project.
Why?
Many companies have API keys disabled (Microsoft is one example) for security reasons preventing access to
codex
. This would allow for more developers to be able to use the CLI.Changes
Support for Microsoft Entra ID and Azure OpenAI Integration:
AuthMode::MicrosoftEntraID
to support keyless authentication via Microsoft Entra ID. Updated token retrieval logic to use Azure CLI for fetching access tokens and implemented caching with expiration checks (codex-rs/login/src/lib.rs
). [1] [2]load_auth
function to handle Azure-specific configurations, including environment variables and model provider names (codex-rs/login/src/lib.rs
). [1] [2]run_login_status
,run_main
,init_codex
, etc.) to pass model provider details for authentication (codex-rs/cli/src/login.rs
,codex-rs/cli/src/proto.rs
,codex-rs/core/src/codex_wrapper.rs
,codex-rs/tui/src/lib.rs
). [1] [2] [3] [4]Configuration Enhancements:
config.md
, including instructions for setting up Azure CLI and modifying thecodex
configuration file (codex-rs/config.md
). [1] [2]ModelClient
for Azure-specific API requirements, ensuring proper URL construction (codex-rs/core/src/client.rs
). [1] [2]Code Refactoring and Cleanup:
client.rs
to improve readability and removed unused dependencies (codex-rs/core/src/client.rs
). [1] [2]codex-rs/login/src/lib.rs
). [1] [2]Error Handling Improvements:
codex-rs/core/src/client.rs
,codex-rs/login/src/lib.rs
). [1] [2]codex-rs/login/src/lib.rs
).