README
¶
grant
A CLI tool for elevating Azure permissions via CyberArk Secure Cloud Access (SCA) — without leaving the terminal.
Overview
grant enables terminal-based Azure permission elevation through CyberArk SCA. It wraps the idsec-sdk-golang SDK for authentication and builds a custom SCA Access API client for JIT role elevation.
Key Features:
- Interactive permission elevation with fuzzy search
- Direct elevation with target and role flags
- Favorites management for frequently used roles
- Session status monitoring
- Secure token storage in system keyring
Installation
Binary Releases (Recommended)
Download pre-built binaries from the Releases page.
macOS:
# Intel
curl -LO https://github.com/aaearon/grant-cli/releases/latest/download/grant_Darwin_x86_64.tar.gz
tar xzf grant_Darwin_x86_64.tar.gz
sudo mv grant /usr/local/bin/
# Apple Silicon
curl -LO https://github.com/aaearon/grant-cli/releases/latest/download/grant_Darwin_arm64.tar.gz
tar xzf grant_Darwin_arm64.tar.gz
sudo mv grant /usr/local/bin/
Linux:
curl -LO https://github.com/aaearon/grant-cli/releases/latest/download/grant_Linux_x86_64.tar.gz
tar xzf grant_Linux_x86_64.tar.gz
sudo mv grant /usr/local/bin/
Windows:
Download grant_Windows_x86_64.zip from releases and extract to a directory in your PATH.
Go Install
go install github.com/aaearon/grant-cli@latest
From Source
git clone https://github.com/aaearon/grant-cli.git
cd grant-cli
make build
Quick Start
Initial Setup
-
Authenticate (auto-configures on first run):
grant loginOn first run, you'll be prompted for:
- Identity URL (e.g.,
https://abc1234.id.cyberark.cloud) - Username
Then follow the interactive prompts to complete MFA authentication. The MFA method will be selected interactively during login.
- Identity URL (e.g.,
-
Elevate permissions:
grantSelect your target and role from the interactive list.
-
Verify active sessions:
grant status
Optional: Run grant configure to reconfigure your Identity URL or username.
Commands
Running grant with no subcommand elevates cloud permissions (the core behavior). Subcommands are listed below.
| Command | Description |
|---|---|
configure |
Configure or reconfigure Identity URL and username (optional — login auto-configures on first run) |
login |
Authenticate to CyberArk Identity (auto-configures on first run, MFA handled interactively) |
logout |
Clear cached tokens from keyring |
status |
Show authentication state and active SCA sessions |
favorites |
Manage saved role favorites (add/list/remove) |
version |
Print version information |
configure
Configure or reconfigure your CyberArk tenant connection.
grant configure
This command:
- Creates
~/.grant/config.yamlfor application settings - Creates
~/.idsec_profiles/grant.jsonfor SDK authentication - Prompts for Identity URL (must be HTTPS, format:
https://{subdomain}.id.cyberark.cloud) - Prompts for username
Note: This command is optional. Running grant login for the first time automatically runs configuration. Use configure to change your Identity URL or username.
login
Authenticate to CyberArk Identity with MFA.
grant login
This command:
- First time: Prompts for Identity URL and username, then authenticates
- Subsequent runs: Uses credentials from
~/.idsec_profiles/grant.json - Prompts for password and MFA challenge (MFA method selected interactively)
- Stores tokens securely in system keyring
- Shows token expiration time on success
Note: Tokens are automatically refreshed during operations if still valid.
logout
Clear all cached tokens from the system keyring.
grant logout
This removes stored authentication tokens but preserves your configuration files.
Default Behavior (Elevate)
Running grant with no subcommand requests JIT (just-in-time) permission elevation for cloud resources.
Interactive mode — select from eligible targets:
grant
grant --provider azure # explicit provider
Direct mode — specify target and role:
grant --target "Prod-EastUS" --role "Contributor"
grant -t "MyResourceGroup" -r "Owner"
Favorite mode — use a saved favorite:
grant --favorite prod-contrib
grant -f dev-reader
Flags:
--provider, -p— Cloud provider (default:azure, v1 supports Azure only)--target, -t— Target name (subscription, resource group, management group, directory, or resource)--role, -r— Role name (e.g., "Contributor", "Reader", "Owner")--favorite, -f— Use a saved favorite alias (combines provider, target, and role)--duration, -d— Requested session duration in hours (subject to policy limits)
Target matching:
- Matches by workspace name (case-insensitive, partial match)
- Interactive mode provides fuzzy search
- Shows workspace type (subscription, resource group, etc.) and available roles
How it works:
For Azure, SCA creates a JIT Azure RBAC role assignment. Your existing az CLI session automatically picks up the elevated permissions — no credentials are returned.
status
Display authentication state and active elevation sessions.
grant status
grant status --provider azure # filter by provider
Output includes:
- Authentication status (username and token validity)
- Active sessions grouped by cloud provider
- Session details: target name, role, expiration time
- Human-readable time remaining (e.g., "2h 15m")
favorites
Manage saved role combinations for quick elevation.
Add a favorite:
grant favorites add <name>
This interactively prompts for:
- Provider (default: azure)
- Target name
- Role name
List favorites:
grant favorites list
Shows all saved favorites with their provider, target, and role.
Remove a favorite:
grant favorites remove <name>
Example workflow:
# Add a favorite
$ grant favorites add prod-contrib
Provider: azure
Target: Prod-EastUS
Role: Contributor
Favorite 'prod-contrib' added successfully.
# Use the favorite
$ grant --favorite prod-contrib
# List favorites
$ grant favorites list
prod-contrib:
Provider: azure
Target: Prod-EastUS
Role: Contributor
version
Display version information including commit hash and build date.
grant version
Configuration
App Config (~/.grant/config.yaml)
Application settings including default provider and favorites.
Default location: ~/.grant/config.yaml
Override: Set GRANT_CONFIG environment variable to use a custom path.
profile: grant # SDK profile name
default_provider: azure # Default cloud provider
favorites:
prod-contrib:
provider: azure
target: "Prod-EastUS"
role: "Contributor"
dev-reader:
provider: azure
target: "Dev-Subscription"
role: "Reader"
Fields:
profile— Name of the SDK profile in~/.idsec_profiles/(default:grant)default_provider— Default cloud provider for elevation (default:azure)favorites— Map of favorite names to provider/target/role combinations
SDK Profile (~/.idsec_profiles/grant.json)
CyberArk Identity SDK profile containing Identity URL and authentication preferences.
Managed by: grant configure command (or auto-created by grant login)
Contains:
- Identity URL (format:
https://{subdomain}.id.cyberark.cloud) - Username
- SDK version metadata
Note: Tokens are NOT stored in this file — they're stored securely in the system keyring. MFA method selection is handled interactively during login.
Environment Variables
| Variable | Description | Default |
|---|---|---|
GRANT_CONFIG |
Custom path to app config YAML | ~/.grant/config.yaml |
HOME |
User home directory (used for config paths) | System default |
How It Works
Azure Elevation Flow
- List Eligibility: Queries SCA API for roles you're eligible to activate
- Request Elevation: Submits elevation request with target and role
- JIT Activation: SCA creates a time-limited Azure RBAC role assignment
- Automatic Access: Your existing
azCLI picks up the new role assignment - Session Expiry: Role assignment automatically expires (default: 8 hours, policy-controlled)
Important: No Azure credentials are returned to you. SCA manages the Azure role assignment behind the scenes. Your Azure CLI session uses its existing authentication but gains the new role assignment.
Authentication Flow
- Initial Authentication:
grant loginauthenticates to CyberArk Identity with MFA - Token Storage: Tokens stored securely in system keyring (macOS Keychain, Windows Credential Manager, Linux Secret Service)
- Token Reuse: Subsequent commands reuse cached tokens if still valid
- Auto-Refresh: SDK automatically refreshes tokens before expiry
- Manual Logout:
grant logoutclears tokens from keyring
Troubleshooting
"Error: failed to load config" or "profile not found"
Cause: Configuration files not created or corrupted.
Solution:
grant login # Auto-configures on first run
# or
grant configure # Explicit reconfiguration
"Error: not authenticated" or "authentication required"
Cause: No valid authentication token in keyring.
Solution:
grant login
If login fails, verify:
- Identity URL is correct (check
~/.idsec_profiles/grant.json- should behttps://{subdomain}.id.cyberark.cloud) - Username is correct
- Password is correct
- MFA device/method is available and working
Elevation succeeds but Azure CLI doesn't see new role
Cause: Azure CLI token cache may be stale.
Solution:
# Refresh Azure CLI token
az account get-access-token --output none
# Or clear Azure CLI cache and re-login
az account clear
az login
"No eligible targets found"
Cause: Either you have no SCA policies granting access, or your policies don't grant Azure access.
Solution:
- Contact your CyberArk administrator to verify SCA policies
- Ensure policies grant you access to Azure targets
- Verify you're using the correct provider:
grant --provider azure
"Failed to elevate" or partial success
Cause: Policy may not allow the specific role or target, or session limit reached.
Solution:
- Check active sessions:
grant status - Verify the target name and role name are correct
- Try with different duration:
grant --duration 4 - Contact your CyberArk administrator if role should be available
Interactive selection doesn't appear
Cause: Terminal doesn't support interactive input (e.g., non-TTY, CI environment).
Solution: Use direct mode with explicit flags:
grant --target "MyTarget" --role "Contributor"
"Error: invalid provider" (v1)
Cause: Version 1.x only supports Azure.
Solution:
Use --provider azure (or omit the flag, as Azure is the default):
grant --provider azure
Token expired or invalid during operation
Cause: Token expired between operations or keyring access denied.
Solution:
grant logout
grant login
Permission denied accessing keyring (Linux)
Cause: No keyring service available or gnome-keyring / kde-wallet not running.
Solution:
- Install and start a keyring service:
# For GNOME sudo apt install gnome-keyring # For KDE sudo apt install kwalletmanager - Or use environment-based auth (not recommended for production)
Development
Running Tests
# Unit tests
make test
# Integration tests (requires binary build)
make test-integration
# All tests
make test-all
Building
# Build binary
make build
# Build with version info
VERSION=1.0.0 make build
Linting
make lint
Contributing
Contributions welcome! Please:
- Follow existing code patterns and conventions
- Write tests for new functionality (TDD preferred)
- Update documentation for user-facing changes
- Use conventional commits for commit messages
License
MIT
Documentation
¶
There is no documentation for this package.