I have a WMS layer hosted on Geoserver that is being shown on a web map using the Google Maps API.
The problem is that for now I want to use basic authentication on the Geoserver. Every time you try to access the server (or the layer) in browser, it will ask for a username and password. (Note: The prompt only shows up on Firefox. Chrome just logs 401 errors in the console).
What I've been trying to do is authorize it in the background so the user does not have to enter any credentials. Here's what I tried.
- Before loading the map, send a request with credentials to fetch at least one tile:
http://user:password@localhost:8080/geoserver/wms?layers=mosaic&version=1.1.1&Service=WMS&request=GetMap&Styles=&format=image%2Fpng&SRS=EPSG:4326&BBOX[my bounds]=&width=256&height=256. My server-side code is in Python so I used the requests library on that URL to at least get something about the layer, like status code or content type. This works fine.
- My assumption was that this would have authenticated the access to this layer (and server) for the user in the background.
user:password. I don't want to expose the credentials on the client-side.
What else can I try to work around this issue?