Skip to content

Conversation

yayami3
Copy link

@yayami3 yayami3 commented Oct 17, 2025

Add authentication default settings support

Summary

This PR provides a comprehensive solution to issue #654 by adding configurable default authentication settings that eliminate repeated prompts during q login. This implementation supersedes PR #655 by not only supporting CLI arguments but also persistent default settings.

Motivation

Issue #654 reports that q login always prompts for start URL and region even when --identity-provider and --region are provided via CLI arguments. While PR #655 addresses the immediate CLI argument issue, users still face repeated prompts across login sessions.

This PR provides a more complete solution by:

  1. ✅ Skipping prompts when CLI arguments are provided (addresses PR feat(cli): skip prompts when identity provider and region CLI args are provided (issue #654) #655)
  2. ✅ Supporting persistent default settings for repeated use (goes beyond PR feat(cli): skip prompts when identity provider and region CLI args are provided (issue #654) #655)
  3. ✅ Providing visual feedback when defaults are used
  4. ✅ Auto-saving CLI arguments as defaults for future use

Changes

New Settings

Three new settings are introduced that users can configure via q settings:

  • auth.defaultLicense: Default license type ("free" or "pro")
  • auth.defaultRegion: Default AWS region (e.g., "us-east-1")
  • auth.defaultIdentityProvider: Default Identity Center start URL

Behavior

Priority order (highest to lowest):

  1. CLI arguments (e.g., --region us-east-1)
  2. Explicit default settings (configured via q settings)
  3. Previous values (shown as prompt defaults, requires Enter)

When CLI arguments or default settings exist, prompts are automatically skipped with visual feedback.

Example Usage

Scenario 1: Using CLI arguments (PR #655 behavior)

q login --license pro --identity-provider "https://example.awsapps.com/start" --region us-east-1
# ✅ No prompts - uses CLI arguments directly
# ✅ These values are saved as defaults for next time

Scenario 2: Using persistent defaults (NEW)

# One-time configuration
q settings auth.defaultLicense "pro"
q settings auth.defaultRegion "us-east-1"
q settings auth.defaultIdentityProvider "https://example.awsapps.com/start"

# Future logins automatically use these defaults
q login
# Output:
# Using license: Pro (Identity Center)
# Using Start URL: https://example.awsapps.com/start
# Using Region: us-east-1
# [authentication flow continues without prompts...]

Scenario 3: Override defaults with CLI arguments

q login --region us-west-2  # Overrides default region
# Using license: Pro (Identity Center)
# Using Start URL: https://example.awsapps.com/start
# Using Region: us-west-2  ← CLI argument takes precedence
# ✅ us-west-2 is now saved as the new default

Scenario 4: First-time setup with CLI arguments

# First login with CLI arguments
q login --license pro --region us-east-1 --identity-provider "https://example.awsapps.com/start"
# ✅ Values are automatically saved as defaults

# Subsequent logins are simpler
q login
# ✅ Uses saved defaults, no prompts needed

Implementation Details

  • Added resolve_auth_value() helper function to handle priority resolution
  • Modified login_interactive() to check CLI args → default settings → prompt
  • CLI arguments are automatically saved as default settings after successful authentication
  • Visual feedback shows which values are being used
  • Maintains backward compatibility - existing behavior unchanged when no defaults are configured

Comparison with PR #655

Feature PR #655 This PR
Skip prompts with CLI args
Persistent default settings
Visual feedback
Auto-save CLI args as defaults
License type defaults
Automation-friendly
User-friendly for repeated use

Testing

Related Issues

Add support for default authentication settings to skip repeated prompts
during login. Users can configure default values for license type, region,
and identity provider that will be automatically used in future logins.

Features:
- Auto-skip login prompts when default settings exist
- Display selected values when using defaults (e.g., 'Using Region: us-east-1')
- Priority order: CLI args > explicit defaults > previous values (as prompt defaults)
- Save settings after successful login for future use

Settings keys:
- auth.defaultLicense: 'free' or 'pro'
- auth.defaultRegion: AWS region (e.g., 'us-east-1')
- auth.defaultIdentityProvider: Identity Center start URL

🤖 Assisted by Amazon Q Developer
@yayami3 yayami3 requested a review from a team as a code owner October 17, 2025 15:41
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.

bug: q login always prompts for start url and region even if the --identity-provider and --region are provided

1 participant