11.5. Login Which Requires a Hidden Value From the Login Page
Extracts a hidden value from the login page and includes it in the login form POSTed to the target application.
{
"heap": {
"objects": [
{
"name": "HandlerServlet",
"comment": "Entry point that transforms Servlet request to handler request.",
"type": "HandlerServlet",
"config": {
"handler": "DispatchHandler",
"baseURI":"http://TARGETIP"
}
},
{
"name": "DispatchHandler",
"type": "DispatchHandler",
"config": {
"bindings": [
{
"condition": "${exchange.request.uri.path == '/login'}",
"handler": "LoginChain",
},
{
"handler": "OutgoingChain",
},
]
}
},
{
"name": "LoginChain",
"type": "Chain",
"config": {
"filters": ["HiddenValueExtract","LoginRequest"],
"handler": "OutgoingChain"
}
},
{
"name": "HiddenValueExtract",
"type": "EntityExtractFilter",
"config": {
"messageType": "response",
"target": "${exchange.hiddenValue}",
"bindings": [
{
"key": "value",
"pattern": "wpLoginToken\"\s.*value=\"(.*)\"",
"template": "$1"
}
]
}
},
{
"name": "LoginRequest",
"type": "StaticRequestFilter",
"config": {
"method": "POST",
"uri": "https://TARGETIP/login",
"form": {
"USER": ["myusername"],
"PASSWORD": ["mypassword"],
"hiddenValue": ["${exchange.hiddenValue.value}"],
}
}
},
{
"name": "OutgoingChain",
"type": "Chain",
"config": {
"filters": ["CaptureFilter"],
"handler": "ClientHandler"
}
},
{
"name": "CaptureFilter",
"type": "CaptureFilter",
"config": {
"captureEntity": false,
"file": "/tmp/gateway.log",
}
},
{
"name": "ClientHandler",
"comment": "Responsible for sending all requests to remote servers.",
"type": "ClientHandler",
"config": {
}
}
]
},
"servletObject": "HandlerServlet",
}

