Spring Cloud Gateway - Discard request based on header value - filter

In a project, I am using spring cloud gateway. I need to discard some requests based on a header value as below:
-If a specific header(say myval1) is not present, discard the request
-If a specific header(say myval1) is present but the value does not match one of a set of values discard the request
-If a specific header(say myval1) is present and the value matches one of a set of values route the request
Normally I would implement a predicate but in my case, the value set to be checked is dynamic means each time I have to check against changing values. In this condition, how can I achieve this feature?
Thanks!

Related

Unable to access POST parameter values - IIB Esql

So I'm quite new to IIB and Extended SQL but what I want to do should be straight forward. I have a REST application which has a resource that is attached to a subflow. What I want to do is to get the input value passed to the service and use it to call a remote web service using the HTTP request node as shown below
SET OutputLocalEnvironment.Destination.HTTP.RequestLine.Method = 'POST';
SET OutputLocalEnvironment.Destination.HTTP.RequestURL = 'http://localhost:8002/MyService';
SET OutputLocalEnvironment.Destination.HTTP.QueryString.RemoteParam= InputLocalEnvironment.REST.Input.Parameters.myValue;
What is happening is, when I call the REST method and pass the value as a GET, I'm able to access the value. However, when I pass the parameter value using POST, I'm unable to access the value. My current flow is as follows:
Input > Compute > HTTPRequest > Compute > Output
I have searched on Google and applied all recommendations (e.g. setting compute node to LocalEnvironment) but nothing seems to work.
Well, we need more information in order to solve your problem but I guess you have problem in your HTTP request node
Go to HTTP request then in properties go to HTTP setting and change HTTP method to the method that you are using ( get or post )
and if you want to see if you are fetching data from right property just lunch debugger and put breakepoint in before and after of your nodes, then you can see what data you are receiving in each level and you can call the proper property.
ps. don't forget to deploy your project again in order to see new
changes
I hope that works for you
After further research, I found that IIB does not automatically parse content submitted as application/x-www-form-urlencoded. I inserted a trace node and realised that the parameters are instead submitted as a BLOB. All I had to do was read the blob, cast it to a string then use a Split function or a message model to get the individual parameters. Thanks for the pointers

Is it possible to return an error for an extra query parameter shows up in light-4j request

I have a question about the light-rest-4j URL validation, for example, if I have a POST request path /party, if I type the path as /party11, I will get error: No handler defined for path /party11, but if I put /party?qqqq, It will pass through, and system treat it as /party should we add validation for this? Our QA team creates this as a defect, in case user input it by mistake, they expect to have error message return.
The light-rest-4j framework validates the request/response based on the OpenAPI specification during the runtime; however, it only validates based on the spec — nothing more and nothing less. In most cases, the spec will define the type of headers, query parameters, path parameters, and cookies, as well as if they are required. We make sure these are validated as defined. For anything that is not defined in the spec, we are doing nothing. For example, an extra query parameter or an extra header in the request will be ignored as they are not defined in the spec. We cannot do any negative validation as we don't know if any client will add additional headers or query parameters for tracing, auditing, etc. A request that comes from one client might be different than another one comes from the same client through a gateway or proxy.

AWS WebSocket API Gateway Template Selection Expressions examples

AWS API Gateway service page says that a Template Selection Expression can be used to implement a way to transform the request body. However the documentation for these selection expressions is very light and I haven't been able to find any examples.
Where can I find examples of what these expressions look like?
Where can I find what variables and options are available in these expressions?
To add content to the integration request, you'll need to use a Request Template. The Request Template is the piece that actually generates the new request body, while the Request Selection Template is used in the process of determining which Request Template to use.
Turn off HTTP Proxy Integration for your route. (You can't modify the request otherwise.)
Save your changes. (the Request Templates section won't appear until you do so.)
Set your Template Selection Expression. This is used to look up a value from the incoming request object. (If you want to match all incoming requests, enter \$default. Note the slash. Full documentation here.)
Set your Template Key. This is compared against the value selected by the Template Selection Expression. If it's a match, the template is used. (If you want to match all incoming requests, enter $default. Note the absence of a slash.)
Click your Template Key to open the template editor. This is where you enter your template that will be sent to your integration endpoint as the body of the request. For example, if you want to forward the connection ID and the incoming query parameters to the integration endpoint, you can use the following:
{
"myConnectionIdProperty": "$context.connectionId",
"myQueryParams": $input.params()
}
Documentation for variables available to you in the template expression can be found here.
(Note that while $request is a valid variable in the Template Selection Expression, it is not a valid variable in the template itself. Use $input instead there.)
Basically Template Selection Expression works same as Route Selection Expression. All examples for Route Selection Expression will work.
https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-websocket-api-selection-expressions.html#apigateway-websocket-api-route-selection-expressions
In addition to it, TemplateSelectionExpression for integration response supports few more variables:
$integration.response.statuscode
$integration.response.header.headerName
$integration.response.multivalueheader.headerName

Can Jmeter LDAP Request or LDAP Extended Request populate a multi-valued attribute?

I am working on a Jmeter LDAP test plan and the test plan has to populate an attribute on the LDAP that is multi-valued.
When I do an LDAP search sampler, I noted that the value I get back is a string, with the values separated by ", ".
But, if I take the same comma-separated string and try to do an LDAP modify or add, using either an LDAP Request or LDAP Extended Request, I get an error.
So I am wondering if there is a way that the Jmeter LDAP Request or LDAP Extended Request can do that?
Thanks,
Jim
EDIT: When I try to use an Extended LDAP Request modification test/add with the attribute of "", I get this error in the Jmeter GUI response:
When attempting to modify entry cn=xxx... to replace the set of values for attribute lastlogindate, value "20181023085627-04, 20181024063205-04" was found to be invalid according to the associated syntax: The provided value "20181023085627-04, 20181024063205-04" is not a valid generalized time value because it contains an invalid character '-' at position 14
The strange part is that even though I have Jmeter to log at debug level, I don't see any detail on the error in the Jmeter.log, but/so I am guessing that that error message is coming from the Jmeter client itself. I noticed that the message says:
to replace the set of values
so it seems like it recognizes that I am trying to modify/replace a multi-value, but it doesn't seem to like the syntax of the replacement values string(s).
Does anyone know what the correct format SHOULD be?
I found the answer to my own question, or at least "A" answer: It appears that I can use an Extended LDAP request, and add the same attribute in that request, multiple times. So for example, if I am populating an attribute named "foo" the Extended LDAP request would have the following:
attribute value opcode
foo 12345 add
foo 12346 add
etc.
I think I also need to do a replace with no value, to empty the attribute, before all the adds.

Nifi: Route on Attribute processor to wrong processor

I am testing a flow in NIFI that checks for specific value of a counter using REST API. I am able to extract it correct value from REST response. However, when I check the condition in Route on Attribute processor, the expected matched condition's results are routing to unmatched processor.
Attached is the :
Flow and configuration
I have already checked my response to be "1". But its routing to unmatched branch.
Is there something wrong with NIFI expression language I am using?
Jasim,
Initial setup check counter attribute in which value is 1.
And modify the expression language like ${counter:equals('1')} or ${counter:matches('1')} instead of contains.
because contains not suitable for your scanerio.
Hope this helpful for you.

Resources