Cliff Patterson
2017-05-01 15:34:50 UTC
I have several layers protected with basic authentication in Geoserver
2.11.0. Authentication works fine with QGIS, but when I try to authenticate
with Leaflet, nothing loads. My leaflet.js code to load a wms layer is the
following:
var wmsLayer =
L.tileLayer.wms('http://username:password@[ip_address]:8080/geoserver/ows?',
{
layers: 'workspace:layer',
format: 'image/png',
transparent: true
}).addTo(mymap);
Where username:password are actual username and password, ip_address is the
ip address, and workplace:layer are the correct workspace and layer.
However, the layer only loads if I am logged into Geoserver on another tab.
When logged out of Geoserver, the WMS layer does not load, so adding
username:password@ seems to do nothing whatsoever.
What are the steps required to authenticate WMS layers in Leaflet.js? Do I
need to set up a proxy server through Apache, and if so, is there
documentation for setting this up correctly?
Cheers,
Cliff
2.11.0. Authentication works fine with QGIS, but when I try to authenticate
with Leaflet, nothing loads. My leaflet.js code to load a wms layer is the
following:
var wmsLayer =
L.tileLayer.wms('http://username:password@[ip_address]:8080/geoserver/ows?',
{
layers: 'workspace:layer',
format: 'image/png',
transparent: true
}).addTo(mymap);
Where username:password are actual username and password, ip_address is the
ip address, and workplace:layer are the correct workspace and layer.
However, the layer only loads if I am logged into Geoserver on another tab.
When logged out of Geoserver, the WMS layer does not load, so adding
username:password@ seems to do nothing whatsoever.
What are the steps required to authenticate WMS layers in Leaflet.js? Do I
need to set up a proxy server through Apache, and if so, is there
documentation for setting this up correctly?
Cheers,
Cliff