Use Telegram numeric user IDs for whitelist authorization#34
Merged
krotname merged 1 commit intoJun 25, 2026
Merged
Conversation
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.
Motivation
usernamevalues by switching the access control trust boundary to immutable numeric Telegram user IDs loaded from operator-controlled configuration.Description
src/telegram_resender/whitelist.pyby addingparse_user_id, storinguser_ids, and makingcontainsaccept numeric IDs.idtoUserProfileinsrc/telegram_resender/models.py, populate it inincoming_from_messageinsrc/telegram_resender/app.py, and updateResenderService.handle_textinsrc/telegram_resender/service.pyto deny missinguser.idand check membership with the numeric id.normalize_usernameand updatingsrc/telegram_resender/routes.pyto accept an optionalusernameparameter for matching.user_idscounts (src/telegram_resender/cli.py), add tests asserting IDs are used and usernames are rejected as authorization identifiers, and update docs andwhitelist.example.csvto instruct operators to use numeric Telegram user IDs.Testing
PYTEST_ADDOPTS='' pytest -q -o addopts='' tests/unit/test_whitelist.py tests/unit/test_service.py tests/integration/test_bootstrap.py tests/unit/test_cli.py, and the targeted suite passed (16 passed, 1 warning).pytestrun in this environment failed only because the container lacks the optional dev dependencypytest-asyncio; async tests require that plugin and should pass when dev dependencies are available in CI or a developer environment.python3 -m mypy src testsandpython3 -m ruff check .and formatting checks withpython3 -m ruff format --check ..python3 -m pip install -e '.[dev]'could not be completed here due to blocked network access to package indices, so dependency installation was not verified in this environment.Codex Task