I have secured my layers on Geoserver. Users can not access my layers without authenticated username and password.
Now, I created a proxy script with PHP. Proxy script sends request with username password.
http://myproxydomain.com/proxy.php is my proxy address.
And I am using this proxy on my OpenLayers application to access WMS and WFS:
OpenLayers.ProxyHost="http://myproxydomain.com/proxy.php?url=";
var myWMSLayer = OpenLayers.Class(OpenLayers.Layer.WMS, {
getURL: function (bounds) {
var url = OpenLayers.Layer.WMS.prototype.getURL.call(this, bounds);
if (OpenLayers.ProxyHost && OpenLayers.String.startsWith(url, "http")) {
url = OpenLayers.ProxyHost + encodeURIComponent(url);
}
return url;
}
});
As a result, everyone can use my services that knows my proxy url. My application is in Javascript and you can see my proxy url from browser view code. And you can add your my proxy to your own Openlayers application and access my layers.
How can I solve this problem?