[OpenLayers-Dev] Headers in WMS Layer

Andreas Hocevar ahocevar at boundlessgeo.com
Fri Apr 4 02:37:24 PDT 2014


This will not work. WMS requests in OpenLayers are pure image
requests, handled by the browser. But it looks like what you want is
plain HTTP Basic authentication, which is supported by all browsers.
So you could just change your layer_url to:

http://user:pass@rest_of_your_url/wms/

I'm sure I do not need to tell you that doing this is equivalent to
sharing credentials with the whole world.

Andreas.

On Fri, Apr 4, 2014 at 11:30 AM, Moises Arcos <marcos at emergya.com> wrote:
> Hi developers,
>
> I am using OpenLayers 2.11 to display WMS Layers, but I need any help,
> because I am trying to pass authorization headers into a WMS request, but I
> don't know if it's possible.
>
> The request that I sent is:
>
> var layer = new OpenLayers.Layer.WMS(
> layerData.name,
> layer_url,
> {
> layers: layers
> },
> {
>     headers: {
>                      'Authorization': 'Basic user:pass'
>       }
> }
> );
>
> I know that the better options to do this is throught a proxy, but I need to
> do this temporaly.
>
> Regards!!!
>
> --
> Moisés Arcos Santiago
> Área de Proyectos
>
> Emergya Consultoría
> Tfno: +34 954 51 75 77
> Fax: +34 954 51 64 73
> www.emergya.es
>
> _______________________________________________
> Dev mailing list
> Dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-dev



-- 
Andreas Hocevar
Geospatial Solutions Engineer | Boundless
ahocevar at boundlessgeo.com
@boundlessgeo


More information about the Dev mailing list