[MINOR] Tighten origin and content-type handling in REST/WebSocket layer#5229
Draft
jongyoul wants to merge 1 commit intoapache:masterfrom
Draft
[MINOR] Tighten origin and content-type handling in REST/WebSocket layer#5229jongyoul wants to merge 1 commit intoapache:masterfrom
jongyoul wants to merge 1 commit intoapache:masterfrom
Conversation
Apply stricter defaults to the request-handling layer: - CorsFilter blocks state-changing methods (POST/PUT/DELETE/PATCH) and cross-origin preflight requests when the Origin header is not in the configured allow-list. Access-Control-Allow-Credentials is only sent when the Origin is allowed. - The default value of zeppelin.server.allowed.origins changes from "*" to empty so cross-origin browser access must be explicitly enabled. Operators relying on the previous default need to set this back to "*" or to specific origin(s). Same-origin/same-host and non-browser clients are unaffected. - A new request filter restricts REST request bodies on state-changing methods to application/json, application/x-www-form-urlencoded, or multipart/form-data; other media types are rejected with 415. - The default shiro.ini.template now sets cookie.sameSite = LAX. - ZeppelinClient.addParagraph and updateParagraph now send an explicit Content-Type: application/json header so they pass the new filter. - CorsUtils.isValidOrigin normalizes the Origin header to lowercase before the allow-list membership check, mirroring how the configured origins are stored, so case differences in the Origin header do not produce false rejections. - A small HttpMethods utility holds the shared STATE_CHANGING method set used by both the servlet filter and the Jersey filter.
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.
What is this PR for?
Apply stricter defaults to the request-handling layer for tighter out-of-the-box behavior:
CorsFilterblocks state-changing methods (POST/PUT/DELETE/PATCH) and cross-origin preflight requests when theOriginheader is not in the configured allow-list.Access-Control-Allow-Credentialsis only sent when theOriginis allowed.zeppelin.server.allowed.originschanges from*to empty so cross-origin browser access must be explicitly enabled. Operators relying on the previous default need to set this back to*or to specific origin(s). Same-origin / same-host and non-browser clients are unaffected.application/json,application/x-www-form-urlencoded, ormultipart/form-data; other media types are rejected with415.shiro.ini.templatenow setscookie.sameSite = LAX.ZeppelinClient.addParagraphandupdateParagraphnow send an explicitContent-Type: application/jsonheader so they pass the new filter.CorsUtils.isValidOriginnormalizes theOriginheader to lowercase before the allow-list membership check, mirroring how the configured origins are stored, so case differences in theOriginheader do not produce false rejections.HttpMethodsutility holds the sharedSTATE_CHANGINGmethod set used by both the servlet filter and the Jersey filter.What type of PR is it?
Improvement
Todos
Questions
Screenshots (if appropriate)
N/A