fix(security): deny unauthenticated access by default#326
Draft
Isaries wants to merge 2 commits into
Draft
Conversation
The authorization chain listed specific paths and ended without a final rule, so any request matching none of the rules was permitted. Most /api endpoints matched no rule and relied entirely on method-level annotations, so any endpoint missing an annotation was reachable without authentication. Add an explicit allow list for the endpoints that must remain public (sign-in and its OAuth callbacks, registration, account and password recovery, the contact form, the public home, news, library and preview content, and the bootstrap configuration) and require authentication for every other request, so a missing method annotation fails closed.
Denying unmatched requests by default also caught the static asset paths served by the resource handlers configured in WebConfig (portal scripts, themes and translations, the runtime engine, project files and project icons). Those are public content that the login page and the anonymous project preview need, so blocking them would break sign-in and preview for signed-out visitors. Permit those paths explicitly. Student uploaded files are intentionally left requiring authentication.
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.
Summary
The security configuration had no default-deny rule, so any request that did not match a specific rule was permitted. Endpoints were therefore exposed unless someone remembered to restrict them explicitly. This denies unmatched requests by default and adds an explicit allowlist of the endpoints that must stay public.
Changes
anyRequest().authenticated()as the final rule, with an allowlist of the genuinely public endpoints: sign-in and its OAuth callbacks, account registration, account and password recovery, the contact form, the public home, news, library and preview content, and the application bootstrap configuration.Why this is a draft
This changes runtime access for every path that does not match an explicit rule, so it needs verification on a running instance before merging:
Testing
mvnw package).