feat(licenses): gate release asset downloads behind license key when licensing enabled #347

Closed
opened 2026-05-31 15:31:44 +00:00 by jmiller · 2 comments
Owner

Summary

When licensing is enabled and RequireKey is on for a repo, prevent unauthenticated/unauthorized users from directly downloading release assets (.zip files). Currently, anyone with the direct URL can download even without a valid license key.

Behavior

  • Logged-in users: Can always download (they have the repo in their dashboard)
  • Anonymous users with valid ?dlid= key: Can download (key is validated against the license system)
  • Anonymous users without key: Get a 403 or redirect to a "license required" page

Implementation

Add middleware to the release asset download route that checks:

  1. If licensing is enabled and RequireKey is on for the repo
  2. If the user is authenticated (allow)
  3. If a dlid/key query param is present and valid (allow)
  4. Otherwise reject

Claude Opus 4.6 (1M context) noreply@anthropic.com

## Summary When licensing is enabled and RequireKey is on for a repo, prevent unauthenticated/unauthorized users from directly downloading release assets (.zip files). Currently, anyone with the direct URL can download even without a valid license key. ### Behavior - **Logged-in users**: Can always download (they have the repo in their dashboard) - **Anonymous users with valid `?dlid=` key**: Can download (key is validated against the license system) - **Anonymous users without key**: Get a 403 or redirect to a "license required" page ### Implementation Add middleware to the release asset download route that checks: 1. If licensing is enabled and RequireKey is on for the repo 2. If the user is authenticated (allow) 3. If a `dlid`/`key` query param is present and valid (allow) 4. Otherwise reject --- *Claude Opus 4.6 (1M context) <noreply@anthropic.com>*
Author
Owner

Testing Plan — Download Gating

API

  • Gating=none: GET /releases/download/v1.0/file.zip → 200 (no key needed)
  • Gating=all: GET same without key → 403
  • Gating=all: GET same with ?dlid=VALIDKEY → 200
  • Gating=all: GET same with ?dlid=INVALIDKEY → 403
  • Gating=prerelease: stable tag download without key → 200
  • Gating=prerelease: RC tag download without key → 403
  • Gating=prerelease: RC tag download with key → 200
  • Archive download (/archive/v1.0.zip) follows same gating rules
  • Gating respects effective config (repo override → org default)

GUI

  • Download gating dropdown in repo settings (none/prerelease/all)
  • Download gating dropdown in org settings
  • Help text explains each mode

🤖 Generated with Claude Code

## Testing Plan — Download Gating ### API - [ ] Gating=none: GET /releases/download/v1.0/file.zip → 200 (no key needed) - [ ] Gating=all: GET same without key → 403 - [ ] Gating=all: GET same with ?dlid=VALIDKEY → 200 - [ ] Gating=all: GET same with ?dlid=INVALIDKEY → 403 - [ ] Gating=prerelease: stable tag download without key → 200 - [ ] Gating=prerelease: RC tag download without key → 403 - [ ] Gating=prerelease: RC tag download with key → 200 - [ ] Archive download (/archive/v1.0.zip) follows same gating rules - [ ] Gating respects effective config (repo override → org default) ### GUI - [ ] Download gating dropdown in repo settings (none/prerelease/all) - [ ] Download gating dropdown in org settings - [ ] Help text explains each mode 🤖 Generated with [Claude Code](https://claude.com/claude-code)
jmiller added the pending: testing label 2026-06-01 10:13:49 +00:00
jmiller reopened this issue 2026-06-02 11:21:40 +00:00
Author
Owner

Tested and verified in production on MokoWaaS. All three download gating modes (none/prerelease/all), feed visibility, XML metadata, download URLs, and access control confirmed working.

Tested and verified in production on MokoWaaS. All three download gating modes (none/prerelease/all), feed visibility, XML metadata, download URLs, and access control confirmed working.
Sign in to join this conversation.
No labels pending: testing
Status
Status
Priority
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: MokoConsulting/MokoGitea#347