Skip to content

Conversation

owenrumney
Copy link
Collaborator

Signed-off-by: Owen Rumney owen.rumney@aquasec.com

@owenrumney owenrumney requested a review from Copilot May 21, 2025 11:57
@owenrumney owenrumney self-assigned this May 21, 2025
Copy link
Contributor

@Copilot 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 refactors the authentication signup flow by updating command structures, credential management, and token generation.

  • Changed the LoginOptions.ToAquaCreds function to return a pointer instead of a value.
  • Introduced new subcommands (login, logout, status, token) with refined behavior and descriptions.
  • Consolidated credentials storage into a unified JSON structure in the keyring and enhanced JWT token handling.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pkg/flag/options.go Updated ToAquaCreds signature to return a pointer to credentials.
pkg/commands/auth.go Refactored auth command structure and introduced multiple subcommands; note an incorrect long description in the status command.
internal/creds/verify.go Added GenerateToken and improved JWT error handling.
internal/creds/aqua_test.go Added tests ensuring proper saving, loading, and clearing of credentials.
internal/creds/aqua.go Consolidated credential storage to a single key using JSON encoding.
Comments suppressed due to low confidence (2)

pkg/flag/options.go:23

  • Changing ToAquaCreds to return a pointer instead of a value is a breaking change; ensure that all consumers of this function are updated accordingly.
func (o *LoginOptions) ToAquaCreds() *creds.AquaCreds {

internal/creds/aqua.go:37

  • Consolidating credential storage into the 'aqua-creds' key simplifies management but consider a migration strategy or clear documentation for users with existing stored credentials.
if err := keyring.Delete("trivy-mcp-aqua", "aqua-creds"); err != nil && err != keyring.ErrNotFound {

Signed-off-by: Owen Rumney <owen.rumney@aquasec.com>
@owenrumney owenrumney force-pushed the chore/refactor-auth-signup branch from 3b08e3c to 02e62a9 Compare May 21, 2025 12:06
Signed-off-by: Owen Rumney <owen.rumney@aquasec.com>
@owenrumney owenrumney requested a review from Copilot May 21, 2025 12:12
Copy link
Contributor

@Copilot 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 refactors the authentication flow for the Aqua signup by converting credential handling to a JSON-based keyring store, restructuring the CLI commands, and introducing token generation.

  • Changed ToAquaCreds to return a pointer and updated callers
  • Split the auth command into login, logout, status, and token subcommands with interactive input
  • Switched keyring storage to a single JSON blob, added GenerateToken, and improved JWT decoding
  • Added unit tests for credential save, load, and clear

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
pkg/flag/options.go Updated ToAquaCreds signature to return *creds.AquaCreds
pkg/commands/auth.go Broke out subcommands, new input helpers, and keyring integration
internal/creds/verify.go Added GenerateToken, enhanced JWT decoding and error wrapping
internal/creds/aqua.go Merged credential fields into JSON, added Token/ExpiresAt
internal/creds/aqua_test.go Tests for Save, Load, and Clear credential operations
Comments suppressed due to low confidence (4)

internal/creds/verify.go:34

  • The new GenerateToken method and JWT decoding logic are not covered by existing tests. Consider adding unit tests for GenerateToken, Verify, and decodeJWT to ensure correct behavior.
func (c *AquaCreds) GenerateToken() (string, error) {

pkg/commands/auth.go:161

  • The code uses fmt.Print but the fmt package is not imported, which will cause a compile error. Please add import "fmt".
fmt.Print(title)

pkg/commands/auth.go:164

  • The code references syscall.Stdin but the syscall package is not imported. Please add import "syscall".
readIn, err := term.ReadPassword(int(syscall.Stdin))

pkg/commands/auth.go:72

  • The code calls creds.Clear() and other creds methods but the creds package is not imported. Please add the appropriate import (e.g., github.com/aquasecurity/trivy-mcp/internal/creds).
if err := creds.Clear(); err != nil {

@owenrumney owenrumney merged commit 0bfece5 into main May 21, 2025
3 checks passed
@owenrumney owenrumney deleted the chore/refactor-auth-signup branch May 21, 2025 12:24
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.

1 participant