Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #11266 - allow context attributes to be used to configure max form (content size / keys) #11274

Closed

Conversation

joakime
Copy link
Contributor

@joakime joakime commented Jan 15, 2024

PROOF OF CONCEPT

This is likely incomplete and certainly not tested (yet).

  • Allows these common configurations to be set via WEB-INF/web.xml without the need for a WEB-INF/jetty-web.xml

The configuration in the WEB-INF/web.xml would look like this ...

<?xml version="1.0" encoding="UTF-8"?>
<web-app 
   xmlns="http://xmlns.jcp.org/xml/ns/javaee" 
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
   metadata-complete="false"
   version="3.1">

  <context-param>
    <param-name>org.eclipse.jetty.server.Request.maxFormContentSize</param-name>
    <param-value>1000000</param-value>
  </context-param>

  <context-param>
    <param-name>org.eclipse.jetty.server.Request.maxFormKeys</param-name>
    <param-value>2000</param-value>
  </context-param>
 
  <!-- ... other config ... -->
</web-app>

…orm (content size / keys)

+ Allows these common configurations to be set via `WEB-INF/web.xml` without the need for a `WEB-INF/jetty-web.xml`

Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
@@ -215,8 +216,8 @@ private enum ProtectedTargetType
private String[] _vconnectors; // connector portion, matching _vhosts array
private Logger _logger;
private boolean _allowNullPathInfo;
private int _maxFormKeys = Integer.getInteger(MAX_FORM_KEYS_KEY, DEFAULT_MAX_FORM_KEYS);
private int _maxFormContentSize = Integer.getInteger(MAX_FORM_CONTENT_SIZE_KEY, DEFAULT_MAX_FORM_CONTENT_SIZE);
private int _maxFormKeys = MAX_FORM_UNSET;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change would prevent the use of System properties being used, which would be removal of long released behaviour. You could just add in support for the context attributes, or we could punt this in favour of a different solution for jetty-web.xml.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The support for these two System properties was just moved to the doStart() location, not removed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see it now in doStart(). However, I don't think we should be doing this development in jetty-10, if we're doing it, it should be in jetty-12.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a possible solution for what was brought up in Issue #11274, which meant it should be done in Jetty 10 thru Jetty 12.

But the OP (@vmassol) made some good points (see #11266 (comment)) and has convinced me that the approach in this PR isn't a great solution.

I'm totally OK with this being only for Jetty 12.
Want me to recreate this for Jetty 12 only? or drop it as a concept?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO we should do it for 12, and also update the doco for it with the new context attributes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do, and I'll add unit tests!

@@ -215,8 +216,8 @@ private enum ProtectedTargetType
private String[] _vconnectors; // connector portion, matching _vhosts array
private Logger _logger;
private boolean _allowNullPathInfo;
private int _maxFormKeys = Integer.getInteger(MAX_FORM_KEYS_KEY, DEFAULT_MAX_FORM_KEYS);
private int _maxFormContentSize = Integer.getInteger(MAX_FORM_CONTENT_SIZE_KEY, DEFAULT_MAX_FORM_CONTENT_SIZE);
private int _maxFormKeys = MAX_FORM_UNSET;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see it now in doStart(). However, I don't think we should be doing this development in jetty-10, if we're doing it, it should be in jetty-12.

@joakime
Copy link
Contributor Author

joakime commented Jan 17, 2024

Closing, will be a feature introduced in Jetty 12 instead.

@joakime joakime closed this Jan 17, 2024
@vmassol
Copy link

vmassol commented Feb 27, 2024

@joakime Hello. Thanks again for working on this. Do you know if the feature has now been integrated in Jetty 12 or not yet? I checked the release notes but couldn't see it (but I could have missed it). For the context, we're still stuck with #11266 and any solution would work for us, even context attributes :) thx!

@joakime joakime deleted the fix/10.0.x/maxform-configs-as-context-attributes branch February 28, 2024 13:11
@vmassol
Copy link

vmassol commented May 31, 2024

@joakime gentle ping to know if this feature has been added in Jetty 12, see #11274 (comment) Thx!

@joakime
Copy link
Contributor Author

joakime commented Jun 13, 2024

@joakime gentle ping to know if this feature has been added in Jetty 12, see #11274 (comment) Thx!

See replacement PR #11898

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

3 participants