Skip to content
Merged
4 changes: 0 additions & 4 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ Key configuration values:
- `gateway_url`: Tiger Gateway URL
- `docs_mcp`: Enable/disable proxied docs MCP tools
- `docs_mcp_url`: URL for docs MCP server
- `project_id`: Default project ID
- `service_id`: Default service ID
- `output`: Output format (json, yaml, table)
- `analytics`: Usage analytics toggle
Expand Down Expand Up @@ -271,7 +270,6 @@ Global flags available on all commands:
- `--config-dir`: Path to configuration directory
- `--debug`: Enable debug logging
- `--output/-o`: Set output format
- `--project-id`: Override project ID
- `--service-id`: Override service ID
- `--analytics`: Toggle analytics
- `--password-storage`: Password storage method
Expand Down Expand Up @@ -405,7 +403,6 @@ func buildRootCmd() *cobra.Command {
// Declare ALL flag variables locally within this function
var configDir string
var debug bool
var projectID string
var serviceID string
var analytics bool
var passwordStorage string
Expand All @@ -428,7 +425,6 @@ func buildRootCmd() *cobra.Command {
cobra.OnInitialize(initConfigFunc)
cmd.PersistentFlags().StringVar(&configDir, "config-dir", config.GetDefaultConfigDir(), "config directory")
cmd.PersistentFlags().BoolVar(&debug, "debug", false, "enable debug logging")
cmd.PersistentFlags().StringVar(&projectID, "project-id", "", "project ID")
cmd.PersistentFlags().StringVar(&serviceID, "service-id", "", "service ID")
cmd.PersistentFlags().BoolVar(&analytics, "analytics", true, "enable/disable usage analytics")
cmd.PersistentFlags().StringVar(&passwordStorage, "password-storage", config.DefaultPasswordStorage, "password storage method (keyring, pgpass, none)")
Expand Down
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Tiger CLI provides the following commands:
- `tiger auth` - Authentication management
- `login` - Log in to your Tiger account
- `logout` - Log out from your Tiger account
- `status` - Show current authentication status
- `status` - Show current authentication status and project ID
- `tiger service` - Service lifecycle management
- `list` - List all services
- `create` - Create a new service
Expand Down Expand Up @@ -211,7 +211,6 @@ tiger config reset
All configuration options can be set via `tiger config set <key> <value>`:

- `docs_mcp` - Enable/disable docs MCP proxy (default: `true`)
- `project_id` - Default project ID (set via `tiger auth login`)
- `service_id` - Default service ID
- `output` - Output format: `json`, `yaml`, or `table` (default: `table`)
- `analytics` - Enable/disable analytics (default: `true`)
Expand All @@ -224,7 +223,6 @@ Environment variables override configuration file values. All variables use the

- `TIGER_CONFIG_DIR` - Path to configuration directory (default: `~/.config/tiger`)
- `TIGER_DOCS_MCP` - Enable/disable docs MCP proxy
- `TIGER_PROJECT_ID` - Default project ID
- `TIGER_SERVICE_ID` - Default service ID
- `TIGER_OUTPUT` - Output format: `json`, `yaml`, or `table`
- `TIGER_ANALYTICS` - Enable/disable analytics
Expand All @@ -238,7 +236,6 @@ Environment variables override configuration file values. All variables use the
These flags are available on all commands and take precedence over both environment variables and configuration file values:

- `--config-dir <path>` - Path to configuration directory (default: `~/.config/tiger`)
- `--project-id <id>` - Specify project ID
- `--service-id <id>` - Specify service ID
- `--analytics` - Enable/disable analytics
- `--password-storage <method>` - Password storage method: `keyring`, `pgpass`, or `none`
Expand Down
36 changes: 11 additions & 25 deletions internal/tiger/cmd/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,17 +126,11 @@ Examples:
return fmt.Errorf("API key validation failed: %w", err)
}

// Store the API key securely
if err := config.StoreAPIKey(apiKey); err != nil {
return fmt.Errorf("failed to store API key: %w", err)
// Store the credentials (API key + project ID) together securely
if err := config.StoreCredentials(apiKey, creds.projectID); err != nil {
return fmt.Errorf("failed to store credentials: %w", err)
}
fmt.Fprintln(cmd.OutOrStdout(), "Successfully logged in and stored API key")

// Store project ID in config if provided
if err := storeProjectID(creds.projectID); err != nil {
return fmt.Errorf("failed to store project ID: %w", err)
}
fmt.Fprintf(cmd.OutOrStdout(), "Set default project ID to: %s\n", creds.projectID)
fmt.Fprintf(cmd.OutOrStdout(), "Successfully logged in (project: %s)\n", creds.projectID)

// Show helpful next steps
fmt.Fprint(cmd.OutOrStdout(), nextStepsMessage)
Expand All @@ -161,8 +155,8 @@ func buildLogoutCmd() *cobra.Command {
RunE: func(cmd *cobra.Command, args []string) error {
cmd.SilenceUsage = true

if err := config.RemoveAPIKey(); err != nil {
return fmt.Errorf("failed to remove API key: %w", err)
if err := config.RemoveCredentials(); err != nil {
return fmt.Errorf("failed to remove credentials: %w", err)
}

fmt.Fprintln(cmd.OutOrStdout(), "Successfully logged out and removed stored credentials")
Expand All @@ -174,17 +168,19 @@ func buildLogoutCmd() *cobra.Command {
func buildStatusCmd() *cobra.Command {
return &cobra.Command{
Use: "status",
Short: "Show current auth information",
Long: `Show information about the currently authenticated token.`,
Short: "Show current authentication status and project ID",
Long: "Displays whether you are logged in and shows your currently configured project ID.",
RunE: func(cmd *cobra.Command, args []string) error {
cmd.SilenceUsage = true

if _, err := config.GetAPIKey(); err != nil {
_, projectID, err := config.GetCredentials()
if err != nil {
return err
}

// TODO: Make API call to get token information
fmt.Fprintln(cmd.OutOrStdout(), "Logged in (API key stored)")
fmt.Fprintf(cmd.OutOrStdout(), "Project ID: %s\n", projectID)

return nil
},
Expand Down Expand Up @@ -256,13 +252,3 @@ func promptForCredentials(consoleURL string, creds credentials) (credentials, er

return creds, nil
}

// storeProjectID stores the project ID in the configuration file
func storeProjectID(projectID string) error {
cfg, err := config.Load()
if err != nil {
return fmt.Errorf("failed to load config: %w", err)
}

return cfg.Set("project_id", projectID)
}
Loading