No project description provided
Project description
fastapi-security-telegram-webhook
Plugin for FastAPI which allows you secure your Telegram Bot API webhook endpoint with IP restriction and optional secret token.
How to use
Use pip or another package management util:
pip install fastapi-security-telegram-webhook
or
poetry add fastapi-security-telegram-webhook
or
pipenv install fastapi-security-telegram-webhook
Package contains two Security objects:
OnlyTelegramNetwork
allows request only from telegram subnetsOnlyTelegramNetworkWithSecret
additionally check secret in path
Example with OnlyTelegramNetworkWithSecret
. Pay attention to {secret}
in path operation, it's required
from fastapi import FastAPI, Body, Depends
from fastapi_security_telegram_webhook import OnlyTelegramNetworkWithSecret
app = FastAPI()
webhook_security = OnlyTelegramNetworkWithSecret(real_secret="your-secret-from-config-or-env")
# {secret} in path and OnlyTelegramNetworkWithSecret as dependency:
@app.post('/webhook/{secret}', dependencies=[Depends(webhook_security)])
def process_telegram_update(update_raw = Body(...)):
...
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
Built Distribution
Close
Hashes for fastapi-security-telegram-webhook-0.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | aebb221fcf7a5b0fe0a120545752cd70fa7d4cbe8074f75cac60315650909902 |
|
MD5 | 6e56de60999eb193749a3517878ccd19 |
|
BLAKE2b-256 | a0f6ef9dfb24cf89fcd89a85475901d408ecb7c129cb1f36149bfca4b3ba575f |
Close
Hashes for fastapi_security_telegram_webhook-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5c8398e06e7dc9e450fb59d934c926b31e6fa6763bdc8df2b74c641e04297368 |
|
MD5 | c0a12ccfdb427b1023014e165eaf7d8f |
|
BLAKE2b-256 | 0b2d6a9ec3b5f0c219538dd325d012510997c54baeb9c2d92f057588477fb5bb |