Authenticate App With Esri Identity Manager and ArcGIS Server CORS

673
0
09-13-2016 11:07 AM
GreggRoemhildt1
Occasional Contributor

Hi, I'm trying to provide a simple authentication mechanism to my app through arcgis server. Basically what I'm after is this:

  1. User visits page
  2. App checks for local storage token (from previous sessions) 
  3. App loads if the token is valid
  4. If token is not valid, identity manager pops up and user enters password and username
  5. identity manager gets a new token and the app is started. 
  6. user leaves and just before, token gets saved to the local storage/cookie

So far I've been able to get the login dialog to display as expected, but once I click the sign in button, the message appears: 

esri.config.defaults.io.proxyUrl is not set. If making a request to a CORS enabled server, please push the domain into esri.config.defaults.io.corsEnabledServers.

I have added the domain name 'gis.myserver.org' to the list of corsEnabledServers. The network request to authenticate is never sent. CORS is enabled on both the ArcGIS server, and the file server. I can see the headers in the network requests.

  1. Access-Control-Allow-Headers:
    DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type
  2. Access-Control-Allow-Methods:
    GET, POST, OPTIONS
  3. Access-Control-Allow-Origin:
    *

Here's my sample code where I am stuck at:

        /**
         * authenticates the identity manager by checking the current
         * sign in status and if necessary displaying the sign in dialog
         */
        authenticate: function() {
          //this.url is 'https://myserver.org/arcgis/rest/services'
            esriId.checkSignInStatus(this.url).then(
                //success
                lang.hitch(this, 'onAuthenticate'),

                //fail, display the sign in dialog
                lang.hitch(this, function() {
                    esriId.signIn(this.url, esriId.findServerInfo(this.url)).then(

                        //success authenticate
                        lang.hitch(this, 'onAuthenticate'),

                        //fail, error out
                        lang.hitch(this, 'onFail')
                    );
                })
            );
        },‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

The error is thrown on the line of getProxyUrl in the urlUtils file. Since I added the url to the esriConfig though, I don't think the proxy should even be used. Do I need to configure a proxy regardless?

0 Kudos
0 Replies