V2Hub Admin — Admin Extension for VPN Subscription API
Admin extension for V2Hub, providing privileged operations for user and IP management through HMAC-SHA256 authentication.
🌐 Part of the V2Hub Ecosystem
This package is one component of V2Hub — see the full project overview, architecture, and all related repositories.
Features
- 🔐 HMAC Authentication (SHA-256 signing)
- 👤 User Management API (user CRUD)
- 🚫 IP Ban System
- ✅ Whitelist Management
- 🔄 Async & Sync clients
- 📦 Built on top of
v2hub - 🛡️ Fully typed (type hints + Pydantic)
Installation
pip install v2hub-admin
Quick Start
Async Usage
from v2hub_admin import AsyncAdminClient
async with AsyncAdminClient(
base_url="https://api.example.com",
secret_key="your-hmac-secret"
) as admin:
user = await admin.get_user(12345)
print(user)
Sync Usage
from v2hub_admin import AdminClient
with AdminClient(
base_url="https://api.example.com",
secret_key="your-hmac-secret"
) as admin:
user = admin.get_user(12345)
print(user)
Admin API
👤 User Management
admin.create_user(user_id: int)
admin.get_user(user_id: int)
admin.delete_user(user_id: int)
admin.set_user_status(user_id: int, is_active: bool)
admin.refresh_token(user_id: int)
Example
user = admin.create_user(12345)
print(user.api_token)
user = admin.set_user_status(12345, False)
print(user.is_active)
🚫 IP Ban Management
admin.ban_ip(ip_address: str, duration_seconds: int | None = None)
admin.unban_ip(ip_address: str)
admin.get_ban_status(ip_address: str)
admin.get_ban_list()
Example
ban = admin.ban_ip("192.168.1.100", duration_seconds=3600)
print(ban.banned_until)
status = admin.get_ban_status("192.168.1.100")
print(status.is_banned)
✅ Whitelist Management
admin.add_to_whitelist(ip_address: str, description: str | None = None)
admin.remove_from_whitelist(ip_address: str)
admin.list_whitelist()
Example
admin.add_to_whitelist("10.0.0.0/24", description="Office network")
whitelist = admin.list_whitelist()
for entry in whitelist.entries:
print(entry.ip_address, entry.description)
⚠️ Error Handling
All errors inherit from v2hub:
from v2hub import VPNAPIError, AuthenticationError, AuthorizationError
try:
admin.delete_user(12345)
except AuthenticationError:
print("Invalid HMAC signature")
except AuthorizationError:
print("No admin privileges")
except VPNAPIError as e:
print(e)
Development
pip install -e ".[dev]"
pytest
mypy src/
Requirements
- Python >= 3.9
- v2hub >= 1.0.0
Security Notes
⚠️ Important:
- Do not hardcode
secret_keyin source code - Use environment variables / secret managers
- HTTPS only in production
- Rotate keys regularly
- The Admin API has full access to the system
License
MIT
Author
nestt
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file v2hub_admin-1.1.1.tar.gz.
File metadata
- Download URL: v2hub_admin-1.1.1.tar.gz
- Upload date:
- Size: 18.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
87d12e04536b4c0f66b7af35869a98a6f221b44a5138b0832752f534003d368c
|
|
| MD5 |
72d2b0bbe9648d474875715c9d0ba600
|
|
| BLAKE2b-256 |
513c659904c401fa363a6a65daa7820f8da4936d27311197f63402f284444c11
|
Provenance
The following attestation bundles were made for v2hub_admin-1.1.1.tar.gz:
Publisher:
publish.yml on nestthub/v2hub-admin
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
v2hub_admin-1.1.1.tar.gz -
Subject digest:
87d12e04536b4c0f66b7af35869a98a6f221b44a5138b0832752f534003d368c - Sigstore transparency entry: 2394831491
- Sigstore integration time:
-
Permalink:
nestthub/v2hub-admin@1de3663d0136e175bca7ce9b64995a0238f2defe -
Branch / Tag:
refs/tags/v1.1.1 - Owner: https://github.com/nestthub
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1de3663d0136e175bca7ce9b64995a0238f2defe -
Trigger Event:
push
-
Statement type:
File details
Details for the file v2hub_admin-1.1.1-py3-none-any.whl.
File metadata
- Download URL: v2hub_admin-1.1.1-py3-none-any.whl
- Upload date:
- Size: 16.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
76eba7068290ede091b257edfda0624e17757b093b924c4cc94417c347eabec9
|
|
| MD5 |
cd2e74b0c2cddd7f049cfbf87db82044
|
|
| BLAKE2b-256 |
42a33bc597dd5d9f01731b0638582b171b99dfed28b70cce5f805db10aeeee58
|
Provenance
The following attestation bundles were made for v2hub_admin-1.1.1-py3-none-any.whl:
Publisher:
publish.yml on nestthub/v2hub-admin
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
v2hub_admin-1.1.1-py3-none-any.whl -
Subject digest:
76eba7068290ede091b257edfda0624e17757b093b924c4cc94417c347eabec9 - Sigstore transparency entry: 2394831516
- Sigstore integration time:
-
Permalink:
nestthub/v2hub-admin@1de3663d0136e175bca7ce9b64995a0238f2defe -
Branch / Tag:
refs/tags/v1.1.1 - Owner: https://github.com/nestthub
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1de3663d0136e175bca7ce9b64995a0238f2defe -
Trigger Event:
push
-
Statement type: