You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adds credential providers for three OAuth 2.0 authentication modes used with an external OIDC provider:
an access token supplied by the application and sent using the Bearer scheme;
Client Credentials Grant;
Device Authorization Grant with polling and refresh-token support.
Client Credentials and Device Authorization obtain their endpoints from the issuer OIDC configuration. Both synchronous and asynchronous implementations are included.
The change also adds documentation, a usage example, and a self-contained Docker Compose environment with YDB and Keycloak for exercising all three modes.
Adds synchronous and asynchronous OIDC credential providers, including token acquisition, refresh, documentation, tests, and a local Keycloak environment.
Changes:
Adds static-token, Client Credentials, and Device Authorization providers.
Adds unit and end-to-end smoke-test coverage.
Adds user documentation, an example, and release notes.
File
Description
ydb/oidc/credentials.py
Implements synchronous providers.
ydb/oidc/_common.py
Provides shared OAuth processing and validation.
ydb/oidc/__init__.py
Exports the public OIDC API.
ydb/aio/oidc.py
Implements asynchronous providers.
ydb/__init__.py
Adds lazy OIDC module loading.
tests/oidc/ydb.yaml
Configures YDB external IdP authentication.
tests/oidc/static_token_smoke.py
Exercises static-token authentication.
tests/oidc/README.md
Documents the local test environment.
tests/oidc/prepare.sh
Generates certificates, secrets, and realm configuration.
Handle case-insensitive HTTPS when applying CA context
ydb/aio/oidc.py:35
HTTPS schemes are case-insensitive, and _is_https_url accepts values such as HTTPS://issuer.example, but this case-sensitive check then omits the configured CA context. Such valid issuer or discovered endpoint URLs fail against private/self-signed CAs in the async provider while the sync provider works.
This issue also appears in the following locations of the same file:
Any positive expires_in is accepted here, but the inherited cache subtracts a fixed 30-second safety window (ydb/credentials.py:102-105). Tokens with a standards-valid lifetime of 30 seconds or less are therefore never considered valid, causing every RPC to request another token and eventually hit IdP throttling. Clamp the safety margin relative to the reported lifetime (with corresponding sync/async tests).
This issue also appears on line 174 of the same file.
Cache token timestamp after synchronous token request
ydb/oidc/credentials.py:200
AbstractExpiringTokenCredentials._refresh_token records current_time before calling this method and later uses that old value to cache the returned token (ydb/credentials.py:108-114). A device flow can spend minutes waiting for the user, so a freshly issued token may be considered expired immediately (and, if no refresh token was returned, the next RPC starts another user interaction). Timestamp the cache after the token request completes; apply the equivalent correction to the async base as well.
The reason will be displayed to describe this comment to others. Learn more.
Copilot review overview
🔵 Needs a closer look
Three moderate issues remain in async session reuse, refresh-audience preservation, and issuer validation.
Review effort: Lite Findings: None
This branch has not been deployed
No deployments
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
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.
Related to #876.
Adds credential providers for three OAuth 2.0 authentication modes used with an external OIDC provider:
Client Credentials and Device Authorization obtain their endpoints from the issuer OIDC configuration. Both synchronous and asynchronous implementations are included.
The change also adds documentation, a usage example, and a self-contained Docker Compose environment with YDB and Keycloak for exercising all three modes.