Files
codex/codex-rs/login/src/oauth/mod.rs
T
smurching-oai df38cb3b2a Add device-code authorization for gateway OAuth (#59822)
## Why

Gateway sign-in needs an alternative for terminals that cannot open a browser.

## What changed

- Add optional `gateway_oauth.device_authorization_url` configuration and a `login_with_device_code` API that presents a verification URL and user code, polls for approval, and persists the resulting credentials.
- Use the configured proxy and network policy, validate verification URLs, and bound OAuth responses. Support cancellation and report denied or expired codes without exposing issuer error details.

## Testing

Add tests for successful authorization and credential persistence, unsafe verification URLs, network-policy denials, denied and expired codes, and cancellation during approval or credential storage.

GitOrigin-RevId: 96398578fb866d34929e85c04eadf468d8cd3255
2026-11-06 04:24:04 +00:00

34 lines
1.2 KiB
Rust

//! OAuth protocol operations shared by independent credential managers.
//!
//! Callers supply an HTTP client with the application's proxy and CA policy. They retain
//! ownership of credential storage, refresh scheduling, account validation, and login UX.
mod authorization;
mod client;
mod device;
mod diagnostics;
mod error;
mod pkce;
pub(crate) use authorization::AuthorizationRequest;
pub(crate) use authorization::CallbackError;
pub(crate) use authorization::CallbackParameters;
pub(crate) use authorization::build_authorization_url;
pub(crate) use authorization::generate_state;
pub(crate) use client::AuthorizationCodeGrant;
pub(crate) use client::OAuthClient;
pub(crate) use client::RefreshReason;
pub(crate) use client::RefreshTokenGrant;
pub(crate) use client::TokenEncoding;
pub(crate) use client::TokenEndpoint;
pub(crate) use device::DeviceAuthorizationError;
pub(crate) use device::DeviceAuthorizationOptions;
pub use device::OAuthDeviceCodePrompt;
pub(crate) use device::authorize_device;
pub(crate) use diagnostics::sanitize_url_for_logging;
pub(crate) use error::ErrorBodyLimit;
pub(crate) use error::OAuthError;
pub(crate) use error::TokenRejection;
pub(crate) use pkce::PkceCodes;
pub(crate) use pkce::generate_pkce;