Forum Discussion
deflate/inflate data in an irule
I'd like to decode a SAML request from an iRule. The reason is that I'd like to synthesize a SAML response when the user has no valid session. The problem is that the SAML request, passed as an url parameter, is deflated and b64 encoded. B64decoding it is easy but I can't find how to decompress the deflated data. TCL v4.6 would include the zlib package which has a "zlib inflate" command, but big-ip up to v13 only has tcl4.5 and I can't find any way to inflate data. Is there any way to "load" the zlib package or use some other mechanism to inflate data in an irule?
Can you provide an example of the SAML request?
Are you using Access Policy Manager to receive the SAML request?
- cjunior
Nacreous
Hi, I don't know your exactly goal to the SAML, but maybe you can do the deflate/inflate with the zlib library from node.js with iRule LX. In the example below, I just created a workspace, plugin then an iRule and it has worked (at least on my lab :).
I hope it helps!
My iRule LX scenario hierarchy:
ilx_plugin ilx_workspace ilx_extension index.js rules ilx_rule
index.js
'use strict' var f5 = require('f5-nodejs'); var zlib = require('zlib'); var ilx = new f5.ILXServer(); ilx.addMethod('deflate_b64', function(req, res) { var zip64 = zlib.deflateSync(req.params()[0]).toString('base64'); res.reply(zip64); }); ilx.addMethod('inflate_b64', function(req, res) { var unzip = zlib.inflateSync(new Buffer(req.params()[0], 'base64')).toString(); res.reply(unzip); }); ilx.listen();
ilx_rule
when HTTP_REQUEST { set handle [ILX::init "ilx_plugin" "ilx_extension"] set b64response [ILX::call $handle "deflate_b64" "My string to deflate and base64 encoding"] log local0. "Deflate response: $b64response" set response [ILX::call $handle "inflate_b64" $b64response] log local0. "Inflate response: $response" }
Result:
Apr 4 12:32:01 bigiplab info tmm2[19039]: Rule /Common/ilx_plugin/ilx_rule : Deflate response: eJzzrVQoLinKzEtXKMlXSElNy0ksSVVIzEtRSEosTjUzUUjNS85PAUoDACY7DlU= Apr 4 12:32:01 bigiplab info tmm2[19039]: Rule /Common/ilx_plugin/ilx_rule : Inflate response: My string to deflate and base64 encoding
Yes, iRuleLX is the way to go. I have used it too for SAML. See:
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com