-
Notifications
You must be signed in to change notification settings - Fork 167
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
feat: Bring back vaadin servlet mapping behind feature flag #14694
feat: Bring back vaadin servlet mapping behind feature flag #14694
Conversation
* fix: Only map websockets to servlet path and not any sub paths (cherry picked from commit f4c7497)
flow-server/src/main/java/com/vaadin/experimental/FeatureFlags.java
Outdated
Show resolved
Hide resolved
flow-server/src/main/java/com/vaadin/experimental/FeatureFlags.java
Outdated
Show resolved
Hide resolved
...spring/src/main/java/com/vaadin/flow/spring/security/VaadinWebSecurityConfigurerAdapter.java
Outdated
Show resolved
Hide resolved
Co-authored-by: Artur <artur@vaadin.com>
vaadin-spring/src/main/java/com/vaadin/flow/spring/FeatureFlagsUtil.java
Outdated
Show resolved
Hide resolved
…sUtil.java Co-authored-by: sonatype-lift[bot] <37194012+sonatype-lift[bot]@users.noreply.github.com>
…ervlet-behind-feature-flag' into feature/14641-bring-back-vaadinServlet-behind-feature-flag
For sake of Quarcus and other non-spring applications JSR356_PATH_MAPPING_LENGTH has been moved to general Atmosphere init parameters in PushRequestHandler Co-authored-by: Marco Collovati <marco@vaadin.com>
…-back-vaadinServlet-behind-feature-flag
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
@@ -58,6 +58,9 @@ | |||
public class VaadinServletConfiguration { | |||
|
|||
static final String VAADIN_SERVLET_MAPPING = "/vaadinServlet/*"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can VAADIN_SERVLET_MAPPING
be removed?
if (rootMapping | ||
&& isPushServletMappingEnabled(context.getEnvironment())) { | ||
// in the case of root mapping, push requests should go to | ||
// /vaadinServlet/pushUrl |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// /vaadinServlet/pushUrl | |
// /VAADIN/push/pushUrl |
.replace("/*", ""); | ||
customPushUrl = customPushUrl.replaceFirst("context://", "/"); | ||
customPushUrl = customPushUrl.replaceFirst(Pattern.quote(mapping), | ||
""); // if workaround "/vaadinServlet/myCustomUrl" used |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
""); // if workaround "/vaadinServlet/myCustomUrl" used | |
""); // if workaround "/VAADIN/push/myCustomUrl" used |
@@ -0,0 +1,4 @@ | |||
server.port=8888 | |||
vaadin.exclude-urls=/swagger-ui/** | |||
vaadin.pushServletMapping=true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd propose "nonRootPushServletMapping" (or vice versa - "pushRootServletMapping", true by default) as a name for this parameter, because "pushServletMapping" doesn't tell much about its meaning. Also, not "pushServletMapping=false" doesn't make sense, since mapping is always there.
@@ -84,7 +84,7 @@ public ServletRegistrationBean<SpringServlet> servletRegistrationBean( | |||
String pushRegistrationPath; | |||
|
|||
if (rootMapping) { | |||
mapping = VaadinServletConfiguration.VAADIN_SERVLET_MAPPING; | |||
mapping = VaadinServletConfiguration.VAADIN_SERVLET_PUSH_MAPPING; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mapping
is used here not for push endpoint, but for SpringServlet registration, which is fine.
Apart from Push, it is fine to have /vaadinServlet
mapped spring servlet.
We only talk about mapping path for JSR356_MAPPING_PATH
, it should be changed, not the spring servlet.
Or I terribly missed something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So in my opinion you should change pushRegistrationPath
to include /VAADIN/push
in case of root mapping, but not mapping
itself.
protected boolean isPushServletMappingEnabled(Environment environment) { | ||
if (SpringUtil.isSpringBoot()) { | ||
try { | ||
return (boolean) Class.forName( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why we have to do this? Isn't VaadinConfigurationProperties
instance available in the context where the method isPushServletMappingEnabled
is needed?
makeContextRelative(mapping.replace("*", ""))); | ||
} | ||
|
||
mapping = VaadinServletConfiguration.VAADIN_SERVLET_PUSH_MAPPING; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mapping
should be "/vaadinServlet", because it corresponds to the servlet, not to the push registration.
pushRegistrationPath
should be modified.
if (configurationProperties.isPushServletMapping()) { | ||
initParameters.put(ApplicationConfig.JSR356_MAPPING_PATH, | ||
mapping.replace("/*", "")); | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did I understand correctly that if I've set a custom vaadin url mapping (e.g. /ui/*
), the mapping for PUSH will be the on /ui/*
and not on /ui/VAADIN/push
?
If so, the AJP reverse proxy configuration will still have the same problem of missing a dedicate path for websockets
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it would be /ui/*
and it was so in the past even with /vaadinServlet
. So seems like if someone uses AJP with non root url mapping, this fix wouldn't work (as it wouldn't work even with old code with /vaadinServlet
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if we add VAADIN/push
always when this new parameter is turned on?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, it seems more consistent to me
Closing a PR due to approach change. New PR will be created. |
Description
As there is a need to support custom servlet mapping after it has been removed (#14602) - it has been bring back behind feature flag.
Fixes #14641
Type of change
Checklist
Additional for
Feature
type of change