LocationHeaderFilter example?

This topic has 2 replies, 2 voices, and was last updated 5 years, 11 months ago by Mark Craig.

  • Author
    Posts
  • #6197

    Does anyone have an example config.json showing how to use LocationHeaderFilter? I’m new to OpenAM/OpenIG, and trying to follow the examples in the getting started guides. My protected application is running at http://qa-sso-px01.dc1.lan:8080/, and OpenIG 3.1.0 is on the same box at port 80. I want to rewrite 302 redirects returned by the application to replace the “real” port of 8080 with 80. I tried variations on the following config.json, but couldn’t make it work:

    {
        "handler": {
            "type": "Router",
            "audit": "global",
            "capture": "all"
        },
        "heap": [
    	{
    	    "name": "LogSink",
    	    "type": "ConsoleLogSink",
    	    "config": {
    		"level": "DEBUG"
    	    }
    	},
    	{
    	    "name": "JwtSession",
    	    "type": "JwtSession"
    	},
    	{
    	    "name": "ClientHandler",
    	    "type": "ClientHandler"
    	},
    	{
    	    "name": "capture",
    	    "type": "CaptureDecorator",
    	    "config": {
    		"captureEntity": true,
    		"_captureExchange": true
    	    }
    	},
    	{
    	    "name": "LocationRewriter",
    	    "type": "LocationHeaderFilter",
    	    "config": {
    		"baseURI": "http://qa-sso-px01.dc1.lan:80/"
    	    }
    	}
        ],
        "baseURI": "http://qa-sso-px01.dc1.lan:8080"
    }
    #6199

    To answer my own question I had better luck by putting the filter into a route instead, e.g. in 98-rewrite.json like so:

    {
        "handler": {
            "type": "Chain",
            "comment": "Rewrite redirect responses to use the OpenIG baseURI",
            "config": {
                "filters": [
                    {
                        "name": "LocationRewriter",
                        "type": "LocationHeaderFilter",
                        "config": {
                            "baseURI": "http://qa-sso-px01.dc1.lan:80"
                        }
                    }
                ],
                "handler": "ClientHandler"
            }
        }
    }
    #6209
     Mark Craig
    Participant

    Yes, as you found out, almost all the objects defined in the heap need to be used somewhere to take effect.

    The reason the “LogSink” defined in the heap has an effect is because it is one of a couple of automatically created objects that OpenIG sets up whether you do anything or not, and whose configurations can be overridden if you declare a configuration having the same name. The other object is “TemporaryStorage”. (For details, see the heap objects reference documentation.)

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

©2021 ForgeRock - we provide an identity and access platform to secure every online relationship for the enterprise market, educational sector and even entire countries. Click to view our privacy policy and terms of use.

Log in with your credentials

Forgot your details?