Skip to content

fix: remove tokens from local file on logout#388

Merged
mckornfield merged 1 commit into
mainfrom
address-auth-token-nvbug/mck
Jun 22, 2026
Merged

fix: remove tokens from local file on logout#388
mckornfield merged 1 commit into
mainfrom
address-auth-token-nvbug/mck

Conversation

@mckornfield

@mckornfield mckornfield commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • Bug Fixes

    • Fixed logout to clear OAuth credentials only for the selected context, leaving other contexts unchanged.
    • Improved OAuth credential handling so explicitly clearing tokens via config overrides works correctly.
  • Improvements

    • Enhanced device authorization flow handling for OAuth endpoints.
    • Refined OAuth scope parsing to handle different token claim formats more reliably.
  • Tests

    • Added coverage for logout clearing behavior and config write behavior when tokens are explicitly set to null.

@mckornfield
mckornfield requested review from a team as code owners June 22, 2026 18:17
@github-actions github-actions Bot added the fix label Jun 22, 2026
@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 4d32d0e8-40d1-4c54-8d7c-7d4838f3ee43

📥 Commits

Reviewing files that changed from the base of the PR and between 1269ab7 and d99f46f.

⛔ Files ignored due to path filters (4)
  • sdk/python/nemo-platform/src/nemo_platform/cli/commands/auth.py is excluded by !sdk/**
  • sdk/python/nemo-platform/src/nemo_platform/config/models.py is excluded by !sdk/**
  • sdk/python/nemo-platform/tests/vendored/nemo_platform_ext/cli/commands/test_auth.py is excluded by !sdk/**
  • sdk/python/nemo-platform/tests/vendored/nemo_platform_ext/config/test_config.py is excluded by !sdk/**
📒 Files selected for processing (4)
  • packages/nemo_platform_ext/src/nemo_platform_ext/cli/commands/auth.py
  • packages/nemo_platform_ext/src/nemo_platform_ext/config/models.py
  • packages/nemo_platform_ext/tests/cli/commands/test_auth.py
  • packages/nemo_platform_ext/tests/config/test_config.py
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/nemo_platform_ext/src/nemo_platform_ext/cli/commands/auth.py
  • packages/nemo_platform_ext/src/nemo_platform_ext/config/models.py

📝 Walkthrough

Walkthrough

ConfigParams.access_token and refresh_token are changed to str | None. ConfigFile.ensure_context is reworked to distinguish explicit None from omission, replacing the user with OAuthUser/NoAuthUser accordingly. Auth CLI removes cast calls and improves scope claim parsing. Tests cover credential clearing and preservation.

Changes

OAuth credential clearing

Layer / File(s) Summary
Nullable ConfigParams fields and ensure_context logic
packages/nemo_platform_ext/src/nemo_platform_ext/config/models.py
access_token and refresh_token typed as str | None; ensure_context tracks explicit provision of each field and branches to OAuthUser, NoAuthUser, or refresh_token update/clear accordingly.
Auth CLI cleanup and scope extraction
packages/nemo_platform_ext/src/nemo_platform_ext/cli/commands/auth.py
Drops cast for device_authorization_endpoint and logout_params; granted-scope parsing now handles both string (split) and list (filter) claim shapes.
Tests for credential clearing and preservation
packages/nemo_platform_ext/tests/config/test_config.py, packages/nemo_platform_ext/tests/cli/commands/test_auth.py
Config tests assert access_token=None persists no-auth user and that omitting access_token preserves existing token. CLI test asserts auth logout --context foo clears only the targeted context.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 77.78% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed Title accurately describes the main change: implementing token removal from local config file during logout operation across multiple components.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch address-auth-token-nvbug/mck

Comment @coderabbitai help to get the list of available commands and usage tips.

@anastasia-nesterenko anastasia-nesterenko left a comment

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.

👏

@github-actions

github-actions Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor
Suite Lines Covered Line Rate Branch Rate
Unit Tests 20042/26517 75.6% 60.9%
Integration Tests 11694/25286 46.2% 19.8%

Signed-off-by: Matt Kornfield <mkornfield@nvidia.com>
@mckornfield
mckornfield force-pushed the address-auth-token-nvbug/mck branch from 1269ab7 to d99f46f Compare June 22, 2026 18:47
@mckornfield
mckornfield added this pull request to the merge queue Jun 22, 2026
Merged via the queue into main with commit 9a8c85d Jun 22, 2026
53 checks passed
@mckornfield
mckornfield deleted the address-auth-token-nvbug/mck branch June 22, 2026 19:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants