add allow_prompt parameter to get_secret to support non-interactive secret retrieval
This commit is contained in:
parent
c754fc7e7a
commit
869c2927d3
1 changed files with 4 additions and 1 deletions
|
|
@ -224,7 +224,7 @@ def detect_launch_command():
|
||||||
|
|
||||||
return commands
|
return commands
|
||||||
|
|
||||||
def get_secret(config, config_path):
|
def get_secret(config, config_path, allow_prompt=True):
|
||||||
"""
|
"""
|
||||||
Retrieves the OTP secret in the following priority:
|
Retrieves the OTP secret in the following priority:
|
||||||
1. System Keyring (SERVICE_NAME, USERNAME) - if available
|
1. System Keyring (SERVICE_NAME, USERNAME) - if available
|
||||||
|
|
@ -266,6 +266,9 @@ def get_secret(config, config_path):
|
||||||
# No keyring, just use config
|
# No keyring, just use config
|
||||||
return secret
|
return secret
|
||||||
|
|
||||||
|
if not allow_prompt:
|
||||||
|
return None
|
||||||
|
|
||||||
# 3. Prompt User
|
# 3. Prompt User
|
||||||
if HAS_KEYRING:
|
if HAS_KEYRING:
|
||||||
print("\nOTP Secret not found in keyring.")
|
print("\nOTP Secret not found in keyring.")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue