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

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for intctl-0.94.0.tar.gz
Algorithm Hash digest
SHA256 b912ca9a6c561421fa3f5e2f3bf3f7544a6f272a8eb0ad4552a817b8cadf3b84
MD5 4c5d4e1c9afc3dda38bfcac74e7f0b02
BLAKE2b-256 499b44822ff1621bac979d1e7172a69be643f455601f7d00cd9417fd02bb676b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: intctl-0.94.0-py3-none-any.whl
  • Upload date:
  • Size: 86.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.94.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f259e0bf2830847ba5ac19eb87bfd9e7e224446a88965ca85ab1e09bc86e7313
MD5 b5bb19067715b7f18303f7eafcdbf6f8
BLAKE2b-256 70ed17ef29d1864013e4fc341487ff0ac2d47c8600d09d584b9114ecdb607aa9

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