Treasury Analytics Core
  • Home
  • API Reference
  • Examples
  • Credentials
  • Global Settings
  1. API Reference
  2. Utilities
  3. credentials
  • Overview
    • Treasury Analytics Core
  • Credential Management
    • Secure Credential Management
    • Global Settings
  • Examples
    • Example Projects
  • API Reference
    • Function reference
    • Core Components
      • FinanceDataEngine
      • engine_factory
      • engine
      • database
      • cache
      • processor
      • analyzer
    • Configuration
      • settings
      • settings_factory
      • global_settings_manager
    • Utilities
      • credentials
      • dataframe_utils
      • setup_logging
      • env_checker
      • query_timer
      • setup_helper
      • logging
      • constants
      • types
    • Scripts
      • configure_db
      • create_project
      • manage_settings

On this page

  • credentials
    • Classes
      • CredentialManager

Other Formats

  • Github (GFM)
  1. API Reference
  2. Utilities
  3. credentials

credentials

utils.credentials

Secure credential management module with enhanced masked password input.

This module provides secure credential storage and retrieval using the system’s secure credential store (Keychain on macOS, Credential Manager on Windows, SecretService/KWallet on Linux) with improved error handling and fallbacks.

It includes enhanced password input with masked characters for better usability when pasting from password managers, while still maintaining security.

Classes

Name Description
CredentialManager Secure credential management system with enhanced password input.

CredentialManager

utils.credentials.CredentialManager(
    self,
    service_name='nova_fde',
    username=None,
    console=None,
)

Secure credential management system with enhanced password input.

This class provides secure storage and retrieval of credentials using the system’s secure credential store, with graceful fallbacks for errors and enhanced password input with masked characters.

Parameters

Name Type Description Default
service_name str Name of the service for credential storage. 'nova_fde'
username Optional[str] Default username for the service. None
console Optional[Console] Rich console for output. None

Notes

Credentials are stored in the system’s secure credential store: - macOS: Keychain - Windows: Credential Manager - Linux: SecretService/KWallet

Methods

Name Description
clear_credentials Clear stored credentials from all storage backends.
ensure_credentials_in_environment Ensure credentials are available in environment variables.
get_credentials Get credentials from secure storage.
get_credentials_with_fallback Get credentials with fallback to manual entry.
store_credentials Store credentials in secure storage.
validate_connection Validate credentials by testing the database connection.
clear_credentials
utils.credentials.CredentialManager.clear_credentials()

Clear stored credentials from all storage backends.

ensure_credentials_in_environment
utils.credentials.CredentialManager.ensure_credentials_in_environment(
    verbose=False,
    use_masked_input=True,
)

Ensure credentials are available in environment variables.

This method retrieves credentials using the fallback mechanism and sets them as environment variables for use by other components.

Parameters
Name Type Description Default
verbose bool Whether to print additional information (default: False). False
use_masked_input bool Whether to use masked password input (default: True). True
get_credentials
utils.credentials.CredentialManager.get_credentials(
    prompt_if_missing=True,
    verbose=False,
)

Get credentials from secure storage.

Parameters
Name Type Description Default
prompt_if_missing bool Whether to prompt for credentials if not found (default: True). True
verbose bool Whether to print additional information (default: False). False
Returns
Name Type Description
Tuple[Optional[str], Optional[str]] Username and password tuple.
get_credentials_with_fallback
utils.credentials.CredentialManager.get_credentials_with_fallback(
    verbose=False,
    use_masked_input=True,
)

Get credentials with fallback to manual entry.

This method tries all storage backends first, but falls back to manual entry if retrieval fails. Unlike get_credentials, this method always returns valid credentials or raises an exception.

Parameters
Name Type Description Default
verbose bool Whether to print additional information (default: False). False
use_masked_input bool Whether to use masked password input (default: True). True
Returns
Name Type Description
tuple[str, str] Username and password tuple, guaranteed to be non-None.
Raises
Name Type Description
ValueError If credentials cannot be obtained.
store_credentials
utils.credentials.CredentialManager.store_credentials(username, password)

Store credentials in secure storage.

Parameters
Name Type Description Default
username str Username to store. required
password str Password to store. required
Raises
Name Type Description
RuntimeError If keyring is not available or credentials could not be stored.
validate_connection
utils.credentials.CredentialManager.validate_connection(
    connection_func,
    max_attempts=3,
    verbose=False,
)

Validate credentials by testing the database connection.

Parameters
Name Type Description Default
connection_func callable Function that attempts to connect to the database using credentials. Should return True for success, False for failure. required
max_attempts int Maximum number of connection attempts, by default 3 3
verbose bool Whether to print additional information, by default False False
Returns
Name Type Description
bool True if credentials are valid, False otherwise
global_settings_manager
dataframe_utils
 
 
  • Built with [Quarto](https://quarto.org/) and [quartodoc](https://machow.github.io/quartodoc/)