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.93.0.tar.gz (53.4 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.93.0-py3-none-any.whl (85.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for intctl-0.93.0.tar.gz
Algorithm Hash digest
SHA256 4d52b99d61bd0bc50b6775b54b301ed38516daf6dc0b0f98449c4488bef93545
MD5 a09903addadaa323fd933638e076e321
BLAKE2b-256 99b0a35fce6fedb312fb20a28de4ccb649942f66aa94ad62494e5820c2226cbd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: intctl-0.93.0-py3-none-any.whl
  • Upload date:
  • Size: 85.3 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.93.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f230ecdc3deaae77f19e68973cc050b6b6f253a485c21dff19d0b0f050318c39
MD5 55d31fdf88137cf8b6834e5f90e01772
BLAKE2b-256 ebdd2f01b3eefc6fcad3faa68f5d3d7b3c3beeb39e8e5902a1e5813bb9c0f1bd

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