Skip to content

Added Microsoft Entra ID Support for Keyless Auth - #1778

Closed
lavaman131 wants to merge 4 commits into
openai:mainfrom
lavaman131:feat/azure-entra-id
Closed

lavaman131 wants to merge 4 commits into
openai:mainfrom
lavaman131:feat/azure-entra-id

Conversation

@lavaman131

Copy link
Copy Markdown

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:

  • Added 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]
  • Updated load_auth function to handle Azure-specific configurations, including environment variables and model provider names (codex-rs/login/src/lib.rs). [1] [2]
  • Modified relevant functions across modules (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:

  • Added documentation for configuring Microsoft Entra ID in config.md, including instructions for setting up Azure CLI and modifying the codex configuration file (codex-rs/config.md). [1] [2]
  • Introduced query parameter handling in ModelClient for Azure-specific API requirements, ensuring proper URL construction (codex-rs/core/src/client.rs). [1] [2]

Code Refactoring and Cleanup:

  • Reorganized imports in client.rs to improve readability and removed unused dependencies (codex-rs/core/src/client.rs). [1] [2]
  • Replaced synchronous file operations with asynchronous equivalents for better performance and compatibility (codex-rs/login/src/lib.rs). [1] [2]

Error Handling Improvements:

  • Enhanced error messages for missing environment variables and Azure CLI issues to guide users during setup (codex-rs/core/src/client.rs, codex-rs/login/src/lib.rs). [1] [2]
  • Added fallback mechanisms for token retrieval and caching to ensure robustness in authentication workflows (codex-rs/login/src/lib.rs).
@github-actions

github-actions Bot commented Aug 1, 2025 •

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@lavaman131

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

github-actions Bot added a commit that referenced this pull request Aug 1, 2025
Comment thread codex-rs/login/src/lib.rs
pub fn load_auth(
codex_home: &Path,
model_provider_name: &str,
env_key: &Option<String>,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is better to use Option<&str> than &Option<String>.
With Option<&str>, you can pass None directly without reference and convert Option<String> to Option<&str> by calling as_deref() method

@justinbarias

Copy link
Copy Markdown

hi @lavaman131 any news on this PR?

@vs4vijay

Copy link
Copy Markdown

much needed this!

@Manouchehri

Copy link
Copy Markdown

Bumping again, would really like this.

@etraut-openai

Copy link
Copy Markdown
Contributor

Thanks for the contribution, and apologies for the slow response. We've received many PRs, and we don't have the bandwidth on the codex team to review all of them.

We've updated our contribution guidelines to clarify that we're currently accepting contributions for bugs and security fixes, but we're not generally accepting new features at this time. We need to make sure that all new features compose well with both existing and upcoming features and fit into our roadmap. If you would like to propose a new feature, please file or upvote an enhancement request in the issue tracker. We will generally prioritize new features based on community feedback.

@github-actions github-actions Bot locked and limited conversation to collaborators Oct 29, 2025
@openai openai unlocked this conversation Oct 30, 2025
youta7 added a commit to youta7/ta-codex that referenced this pull request Nov 10, 2025
swordfish444 pushed a commit to swordfish444/codex that referenced this pull request Feb 26, 2026
@electroma

Copy link
Copy Markdown

Any chance to get it merged?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

7 participants