Restrict SOURCE_PDF access to admins across activity and document endpoints#38
Merged
milljoniaer merged 3 commits intomainfrom Mar 27, 2026
Merged
Conversation
Co-authored-by: milljoniaer <78978542+milljoniaer@users.noreply.github.com> Agent-Logs-Url: https://github.com/ls1intum/LEARN-Hub/sessions/b3e34c37-f19f-455a-a34c-6c92f6aa7039
Copilot
AI
changed the title
[WIP] Exclude source pdf for non-admin users from activity response
Restrict SOURCE_PDF access to admins across activity and document endpoints
Mar 26, 2026
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.
SOURCE_PDF documents were accessible to non-admin users via activity GET responses and the document info endpoint. This PR enforces admin-only access at both layers.
Changes
Activity GET responses
ActivityControllerpassesisAdmin(authentication)asincludeSourcePdfflag for bothGET /api/activities/andGET /api/activities/{id}ActivityService.mapToResponse()filters out SOURCE_PDF documents whenincludeSourcePdf=falseDocumentsController — download endpoint
enforceDownloadAccess()throwsAccessDeniedExceptionfor non-admins attempting to download SOURCE_PDF documentsDocumentsController — info endpoint (new protection)
GET /api/documents/{documentId}/infonow also callsenforceDownloadAccess(), preventing metadata leakage (filename, size, confidence score) to non-adminsAuthenticationparameter and@SecurityRequirementannotation; re-throwsAccessDeniedExceptionto bypass the genericcatch (Exception e)→ 404 handlerTests
mapToResponseIncludesSourcePdfDocumentsForAdminto verify admins (includeSourcePdf=true) do receive SOURCE_PDF entries in the documents listWarning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
jfrog-prod-use1-shared-virginia-main.s3.amazonaws.com/usr/lib/jvm/temurin-21-jdk-amd64/bin/java /usr/lib/jvm/temurin-21-jdk-amd64/bin/java --enable-native-access=ALL-UNNAMED -classpath /home/REDACTED/.m2/wrapper/dists/apache-maven-3.9.11/a2d47e15/boot/plexus-classworlds-2.9.0.jar -Dclassworlds.conf=/home/REDACTED/.m2/wrapper/dists/apache-maven-3.9.11/a2d47e15/bin/m2.conf -Dmaven.home=/home/REDACTED/.m2/wrapper/dists/apache-maven-3.9.11/a2d47e15 -Dlibrary.jansi.path=/home/REDACTED/.m2/wrapper/dists/apache-maven-3.9.11/a2d47e15/lib/jansi-native -Dmaven.multiModuleProjectDirectory=/home/REDACTED/work/LEARN-Hub/LEARN-Hub/server org.codehaus.plexus.classworlds.launcher.Launcher clean compile -q(dns block)/usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java -Dfile.encoding=UTF-8 -Xms256M -Xss8M -Djdk.util.zip.disableZip64ExtraFieldValidation=true -Dsun.misc.unsafe.memory.access=allow --add-opens java.base/sun.reflect.annotation=ALL-UNNAMED -Xmx14579m -classpath /opt/hostedtoolcache/CodeQL/2.24.3/x64/codeql/java/tools/semmle-extractor-java.jar:/opt/hostedtoolcache/CodeQL/2.24.3/x64/codeql/java/tools/lombok-javac-extend.jar com.semmle.extractor.java.JavaExtractor --jdk-version 17 --javac-args @@@/tmp/codeql-scratch-21fe057196e5a270/dbs/java/log/ext/javac.args earnhub/documentgit earnhub/document-c earnhub/documentcore.quotePath=false earnhub/documentdiff(dns block)If you need me to access, download, or install something from one of these locations, you can either:
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.