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.86.0.tar.gz (36.6 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.86.0-py3-none-any.whl (61.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for intctl-0.86.0.tar.gz
Algorithm Hash digest
SHA256 452c8eaac434eaea0ae06fd20ed5b2fc4efac9694a9ffd60c7998008f3c7dd6a
MD5 cd4a73bb80de44641cd9df6e113f7cb6
BLAKE2b-256 ac85b4a3d1f6d42ddddae45937d4de6bf2926d8255e0bab3919023139ac39aaa

See more details on using hashes here.

File details

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

File metadata

  • Download URL: intctl-0.86.0-py3-none-any.whl
  • Upload date:
  • Size: 61.0 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.86.0-py3-none-any.whl
Algorithm Hash digest
SHA256 221f4de68ab6389b1f9de374df78e3e464fd9e0c52ffb2cacd0cc4c9f8cc8de3
MD5 8128722bcb82a84978e5acdaf2e618ad
BLAKE2b-256 b28ae9d11338d18dd8987a4a7e66e1a30e470448ec8dc2e6382259b4659083b3

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