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.99.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.99.0-py3-none-any.whl (86.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: intctl-0.99.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.99.0.tar.gz
Algorithm Hash digest
SHA256 7e1dbb37daf90f7d98ab61c44303e31abe756290a36946fa1ad6c1538c0ece04
MD5 cb91594e4432399f7c0b784c03329d05
BLAKE2b-256 eb912506e62a926c18f98a3007f68062c94fdb56c8431c022b136303ba4c8daa

See more details on using hashes here.

File details

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

File metadata

  • Download URL: intctl-0.99.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.99.0-py3-none-any.whl
Algorithm Hash digest
SHA256 55d31522e66a9d0f0ad0bacbf30d0bcaf6bd48b7ea0023ad048ef5b4a9b040d4
MD5 4035a99d4193bd1e58936a0f920eb61d
BLAKE2b-256 0524acbdb1a05838fe64cfa25a91bdb658cea462b97045587fbc6e9ffa73218c

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