Add --allowed-bot-ids option to whitelist bots - #892
Open
yagop wants to merge 1 commit into
Open
Conversation
When specified, requests for bot user identifiers outside the comma-separated list are rejected with 401 before a client is created, so unknown bots can't consume server resources. By default all bots are allowed.
Contributor
|
The server must be either available only from a private network or to be available through a TLS termination proxy. In the first case it makes no sense to restrict allowed bots. In the second case the restriction is better to be done on the proxy side. The option |
Author
|
I'm running my telegram-bot-api in a public exposed Fly.io instance. Fly.io handles the TLS certificates (we can't do any kind of authorization). Many other cloud providers may handle the certificates too. Thus the need of |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds an optional
--allowed-bot-idscommand-line option that takes a comma-separated list of bot user identifiers permitted to use the server.When the option is set, a request whose bot user id is not in the list is rejected with
401 Unauthorized: bot is not allowed to use the serverinClientManager::send, before anyClientis created — so unknown bots can't consume server resources (memory, TDLib instances, database entries). When the option is omitted the behavior is unchanged: all bots are allowed.This complements the existing
--filteroption:--filterpartitions bots across server instances bybot_user_id % modulo, whereas--allowed-bot-idsrestricts the server to an explicit allowlist, which is useful for single-tenant or private deployments.Changes
ClientParameters: addallowed_bot_user_ids_(empty means all bots allowed).telegram-bot-api.cpp: parse and validate the--allowed-bot-idsoption.ClientManager::send: reject bot ids outside the allowlist with 401.