A CLI tool to obtain AWS credentials via Okta authentication, supporting both OIDC and SAML workflows.
- OIDC Device Flow: Authenticate using Okta OIDC with device authorization
- SAML Browser Flow: Seamless browser-based SAML authentication with automatic credential capture
- Flexible Configuration: Configure via YAML file, environment variables, or CLI flags
- Multiple Output Formats: Export credentials as JSON or environment variables
- AWS Credentials File: Automatically write to
~/.aws/credentials - Browser Extension: Auto-installs Chrome/Firefox extension for SAML interception
go build -o oktaws./oktaws config initThis creates ~/.config/oktaws/config.yaml with default values.
./oktaws config set org_domain your-org.okta.com
./oktaws config set aws_acct_fed_app_id your-app-id
./oktaws config set aws_region us-east-1./oktawsOn first run, the CLI will:
- Detect your default browser (Chrome or Firefox)
- Guide you through a one-time extension installation
- Open your browser to Okta
- Automatically capture SAML and fetch AWS credentials
Location: ~/.config/oktaws/config.yaml
org_domain: your-org.okta.com
aws_acct_fed_app_id: exkXXXXXXXXXXXXXXXX
aws_region: us-east-1
session_duration: 43200 # 12 hours
auth_flow: saml-browser # or "oidc" or "auto"
profile: default
format: env-var # or "json"# View current configuration
./oktaws config list
# Get a specific value
./oktaws config get org_domain
# Set a value
./oktaws config set org_domain your-org.okta.com
# Show config file path
./oktaws config path- CLI flags (highest priority)
- Environment variables
- Config file
- Defaults (lowest priority)
./oktaws --auth-flow saml-browserBest for:
- Users without Okta admin access
- Standard AWS/Okta SAML SSO setup
- Interactive workflows
How it works:
- Starts a local callback server
- Opens your browser to Okta
- Browser extension intercepts SAML assertion
- CLI receives SAML and calls AWS STS
- Outputs AWS credentials
./oktaws --auth-flow oidc --oidc-client-id your-client-idBest for:
- CI/CD environments
- Headless servers
- When you have an OIDC client configured in Okta
How it works:
- Generates a device code
- Displays URL and code for user authorization
- Polls Okta for access token
- Exchanges token for SAML assertion
- Calls AWS STS for credentials
--auth-flow string- Authentication flow:auto,oidc, orsaml-browser(default: auto)--org-domain string- Okta organization domain--oidc-client-id string- OIDC client ID (for OIDC flow)--aws-acct-fed-app-id string- AWS Account Federation app ID
--aws-region string- AWS region (default: us-east-1)--aws-iam-role string- AWS IAM role ARN (optional, will prompt if multiple)--aws-session-duration string- Session duration in seconds (default: 3600)
--format string- Output format:env-varorjson(default: env-var)--profile string- AWS profile name (default: default)--write-aws-credentials- Write to~/.aws/credentials
--open-browser- Open browser automatically (default: true for SAML flow)--open-browser-command string- Custom browser command
--debug- Enable debug output--debug-api-calls- Debug API calls
export AWS_ACCESS_KEY_ID="ASIA..."
export AWS_SECRET_ACCESS_KEY="..."
export AWS_SESSION_TOKEN="..."Use with:
eval $(./oktaws)./oktaws --format json{
"AccessKeyId": "ASIA...",
"SecretAccessKey": "...",
"SessionToken": "...",
"Expiration": "2025-10-07T07:50:15Z"
}./oktaws --write-aws-credentials --profile my-profileWrites to ~/.aws/credentials:
[my-profile]
aws_access_key_id = ASIA...
aws_secret_access_key = ...
aws_session_token = ...The SAML browser flow requires a browser extension that automatically captures SAML assertions.
When you first run with --auth-flow saml-browser, the CLI will:
- Detect your browser (Chrome or Firefox)
- Extract extension files to
~/.config/oktaws/extension/ - Enable Chrome Developer Mode (if using Chrome)
- Open the extensions page in your browser
- Guide you through installation (one click: "Load unpacked")
- Google Chrome
- Mozilla Firefox
Other browsers are not currently supported.
The extension requires:
- Access to Okta domains (
*.okta.com,*.okta-emea.com) - Access to AWS signin (
*.signin.aws.amazon.com) - Network request interception (to capture SAML)
- Local storage (to save CLI port)
Your Okta domain is in the URL when you log into Okta:
https://your-org.okta.com
^^^^^^^^^^^^^^^^
- Log into Okta
- Navigate to your AWS tile
- Look at the URL:
https://your-org.okta.com/app/amazon_aws/exkXXXXXXXXXXXXXXXX/sso/saml
^^^^^^^^^^^^^^^^^^^^
Ask your Okta administrator to create an OIDC client for you and provide the client ID.
# Configure once
./oktaws config set org_domain my-company.okta.com
./oktaws config set aws_acct_fed_app_id exk123456789
# Get credentials
eval $(./oktaws)
# Use AWS CLI
aws s3 ls# Dev account
./oktaws --profile dev --aws-acct-fed-app-id exkDEV123 --write-aws-credentials
# Prod account
./oktaws --profile prod --aws-acct-fed-app-id exkPROD456 --write-aws-credentials
# Use profiles
aws s3 ls --profile dev
aws s3 ls --profile prod./oktaws --aws-session-duration 43200 # 12 hours./oktaws --aws-iam-role admin-roleCREDS=$(./oktaws --format json)
ACCESS_KEY=$(echo $CREDS | jq -r '.AccessKeyId')
echo "Access Key: $ACCESS_KEY"Issue: CLI says extension is not installed, but you installed it.
Solution:
- Make sure Chrome is running
- Verify the extension is enabled in
chrome://extensions/ - The extension name should be "Oktaws SAML Interceptor"
- Try restarting Chrome after installation
Issue: bind: address already in use on port 8765
Solution:
# Kill the process using the port
lsof -ti:8765 | xargs kill -9Issue: Browser opens but SAML is never received.
Solution:
- Check browser console for
[Oktaws]messages - Verify extension is loaded:
chrome://extensions/ - Try reloading the extension
- Make sure you're authenticating (not already logged into AWS)
Issue: Extension needs additional permissions.
Solution:
- Click the extension icon in your browser
- Grant the requested permissions
- Refresh the Okta page
Issue: You have access to multiple AWS roles.
Solution:
- CLI will prompt you to select a role
- Or specify with
--aws-iam-role role-name - Add to config file to avoid prompts:
aws_iam_role: admin-role
Issue: CLI doesn't open browser automatically.
Solution:
- CLI will print the URL - open it manually
- Or set a custom browser:
--open-browser-command "/path/to/browser"
- Credentials: Never commit your config file with credentials to version control
- Extensions: The extension only runs on Okta and AWS domains
- Local server: The callback server only listens on localhost (127.0.0.1)
- No data storage: SAML assertions are not stored, only used in memory
- Token caching: Optional, disabled by default (
--cache-access-tokento enable)
Issues and pull requests are welcome!
MIT