CompositeContentGuard should return a 401 authentication challenge when a sub-guard requires authentication
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 45/100
- issue の種類
- 機能追加
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- python
- 領域
- api, authentication, backend
調査の方向性
Read pulpcore/app/models/publication.py and pulpcore/content/handler.py, then inspect the content guard and handler tests for permission failures and cached authentication. Implement the configurable authentication challenge across composite guards and the handler. Done means missing authentication returns 401 with WWW-Authenticate, authorization denial remains 403, and an allowed sub-guard still permits access.
索引モデルが issue の本文から書いたものです。
説明
Problem
CompositeContentGuard.permit() evaluates its sub-guards with OR semantics: the first guard that passes permits the request, and if all guards fail it raises a single PermissionError. The content app handler translates that PermissionError into an HTTP 403 Forbidden.
This conflates two distinct situations:
- Authorization denied — the request has an identity, but that identity is not allowed.
403 Forbiddenis correct. - Authentication missing — the request carried no identity at all. The correct HTTP response is 401 Unauthorized with a
WWW-Authenticatechallenge, so the client knows it should authenticate and retry.
Because CompositeContentGuard only knows about PermissionError, a request that fails purely for lack of authentication still gets a flat 403. A client (e.g. a package manager, or a browser behind basic auth) never receives the WWW-Authenticate challenge and has no signal to supply credentials.
Current behavior
pulpcore/app/models/publication.py — CompositeContentGuard.permit():
for guard in self.guards.all():
detail_guard = guard.cast()
try:
detail_guard.permit(request)
return # success on first-pass
except PermissionError as pe:
errors.append(...)
# If we get here - FAIL
raise PermissionError(_("Access forbidden. Refusals: {}").format(errors))
pulpcore/content/handler.py — _permit() maps any PermissionError to HTTPForbidden (403). There is no path that produces a 401 with a WWW-Authenticate header.
Proposed behavior
- Introduce (or adopt) a distinct exception that a content guard can raise to mean "authentication required" rather than "forbidden" — e.g. an
AuthenticationErrorseparate fromPermissionError. - In
CompositeContentGuard.permit(), track whether any sub-guard raised the authentication-required error. If no guard passes and at least one raised authentication-required, re-raise that authentication error instead of the genericPermissionError. (Authorization denials still collapse toPermissionError→ 403.) - In the content handler's
_permit(), translate the authentication-required error intoHTTPUnauthorized(401) with aWWW-Authenticatechallenge header. Also update the cached-auth path so a 401 is handled like a 403 (not cached as a pass).
This preserves the OR semantics: if any guard permits, access is granted; a 401 is only returned when the sole reason for failure is missing authentication.
Reference implementation
pulp-service already carries this as a downstream patch and it works in production for packages.redhat.com:
The patch:
- Catches a new
AuthenticationErrorinCompositeContentGuard.permit(), remembers the first one, and re-raises it after the loop if no guard passed. - Catches
AuthenticationErrorinhandler._permit()and raisesHTTPUnauthorizedwithWWW-Authenticate: Basic realm="packages.redhat.com". - Updates
auth_cached()to treatHTTPUnauthorizedlikeHTTPForbiddenand to avoid caching when the guard result is indeterminate.
Upstreaming this would require a general mechanism (the realm / challenge value should be configurable rather than hard-coded), but the core behavior — a composite guard surfacing an authentication challenge instead of a blanket 403 — belongs in pulpcore.
- 主要言語
- Python
- スター
- 612
- フォーク
- 175
- 平均マージ
- 15時間 47分
- マージ済み PR(30日)
- 117
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
pulp/pulpcore のほかの issue
-
Issue
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
Feature
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
pulp/pulpcore#5802 · コメント 10 件 ·
メンテナーはふだん 1 日以内に返信
-
Content app answers 404 instead of 502 when the remote of on-demand content is unavailable対応中かも @gigi206 が 12 日前に担当しました。 オープンTriage-Needed
難易度 3/5 半日 初心者へのやさしさ 66/100
メンテナーはふだん 1 日以内に返信
-
Issue
難易度 4/5 3〜5日 初心者へのやさしさ 28/100
pulp/pulpcore#8214 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Performance Task
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
pulp/pulpcore#8206 · コメント 3 件 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
似ている issue
-
request-theme
難易度 1/5 1時間未満 初心者へのやさしさ 66/100
LizardByte/ThemerrDB#9575 ·
メンテナーはふだん 1 日以内に返信
-
author-page correction
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
acl-org/acl-anthology#10599 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
zilliztech/memsearch#818 ·
メンテナーはふだん 1 日以内に返信
-
[FAQ] Commit ID for Projects対応中かも @github-actions が今日担当しました。 オープンfaq-proposal
難易度 1/5 1時間未満 初心者へのやさしさ 84/100
DataTalksClub/faq#503 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
README.zh-CN/ja/es still hard-code 501 test counts after README.md went count-free対応中かも @Aaqibhafeezkhan が今日担当しました。 オープンbeginner documentation good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
BistaDinesh03/critique#164 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信