The Dipper Admin CLI supports multiple authentication mechanisms to securely manage your configuration and secrets.
Important
Before using any authentication mechanism, ensure you understand and follow these security best practices.
-
Access Control
- Store signing keys in dedicated 1Password vaults
- Use environment-specific vaults (development, staging, production)
- Regularly audit vault access permissions
- Implement the principle of least privilege for key access
-
Secret Management
- Never commit actual signing keys to version control
- Use descriptive item names in 1Password
- Regularly rotate signing keys
- Keep the 1Password CLI authenticated
- Avoid storing secrets in plain text files
- Use secure secret rotation procedures
-
Configuration
- Use template
.envfiles with 1Password references - Document the required 1Password items and fields
- Maintain separate configurations for different environments
- Keep configuration templates in version control
- Document security requirements and procedures
- Use template
The CLI provides multiple ways to handle authentication and configuration, each with its own use cases and security considerations.
All environment variables used by the CLI are prefixed with DIPS_. The main configuration-related environment variables are:
DIPS_SERVER_URL: The URL of the DIPs gateway serverDIPS_SIGNING_KEY: The secret key used to sign requests (in hex format)
Environment variables take precedence over command-line arguments and can be used to avoid repeating common configuration:
# Set the server URL in the environment
export DIPS_SERVER_URL=https://admin.dips.example.com
# Run a command without specifying the server URL
dipper-cli init keygen --output .env.unencryptedYou can use a .env file to store your configuration. The CLI will automatically look for a .env file in the current directory. You can also specify a custom path using the --env-file flag:
dipper-cli --env-file /path/to/.env <command>The CLI provides several flags for authentication:
--server-url <URL>: Specify the DIPs gateway server URL--signing-key <KEY>: Provide the signing key in hex format--env-file <FILE>: Specify a custom.envfile path
The CLI supports integration with 1Password for secure secret management. There are two main approaches to provide credentials using 1Password:
You can use the 1Password CLI (op) to read secrets directly into environment variables or CLI flags:
# Using environment variables
export DIPS_SIGNING_KEY=$(op read "op://mainnet/dips/signing-key-1")
dipper-cli <command>
# Using CLI flags
dipper-cli --signing-key "$(op read "op://mainnet/dips/signing-key-1")" <command>This approach is useful for:
- One-off commands
- CI/CD pipelines
- Scripts where you need direct access to the secret value
For more complex configurations, you can use 1Password's environment variable injection feature:
- Create a template
.env.templatefile with 1Password references:
# .env.template
DIPS_SERVER_URL=https://admin.dips.example.com
DIPS_SIGNING_KEY={{ op://mainnet/dips/signing-key-1 }}- Use
op injectto inject the secrets:
op inject --in-file .env.template --out-file .env.injected -- dipper-cli --env-file .env.injected <command>This approach is beneficial when:
- Managing multiple secrets
- Working with configuration files
- Sharing configuration templates without exposing secrets
The init command helps you bootstrap your DIPs Admin CLI configuration. It provides two subcommands for different use cases:
The init keygen command generates a new key pair for signing requests:
# Generate a new key pair and display it
dipper-cli init keygen
# Generate a new key pair and save it to a .env file
dipper-cli init keygen --server-url https://admin.dips.example.com --output .env.unencryptedThis command will:
- Generate a new random key pair
- Display the public and private keys
- Optionally save the configuration to a file if
--outputis specified
Important
When saving to a file, the command will display a security warning about storing private keys in environment files. Consider using a secure credential manager instead.
The init placeholder command helps you set up configuration with 1Password integration:
# Create a template .env.template file with 1Password references
dipper-cli init placeholder op://mainnet/dips/signing-key-1 --server-url https://admin.dips.example.com --output .env.templateThis command will:
- Create a template configuration file with 1Password references
- Show instructions for using
op injectto inject secrets at runtime - Save the template to the specified output file (defaults to
.env.template)
The generated template will contain the 1Password reference wrapped in double curly braces, which is the format required by op inject:
# .env.template
DIPS_SERVER_URL=https://admin.dips.example.com
DIPS_SIGNING_KEY={{ op://mainnet/dips/signing-key-1 }}To use the generated template:
# Inject secrets and run a command
op inject --in-file .env.template --out-file .env.injected -- dipper-cli --env-file .env.injected <command>This section provides information for developers who want to contribute to the Dipper CLI module.
To build the Dipper CLI, use the following Cargo commands:
# Build the CLI in debug mode
cargo build --bin dipper-cli
# Build the CLI in release mode (optimized)
cargo build --bin dipper-cli --releaseThe compiled binary will be available in:
- Debug build:
target/debug/dipper-cli - Release build:
target/release/dipper-cli
You can build and run the CLI directly using Cargo:
# Run a specific command
cargo run --bin dipper-cli <command> [options]
# Examples:
cargo run --bin dipper-cli init --server-url https://admin.dips.example.com
cargo run --bin dipper-cli --env-file .env indexings listTo enable debug logging, set the RUST_LOG environment variable.
# Enable debug logging
export RUST_LOG=debug
# Enable trace logging for maximum verbosity
export RUST_LOG=traceThe Dipper CLI uses the following module names for more specific logging:
# Enable debug logging for all Dipper CLI modules
export RUST_LOG=dipper_cli=debug
# Enable debug logging for specific modules
export RUST_LOG=dipper_cli::cmd=debug,dipper_cli::config=debugYou can combine this with running the CLI:
RUST_LOG=debug cargo run --bin dipper-cli <command>For more detailed debugging with backtraces:
RUST_LOG=debug RUST_BACKTRACE=1 cargo run --bin dipper-cli <command>