Skip to main content

Bootstrap CLI for provisioning cloud resources

Project description

remove the existing package: rm -rf build/ dist/ *.egg-info build again: python -m build

upload to pypi: twine upload dist/*

📦 Overview

The CLI now supports:

  • 🔐 Secure login via browser-based device authorization (OAuth2-compliant)
  • 🏢 Organization-scoped login (per session)
  • 🔁 Automatic token refresh using offline tokens
  • 👤 User context inspection (whoami)
  • 👋 Session clearing (logout)

🧑‍💻 Commands

All auth-related commands are grouped under:

intctl auth <subcommand>

1. 🔐 intctl auth login

Start login flow via browser:

intctl auth login

Flow:

  1. Prompts for organization ID or name

  2. Opens Keycloak device login via browser

  3. User authenticates (e.g., via password or IdP)

  4. Token is issued and saved locally:

    • access_token: short-lived
    • refresh_token: long-lived
    • username, org: stored with token

Stored at: ~/.intctl_token


2. 🧾 intctl auth whoami

Displays the current authenticated user and selected organization:

intctl auth whoami

Output:

👤 User: saeid
🏢 Org:  org-abc

3. 🚪 intctl auth logout

Clears the local session:

intctl auth logout

This deletes the token and org information stored in ~/.intctl_token.


🔁 Token Refresh

The CLI automatically refreshes your token when it's near expiry:

  • Refreshes if token expires in less than 60 seconds
  • Uses stored refresh_token (offline token)
  • Seamless; no user input required

🔧 Use in Code

from login import get_valid_access_token

headers = {
    "Authorization": f"Bearer {get_valid_access_token()}",
    "X-Org": load_login_data()["org"]
}

🗂️ Token Storage Format

Stored as JSON at ~/.intctl_token:

{
  "access_token": "eyJhbGci...",
  "refresh_token": "eyJhbGci...",
  "username": "saeid",
  "org": "intellithing"
}

🔐 Keycloak Client Configuration Summary

Field Value
Client Type OpenID Connect (Public)
Device Auth Grant ✅ Enabled
Offline Access Scope ✅ Assigned
Access Type Public

🔄 Future Ideas (Optional Enhancements)

  • intctl auth switch-org: change org context without full re-login
  • Encrypt token file using keyring or GPG
  • Add intctl auth refresh (manual token refresh)

📎 Example Usage

intctl auth login
intctl configure
intctl setup
intctl auth whoami
intctl auth logout

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

intctl-0.98.0.tar.gz (54.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

intctl-0.98.0-py3-none-any.whl (86.8 kB view details)

Uploaded Python 3

File details

Details for the file intctl-0.98.0.tar.gz.

File metadata

  • Download URL: intctl-0.98.0.tar.gz
  • Upload date:
  • Size: 54.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.12

File hashes

Hashes for intctl-0.98.0.tar.gz
Algorithm Hash digest
SHA256 7de5056da0a479d7587d453525787c9358a0632fffe4dd7d3965b1fff5bf9237
MD5 65284696bc1280863538152fbfaa24b4
BLAKE2b-256 2aa0c87e356b5d2f0ad38797e4fe7e87e64f53f15f7c52199a2fd0c40e658857

See more details on using hashes here.

File details

Details for the file intctl-0.98.0-py3-none-any.whl.

File metadata

  • Download URL: intctl-0.98.0-py3-none-any.whl
  • Upload date:
  • Size: 86.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.12

File hashes

Hashes for intctl-0.98.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0d35ce716fd11ae5b371b47ef5c05723fc5ab41e7b81f6f9efd6b2da71e963c4
MD5 594a99e35c180bafc3f4e911d38246d5
BLAKE2b-256 efb4120c86e64003e5f0f55a142e3e82ec5f57dffa3cc166f4a61ae8e9df07cb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page