Mule HTTP Connector - session is required to access resource - mule

I have requirement to develop mule flow to access, login, navigate and then submit form (HTTPS Post). I am using HTTP Connector configured as HTTPS with all required configurations like host/port/path/method/TSL etc. Added Query parameters which I tracked from HTTP trace in Firefox. Also set cookies as Header but I am getting A session is required to access this resource. response instead login to application.
Please find below HTTP Connector and configuration
Any suggestion?

You should not need to set cookies explicitly, and also setting them as HTTP headers will not work. First find out the type of authentication required by the service (basic, oauth, other?), then try to configure it in the HTTP connector.

Related

Keycloak fails to autenticate XHR requests

I have been scratching my head for days on this issue so thought I would try and seek some help here.
So I have a Wildfly server and an external keycloak server used for autentication.
My keycloak server uses OICD and a public client.
Usually the flow works fine, the user logs in, and subsequent resources authenticate properly with Keycloak. However the issue comes when I deploy my custom plugins to my wildfly server. Each plugin needs to authenticate to the keycloak server, usually this happens without issue on the first request. However some of my plugins are REST only, so their first request is an XHR request and this request fails as it gets redirected to the login page of keycloak which it does not understand. I am unsure how this flow is meant to work like.
If I set my XHR request withCredentials to true, it triggers CORS on my keycloak server, which is fine I have that setup correctly, however what is baffling to me is that the return request from keycloak then triggers CORS on my wildfly server, and because Keycloak redirects uses a no-refferer policy the origin is null! Setting my wildfly server to accepting null would not be acceptable.
I preferably would want a solution where each plugin would not need to authenticate towards my keycloak if the user has already done the login process but I cannot find any way of enabling session sharing between deployed plugins.

JMeter: Oauth 2.0 Token Generation- Getting Timed Out

I am trying to do API Testing by JMeter in two steps:
1. Generate Acess Token
Here, the authentication request is getting timed out.
Authentication Type: OAuth2.0
Grant Type- Client Credentials
I am passing the token URL and grant_type, client_id and client_secret in the Parameters section like this:
But I am getting the following error:
2. Hit the API with the fetched token
I am able to hit this with a token generated from POSTMAN.
Also in POSTMAN, I am able to authenticate properly. I tried recording the POSTMAN script but the authentication flow is not getting recorded. Just the GET API is working.
Is there any way to get the token in JMeter? or any other workaround?
Given you send the same requests you should get the same responses so capture the requests originating from JMeter and Postman using an external sniffer tool like Fiddler or Wireshark and compare the them.
The requests must be exactly the same including:
URL
Request Body
HTTP Headers
Inspect the requests and amend JMeter's configuration so the request would be 100% equal to what Postman sends.
Also it's possible to record Postman request or collection execution using JMeter's HTTP(S) Test Script Recorder
And last but not the least check HTTP Proxy settings for Postman, it might be the case you need to use a proxy server for accessing the authorization endpoint and the connection to the application under test is direct, Postman has proxy configured and JMeter doesn't, if this is the case - perform JMeter Proxy configuration again to match 100% Postman settings.

Prometheus returned error "server returned HTTP status 401 Unauthorized" for .NET core api

I have a .NET core api hosted in IIS which uses windows authentication. I'm using Prometheus to scrape metrics from this API. But I'm getting the error "server returned HTTP status 401 Unauthorized" for the api target. Can some help me how to configure prometheus for targets with Windows authentication?
When I tried to browse the metrics path separately, the browser is requesting for credentials and I'm able to view the metrics with my Windows authentication.
Looking at the documentation, Prometheus seems to support basic (user/password) and OAuth bearer token authentication only. If your API/IIS doesn't support any of those, then you either need to disable authentication for the /metrics path or maybe set up a proxy that only allows /metrics requests and does the authentication for you.

Optional HTTP basic authentication in JMeter

I have a request, which can be used on an endpoint with and without authentication too, but response is different in these cases. I send request to path like /MyService?wsdl. I tried to use HTTP Authorization Manager added it to HTTP Request element with whole url to this service, but it isn't working. I am sure, that username and password are correct. How is it possible to debug authentication process?
HTTP Authorisation Manager respects JMeter's Scoping Rules so make sure it is located either on the same level as HTTP Request sampler or add it as a child of this sampler (in the latter case it will be applied to this sampler only)
Configure it as follows:
Base URL: protocol followed by IP address or hostname of the application under test
Username: your username
Password: your password
Mechanism: BASIC_DIGEST
Assuming everything goes well you should see Authorization header added to your request
See How to Use HTTP Basic Authentication in JMeter article for more details.
Alternative solution is adding HTTP Header Manager and configuring it to send Authorisation header with the value of ${__base64Encode(username:password,)}
This approach assumes having __Base64Encode function installed, you can obtain it as a part of Custom JMeter Functions bundle using JMeter Plugins Manager
I suggest to use Fiddler which is a Web Debugging Proxy to send requests from JMeter through it. You can configure HTTP Request to use a proxy.
Make sure the Authorization: Basic ... header is sent within the request.
The HTTP Authorization Manager should be placed at the root of the thread group. You can then specify the full request path associated to each authorization.

Read Http Cookie from Request Stream In a WCF Service

What settings must be configured to permit Http cookies to retrieved from the Http request object in a WCF service. I am using basic Http binding. I have set aspNetCompatibilityEnabled = true and allowCookies="true". Please advise. I am certain the cookie is there with the proper domain. I have created an .aspx test page that calls my utility directly and the cookie value is returned, but calling the same code wrapped in a service does not return a value.
Are you using :
HttpContext.Current.Request.Cookies["CookieName"]?
If you are using this then there no problem.
And make sure that there is no spelling mistake.
If you are using form authentication then you have to pass token for authentication.