I'm using JavaScript API 3.24 for reference. I want my application to automatically allow users to access secured services based on background authentication via a token (this way they don't need to login). I have reviewed the documentation and many questions here, but I just can't seem to get it to work. Sorry for the length of this post, but I want to explain fully what I have tried.
I've secured one geoprocessing service called Habitat Management. It is located in the HabitatManagement folder, the service is titled HabitatManagement, and it contains a geoprocessing task called HabitatManagement. Essentially, the url for the secured service looks like this:
The actual web mapping application resides inside of a .NET application. The URL of the .NET application is this:
https://www.mydomain.com/appName
The actual web map url is this:
https://www.mydomain.com/appName/HabitatMap/HabitatJSMap
I have my proxy config file set up like so:
<ProxyConfig allowedReferers="*"
mustMatch="false"
logFile="proxyLog.txt"
logLevel="Warning">
<serverUrls>
<serverUrl url="https://www.mydomain.com/myServer/rest/services/HabitatManagement/HabitatManagement/GPServer/HabitatManagement"
username="username"
password="password"
matchAll="true"/>
</serverUrls>
</ProxyConfig>
I have the proxy JS code like this:
urlUtils.addProxyRule({
urlPrefix: "https://www.mydomain.com",
proxyUrl: "https://www.mydomain.com/appName/proxy/proxy.ashx"
});
If I go to the proxy page following this URL:
https://www.mydomain.com/appName/proxy/proxy.ashx
It works as expected, it says "Config File: "OK" Log File: "OK""
When I test this URL, it shows the login screen for my REST services, even though the token should be passing the username and password so I can see the services, right? That's issue #1 that I don't understand.
Additionally, when I go the web map and try to access the service, it still makes me login with this message:
Please sign in to access the item on https://www.mydomain.com/myServer (HabitatManagement/HabitatManagement)
If I login, things work fine - it appears the token is generated and appended to the URL as it should be.
I have also tried to change my serverURL to something very general with no luck. Ideally, the serverURL would be more specific than this as there are some services we have that don't require authentication thus do not need to run through a proxy. This just takes me to the login page for my REST services too.
<serverUrl url="https://www.mydomain.com"
username="username"
password="password"
matchAll="true"/>
I'm not sure if my proxy is located in the wrong spot in my .NET application, or if my referrer URL is messed up, or if my serverURLs are messed up. How do I access my secured services using the proxy?