Select to view content in your preferred language

Enter the Application without username and password

3490
14
11-20-2019 08:40 AM
AlbertoCañivano1
Emerging Contributor

Good morning.
I am implementing a proxy to my application so that the user does not have to enter login/password every time he wants to enter the application.
I have the application downloaded and implemented on my local server.
I have checked that the webmap is shared with the Organization as well as the layers it has published.

I am using Xammp's Apache server and the proxy chosen was the PHP version offered by ESRI.

GitHub - Esri/resource-proxy: Proxy files for DotNet, Java and PHP. 

First I configured the proxy.config:

<?xml version="1.0" encoding="utf-8" ?>
<ProxyConfig allowedReferers="*"
             logFile="proxy_log.log"
             mustMatch="true">
    <serverUrls>
    	<serverUrl url="https://MY_ORGANIZATION.maps.arcgis.com/"  
                   username="USER"  
                   password="PASSWORD"
                   matchAll="true"/>

        <serverUrl url="http://services.arcgisonline.com"  
                   matchAll="true"/>
	
    </serverUrls>
</ProxyConfig>‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Second I configured the config.json:

"wabVersion": "2.12",
  "isWebTier": false,
  "httpProxy": {
    "useProxy": true,
    "alwaysUseProxy": false,
    "url": "PHP/proxy.php?",
    "rules": [{  
        "urlPrefix": "http://MY_ORGANIZATION.maps.arcgis.com/",  
        "proxyUrl": "PHP/proxy.php?"  
    }]‍‍‍‍‍‍‍‍‍‍

The application loads correctly without asking for username/password.
However it does not load the features.

Access to XMLHttpRequest at 'https://static.arcgis.com/attribution/World_Imagery?f=json' from origin 'http://localhost' has been blocked by CORS policy: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.

Access to XMLHttpRequest at 'https://services9.arcgis.com/YJdM1D4Nb7rZFsXe/arcgis/rest/services/Viviendas/FeatureServer/0?f=json' from origin 'http://localhost' has been blocked by CORS policy: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.

Services that are not displayed return an error of the type:

{"error":{"code":499,"message":"Token Required","messageCode":"GWM_0003","details":["Token Required"]}}

I don't know if the mistake can come from:
1) I haven't introduced any service in the "proxy.config" so that it passes with the proxy and the features are displayed.
2) When entering username/password I have to change another parameter that I don't know what it can be.


Any idea? Thank you very much in advance

Tags (2)
0 Kudos
14 Replies
RobertScheitlin__GISP
MVP Emeritus

Alberto,

  The issue is that you are attempting to test the app using the localhost url. Once a proxy is involved and you are testing you need to no longer use the localhost url and instead use the actual machine name url.

AlbertoCañivano1
Emerging Contributor

Good morning, Robert. Thank you for your reply.

I have tried to call the application with the machine name and the IP of the equipment; it still gives the same message but instead of "http://localhost" appears the address I'm looking for, in addition to the token error required for each layer

according to the DevOps of Chrome

De: Robert Scheitlin, GISP <geonet@esri.com>

Enviado el: miércoles, 20 de noviembre de 2019 19:54

Para: Alberto Cañivano Moreno <acanivanom@boslan.com>

Asunto: Re: - Re: Enter the Application without username and password

GeoNet, The Esri Community | GIS and Geospatial Professional Community <https://community.esri.com/?et=watches.email.thread>

Re: Enter the Application without username and password

reply from Robert Scheitlin, GISP<https://community.esri.com/people/rscheitlin?et=watches.email.thread> in Web AppBuilder for ArcGIS - View the full discussion<https://community.esri.com/message/892411-re-enter-the-application-without-username-and-password?commentID=892411&et=watches.email.thread#comment-892411>

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Alberto,

  Is your proxy and web app on the same server?

0 Kudos
AlbertoCañivano
Occasional Contributor

Yeah, it's in the same place.

I have managed to load the features; putting in the proxy.config the services that were giving me problems "https://static.arcgis.com" and "https://services9.arcgis.com".
Then I have configured them in config.json under "rules".
I know I'm doing something wrong because all the features are displayed (my webmap has 15) but it's very slow to refresh because it's doing the queries from the proxy to Arcgis online, instead of just to Arcgis online.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Alberto,

  If all the services you are using on services9 are not secured then you need to be more specific with your proxy rule to only those that are secure. Also make sure that the config.json has

"alwaysUseProxy": false,

DanielPérez_López
Occasional Contributor

Robert,

As a safe service you are referring to private entities, those that are not public? all the entities in my viewer are private, only shared with my organization, so, if I understand it well, all would have to go through the proxy so it would be very slow to work with the viewer.

My goal is that you can enter the viewer from another website (redirecting the user through a url), users who enter are authorized in their application and use my application as a viewer to consult data, would make many requests and is annoying for them to be entering user / password every time they make queries to my viewer.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Daniel,

  Yes by "secured" services I am taking about services that are not public. If all of the data is secured then they all will need to go through the proxy.

DanielPérez_López
Occasional Contributor

Thank you for your reply, Robert.
After setting the proxy to all features, the application is very slow, takes a long time to load and refresh when I move around the map. I see that what takes are the requests it makes for the proxy.

Do you know why this happens?

Thanks

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Daniel,

   I do not experience slow response when using a proxy so I am not sure what to tell you.