Skip to content

Fix credential lifecycle: persist API key, add required --user to rspm#56

Merged
statik merged 1 commit intomainfrom
fix-credential-cleanup
Mar 10, 2026
Merged

Fix credential lifecycle: persist API key, add required --user to rspm#56
statik merged 1 commit intomainfrom
fix-credential-cleanup

Conversation

@ian-flores
Copy link
Copy Markdown
Collaborator

Summary

  • Remove auto-deletion of Connect API key from mint_interactive_credentials(). The key must persist in the K8s Secret for the Job to consume. Users run vip verify cleanup to delete credentials when done.
  • Add required --user flag to rspm create token — it's mandatory per the Package Manager CLI and was missing.

Refs

Refs #29

Remove auto-deletion of Connect API key from mint_interactive_credentials().
The key must persist in the K8s Secret for the Job to consume. Users
run `vip verify cleanup` to delete credentials when done.

Add required --user flag to rspm create token (it's mandatory per the
Package Manager CLI and was causing runtime failures without it).

Refs #29
@ian-flores ian-flores linked an issue Mar 10, 2026 that may be closed by this pull request
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 10, 2026

PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-03-10 23:32 UTC

@ian-flores ian-flores marked this pull request as ready for review March 10, 2026 23:21
@ian-flores ian-flores requested a review from statik as a code owner March 10, 2026 23:21
Copilot AI review requested due to automatic review settings March 10, 2026 23:21
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the VIP verify credential-minting flow so that Connect API keys persist in the Kubernetes Secret for later consumption by a K8s Job, and fixes Package Manager token creation by supplying the required --user flag.

Changes:

  • Stop auto-deleting the Connect API key during mint_interactive_credentials() so the K8s Job can consume it from the Secret.
  • Update Package Manager token generation to pass the required --user=<username> argument.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines 118 to +122
print("Minting Connect API key via interactive auth...")
auth_session = start_interactive_auth(connect_url)

try:
if not auth_session.api_key:
raise RuntimeError("Interactive auth did not produce an API key")
if not auth_session.api_key:
raise RuntimeError("Interactive auth did not produce an API key")
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

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

auth_session.cleanup() was removed, but InteractiveAuthSession.cleanup() also deletes the temporary vip-auth-* directory that contains the Playwright storage state (cookies/session data). As written, this leaves sensitive auth state on disk and also leaves the Connect API key minted if any later step fails (e.g., kubectl exec or secret save), potentially creating an untracked, long-lived key. Consider reintroducing a try/finally that always removes the temp directory, and only preserves the API key after the Secret has been successfully written (otherwise delete it on failure).

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Temp dir cleanup: intentionally left as-is. The storage state is needed for --local mode where Workbench browser tests (OIDC auth) consume it via the browser_context_args fixture. The temp dir lives in /tmp and is cleaned on reboot.

Error handling (orphaned key on partial failure): addressed in #57 by guarding against re-minting when the Secret already exists.

Comment on lines +124 to 125
print(f"Connect API key created: {auth_session.key_name}")

Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

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

start_interactive_auth() deletes any existing Connect API keys whose name contains the _vip_interactive_ prefix before creating a new key. With this PR’s new behavior of persisting the key until vip verify cleanup, a subsequent interactive-auth run can silently delete a still-needed key from a previous run. To avoid unexpected key invalidation, consider adding an option to disable orphan-key deletion (or adjust the naming/prefix / deletion criteria) for the “persist until cleanup” flow.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Good catch. Addressed in #57mint_interactive_credentials() now checks if the Secret already has credentials and returns early, preventing start_interactive_auth() from sweeping the existing key.

Copy link
Copy Markdown
Collaborator

@statik statik left a comment

Choose a reason for hiding this comment

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

thank you!

@statik statik merged commit fbf6360 into main Mar 10, 2026
14 checks passed
@statik statik deleted the fix-credential-cleanup branch March 10, 2026 23:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support credential generation for ptd verify K8s Job

3 participants