Hi,
The
DefaultSecurityClientFinder class uses following code to search for
force_client parameter in client request:
final var clientOnRequest = context.getRequestParameter(clientNameParameter);This method wraps on
request.getParameter() in
JEEContext. The
getParameter() searchs parameter in URL query AND in request form:
I'm wondering if it is a good idea to use that method.
Javadoc says following:
[...] For HTTP servlets, parameters are contained in the query string or posted form data. source:
https://docs.oracle.com/javaee/6/api/javax/servlet/ServletRequest.html#getParameter(java.lang.String)If the goal of that is to read
force_client in URL parameters, it may be safer to parse URL directly. Now if
force_client is expected in form data, then this means that payload must combine business data and authentication logic data, which is imho a bad idea.
More problematic, the
getParameter() has a side effect on request payload: the reading of parameter in form data consumes the request input stream. This makes that input stream unreadable for application. For instance, I get empty result if I try to read it with following code:
try (InputStream in = request.getInputStream()) {
return IOUtils.toString(in, charset);
}
But if I try to read the payload just before the
getRequestParameter() call, I can get data.
Now I can work arround by simply not defining
clients init-param in my
web.xml, but I think it would be a safer method to get that parameter by either parsing URL query string or searching for
force_client in request header.