fix(auth): Skip token refresh attempt when cluster has auth disabled - #1136
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughOAuth bootstrap skips token-provider setup when OIDC authentication is disabled and no explicit access token is supplied. Discovery failures retain provider setup. Tests cover these paths and add configuration-discovery mocks across client scenarios. ChangesOAuth authentication bootstrap
Sequence Diagram(s)sequenceDiagram
participant OAuthBootstrap
participant OIDCDiscovery
participant TokenProvider
OAuthBootstrap->>OIDCDiscovery: Discover OIDC configuration
OIDCDiscovery-->>OAuthBootstrap: Return disabled-auth configuration or error
OAuthBootstrap->>TokenProvider: Skip setup when auth is disabled without an explicit token
OAuthBootstrap->>TokenProvider: Continue setup after discovery failure
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/nemo_platform_ext/src/nemo_platform_ext/client/factory.py`:
- Around line 527-535: The guard around _ResolvedBootstrap must not interpret
_discover_oidc_client_settings exceptions as confirmed no-auth; preserve a
distinct discovery-failure state or fail bootstrap, and only return the no-auth
result when successful discovery confirms auth_enabled=False. Add a regression
test covering a discovery exception with a valid stored token, ensuring OAuth
authentication is not silently removed.
- Around line 527-535: Update the bootstrap resolution flow around the
auth-disabled guard to compute a single effective access-token override that
includes NMP_ACCESS_TOKEN and the explicit access_token value. Use this
effective token for the guard condition and downstream provider-sharing
behavior, preserving the no-auth fallback only when no effective token exists.
Restore coverage for an NMP_ACCESS_TOKEN on auth-disabled clusters.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: bfb65645-3532-4a89-9845-51791f108402
⛔ Files ignored due to path filters (2)
sdk/python/nemo-platform/src/nemo_platform/client/factory.pyis excluded by!sdk/**sdk/python/nemo-platform/tests/vendored/nemo_platform_ext/client/test_client.pyis excluded by!sdk/**
📒 Files selected for processing (2)
packages/nemo_platform_ext/src/nemo_platform_ext/client/factory.pypackages/nemo_platform_ext/tests/client/test_client.py
Signed-off-by: Jash Gulabrai <jgulabrai@nvidia.com>
Signed-off-by: Jash Gulabrai <jgulabrai@nvidia.com>
Signed-off-by: Jash Gulabrai <jgulabrai@nvidia.com>
cc923b2 to
0d668fb
Compare
|
NeMoPlatform.__init__ runs a second bootstrap via the SDK factory when create_client returns http_client=None (the no-auth path). In CI there is no local server, so the unpatched SDK factory discovery call fails, falls through to an OIDCTokenProvider with the stored token, and crashes on refresh. Patch nemo_platform.client.factory.discover_nmp_config in addition to the ext factory mock so both bootstrap passes see the same auth_enabled=False response. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Jash Gulabrai <jgulabrai@nvidia.com>
Signed-off-by: Jash Gulabrai <jgulabrai@nvidia.com>
Summary
When an
nmpconfig file contains anOAuthUserfrom a previousnemo auth loginsession, but the active cluster has auth disabled, client construction would crash with an opaqueUnsupportedProtocol: Request URL is missing an 'http://' or 'https://' protocolerror.Root cause:
_resolve_bootstrapwas building anOIDCTokenProviderwith an emptytoken_endpoint(what discovery returns for no-auth clusters) and immediately attempting a token refresh against it. The fix adds an early-return in_resolve_bootstrapto skip refreshing the token when auth is disabled.Before:
nemo setupthrows an error:After:
nemo setupdoesn't throw an error and proceeds with the setup flow.Related Issue
None.
Changes
packages/nemo_platform_ext/src/nemo_platform_ext/client/factory.py: Added guard in_resolve_bootstrap: when the cluster's discovery endpoint returnsauth_enabled=Falseand no explicitaccess_tokenwas provided, return a no-auth bootstrap instead of constructing anOIDCTokenProviderwith an empty endpoint.packages/nemo_platform_ext/tests/client/test_client.py: AddedTestCreateClientOAuthUserAuthDisabledClusterwith two regression tests. Fixed six existing tests that were relying on the accidental behavior of a failing discovery call being silently ignored - each now mocksdiscover_nmp_configto reflect a cluster that actually accepts auth. Renamedtest_env_access_token_overrides_user_auth→test_explicit_access_token_overrides_config_authto accurately describe whatcreate_clienttests (explicit param, not env var reading).Type of Change
Quality Gates
Verification
Signed-off-by:traileruv run pre-commit run -apasses, or any blocked checks are identified belowSummary by CodeRabbit
Bug Fixes
Tests