Secured feature service authentication in widget

4108
11
Jump to solution
11-21-2016 02:06 PM
AndrewTerwiel
Occasional Contributor II

How do I add a layer to a map from a widget when the layer is secured and requires authentication? Currently, the secured layer gets added to the map, but an authentication popup appears. I'm hoping I can add a token or credentials to the layer properties and so circumvent the authentication popup. The layer that I'm trying to add is secured and visible externally in our DMZ. We'd like our users to not see the authentication popup, if possible. I've been experimenting with IdentityManager using the online examples, but these samples don't seem to apply well to Web App Builder apps and widgets.

0 Kudos
11 Replies
RobertScheitlin__GISP
MVP Emeritus

Andrew,

  Sorry I am drawing a blank than.

0 Kudos
AndrewTerwiel
Occasional Contributor II

I have this working now. For those who are new to using the proxy, here are some important considerations.

  • The proxy must be on the same domain as the app that is calling it. If you are running your app from Web App Builder the domain of your app will be something like: http://<yourmachinename:3344/webappbuilder/apps/8/>, so putting the proxy at http://localhost/proxy will not work because the port number 3344 is a different domain from localhost. This is where I went wrong.
  • Download the app and extract the zipped files to inetpub/wwwroot/<yourappname> and convert to this folder to an application in IIS manager.
  • Your proxy should be in http://localhost. Ping it to make sure it runs. http://localhost/proxy/proxy.ashx?ping
  • Configure your app to use the proxy in <yourappname>\config.json. e.g.
    • "httpProxy": {
          "useProxy": true,
          "alwaysUseProxy": false,
          "url": "",
          "rules":[{
                "urlPrefix": "http://<domain>/arcgis/rest/services/.../MapServer",
                "proxyUrl": "http://localhost/proxy/proxy.ashx"
           }
           ]
        },

  • Configure the proxy. Refresh the proxy in IIS after changing the config. e.g.
    • <?xml version="1.0" encoding="utf-8" ?>
      <ProxyConfig allowedReferers="*"
                   mustMatch="true"
                      logFile="proxylog.txt">
          <serverUrls>
              <serverUrl url="http://<serviceUrl>"
                         matchAll="true"
                      username="<username>"
                   password="<password>"
                   oauth2Endpoint="https://www.arcgis.com/sharing/oauth2/"/>
                             
          </serverUrls>
      </ProxyConfig>