Select to view content in your preferred language

tokens, proxy, secure services and the vanishing help

7528
14
Jump to solution
04-02-2014 04:56 AM
AdrianMarsden
Honored Contributor
Ok

I decided (why I don't know) to have yet another go at securing my services (about the tenth attempt I think)

First off, the help that was in the 9.x versions (http://resources.esri.com/help/9.3/arcgisserver/apis/javascript/ve/help/Working with ArcGIS Server s...) seems to have vanished from the 10.2 help.  I cannot see any mention of "proxy.ashx" anywhere in the Help.

Secondly, I have a proxy page, it works, I can see the requests in Fiddler going via it.  However even though I have the token="jhkjghkjhkjhkjhkjhkjh" bit, it isn't passing this token.

Next, which leads me to believe it is all different in 10.2.1, despite the service being secured, and despite not seeing the token in Fiddler, and despite the logs saying it is using anonymous access, maps ARE displayed in my app.  It fails when I try an Id, find or query task.

I simply want a secure service and the API to pass the credentials, yet every time I try I end up bashing my head on brick walls.

Giving up for now

ACM
0 Kudos
14 Replies
AdrianMarsden
Honored Contributor
OK - digging further.  I pasted the proxy request the ID task fires off directly into a browser and got back

{error: {code: Forbidden,message:"Proxy is being used from an unsupported referer: "}}

Which seems to be thrown by the proxy.ashx page at line 125 after failing "
//check against the list of referers if they have been specified in the proxy.config"

Thoughts?

ACM

The only way I can see of making it work is to change the allowedReferers back to * - it's odd the error message code  appears to indicate it should print the referer that is failing, but mine doesn't - well it does, but the content of context.Request.Headers["referer"] is an empty string, so 'allowed' stays false.
0 Kudos
BjornSvensson
Esri Regular Contributor
what is the lowest version of the API that the new proxy will work on?  I have some code stuck at 3.0, which onlyu seems to pass the initial requests in - query tasks go direct to server.


The resource proxy should work fine with all versions the Javascript API. Assuming there isn't an API bug related to using proxies in general for specific scenarios.
0 Kudos
AdrianMarsden
Honored Contributor

OK - I've had some spare time and found the issue.

I use this code

        //return the layer descriptions and © text into arrays - we use this later for the info dialog to generate hyperlinks and © text

        dojo.forEach(dynamicMapServiceLayer.layerInfos, function (layer) {

            var restAPIServicePage = {

                url: mapservice2 + "/" + layer.id +

                    "?f=json&token=uO3JarsebollockswxI9ExjTj_VE5IgAHr9YKPjoE3Mn00qipj9Baxjg1s0lm1c4c", callbackParamName: "callback", load: function (data) {

  LayerDescriptions[layer.id] = data.description;                   

                    dynamicMapServiceLayer.layerInfos[layer.id].copyrightText = data.copyrightText;                 

                }

            };

            dojo.io.script.get(restAPIServicePage);

        });

in my init function, to step throughmy layers and return the description into an array, which I use for layer specific hyperlinks in my ID task results.

As you see, I've had to hard code a token here as it appears to be this bit that doesn't go via the proxy, so fails to return anything

Is this the only realistic way of doing it?

Cheers


ACM

0 Kudos
AdrianMarsden
Honored Contributor

Ah - answered my last question myself - I needed to wrap it in a esri.request.

   var requestHandle = esri.request({

                url:mapservice2 + "/" + layer.id + "?f=json",              

                handleAs: "json",

                load: function (data) {

                    console.debug(data)

                    LayerDescriptions[layer.id] = data.description;

                   dynamicMapServiceLayer.layerInfos[layer.id].copyrightText = data.copyrightText;

                   

                },              

            }, { useProxy: true });

0 Kudos
AlexeiB
Deactivated User

I don't mean to revive what appears to be a solved problem, but I am experiencing perhaps a similar issue.

HTTPS and Proxy

I was wondering if you had experienced any similar behavior when you had your issue?

Thanks,

Alex

0 Kudos