Cap and throttle channel tokens on the public v1 channel list

未关闭
#6,418 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
72/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
python

调研方向

Start with contentcuration/kolibri_public/views_v1.py, especially _get_channel_list_v1 and get_public_channel_lookup, then inspect the project’s DRF throttling configuration and tests for these endpoints. Check how cache_page affects list throttling. Done means requests with 51 tokens return 400, each endpoint limits anonymous requests to 60 per minute per IP, and tests cover the 50/51 token boundary and rate limits.

由索引模型根据 Issue 内容生成。

描述

DEV: backend

Overview

/api/public/v1/channels accepts any number of channel tokens in its tokens parameter, with no login and no rate limit, and reports which tokens matched. The v1 lookup endpoint checks one token per request, also without a rate limit. Unlisted channel tokens come from a space of 2^32 values, so a client can test hundreds of guesses per request without limit.

Complexity: Low
Target branch: hotfixes

Context
  • _get_channel_list_v1 splits tokens on commas with no limit, and matches them against secret tokens.
  • get_public_channel_lookup (/api/public/v1/channels/lookup/<token>) also matches one token per request, anonymously and without a rate limit.
  • Studio configures no DRF throttling. The channel list is wrapped in cache_page, so a repeated identical URL is served from cache before any DRF throttle runs.
The Change
  • tokens should accept at most 50 tokens per request.
  • The v1 channel list and the v1 channel lookup should each be throttled to 60 anonymous requests per minute per IP, using DRF throttling.
Acceptance Criteria
General
  • A request with more than 50 tokens returns 400.
  • The 61st channel list request from one IP within a minute, each with a different tokens value, returns 429.
  • The 61st channel lookup request from one IP within a minute returns 429.
  • Requests with up to 50 tokens and within the rate return the same response as before.
Testing
  • Tests cover 50 and 51 tokens, and requests over the rate on both endpoints.

AI usage

I set the token cap and the rate. Claude Code found this gap and drafted this issue.

主要语言
Python
星标
212
派生
321
平均合并
1 天 7 小时
30 天内合并 PR
14

环境准备

  • 提供 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

learningequality/studio 的其他 Issue

查看 learningequality/studio 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。