GeoNode / geonode

GeoNode is an open source platform that facilitates the creation, sharing, and collaborative use of geospatial data.
https://geonode.org/
Other
1.44k stars 1.12k forks source link

MapFish print service won't print private layer #765

Closed capooti closed 9 years ago

capooti commented 11 years ago

When printing a map with some private layer, those will not be printed. The public layers will be printed regularly, though. This is the behavior on both 1.2 and 2 GeoNode series, you can easily replicate it. I would like to fix this as it is extremely critical for us, but not sure where to investigate as I don't know well the GeoNode/GeoServer authentication mechanism.

Here is a part of the GeoServer log:

2013-02-05 13:01:38,853 INFO [geoserver.wms] - Request: getServiceInfo 2013-02-05 13:01:38,858 INFO [geoserver.wms] - Request: getMap KMattr = true ViewParams = null Crs = PROJCS["WGS84 / Google Mercator", GEOGCS["WGS 84", DATUM["World Geodetic System 1984", SPHEROID["WGS 84", 6378137.0, 298.257223563, AUTHORITY["EPSG","7030"]], AUTHORITY["EPSG","6326"]], PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]], UNIT["degree", 0.017453292519943295], AXIS["Longitude", EAST], AXIS["Latitude", NORTH], AUTHORITY["EPSG","4326"]], PROJECTION["Mercator_1SP"], PARAMETER["semi_minor", 6378137.0], PARAMETER["latitude_of_origin", 0.0], PARAMETER["central_meridian", 0.0], PARAMETER["scale_factor", 1.0], PARAMETER["false_easting", 0.0], PARAMETER["false_northing", 0.0], UNIT["m", 1.0], AXIS["x", EAST], AXIS["y", NORTH], AUTHORITY["EPSG","900913"]] Bbox = ReferencedEnvelope[-310444.44 : 310444.44, -340783.34 : 340783.34] Elevation = [] Angle = 0.0 BgColor = java.awt.Color[r=255,g=255,b=255] Transparent = true StartIndex = null FormatOptions = {DPI=75} RemoteOwsType = null RemoteOwsURL = null SldBody = null ValidateSchema = false Sld = null CQLFilter = null FeatureId = null SldVersion = null TilesOrigin = null Env = {} Layers = [org.geoserver.wms.MapLayerInfo@2c55ad6] MaxFeatures = null FeatureVersion = null SRS = EPSG:900913 Legend = false Styles = [StyleImpl[ name=hotspots]] Tiled = true Palette = null Height = 503 KMScore = 40 Exceptions = SE_XML Format = image/png Buffer = 0 Filter = null Filters = null Width = 458 Time = [] Get = true RawKvp = {BBOX=-310444.44,-340783.34,310444.44,340783.34, SERVICE=WMS, TILED=true, HEIGHT=503, REQUEST=GetMap, STYLES=, WIDTH=458, TRANSPARENT=true, VERSION=1.1.1, FORMAT=image/png, FORMAT_OPTIONS=dpi:75, LAYERS=geonode:hotspots, SRS=EPSG:900913} BaseUrl = http://localhost:8080/geoserver/ RequestCharset = UTF-8 Request = GetMap Version = 1.1.1 2013-02-05 13:01:38,944 INFO [geoserver.wms] - Request: getServiceInfo 2013-02-05 13:01:38,944 ERROR [geoserver.ows] - org.geoserver.platform.ServiceException: Could not find layer geonode:country at org.geoserver.wms.map.GetMapKvpRequestReader.parseLayers(GetMapKvpRequestReader.java:1240) at org.geoserver.wms.map.GetMapKvpRequestReader.read(GetMapKvpRequestReader.java:209) at org.geoserver.wms.map.GetMapKvpRequestReader.read(GetMapKvpRequestReader.java:79) at org.geoserver.ows.Dispatcher.parseRequestKVP(Dispatcher.java:1405) at org.geoserver.ows.Dispatcher.dispatch(Dispatcher.java:622) at org.geoserver.ows.Dispatcher.handleRequestInternal(Dispatcher.java:263) at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153) at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778) at javax.servlet.http.HttpServlet.service(HttpServlet.java:735) at javax.servlet.http.HttpServlet.service(HttpServlet.java:848) at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:669) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1336) at org.geoserver.filters.ThreadLocalsCleanupFilter.doFilter(ThreadLocalsCleanupFilter.java:23) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1307) at org.geoserver.filters.SpringDelegatingFilter$Chain.doFilter(SpringDelegatingFilter.java:74) at org.geoserver.filters.SpringDelegatingFilter.doFilter(SpringDelegatingFilter.java:45) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1307) at org.geoserver.platform.AdvancedDispatchFilter.doFilter(AdvancedDispatchFilter.java:49) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1307) at org.vfny.geoserver.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:109) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1307) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:311) at org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:68) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:116) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83) at org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:72) at org.geoserver.security.filter.GeoServerCompositeFilter.doFilter(GeoServerCompositeFilter.java:91) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323) at org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:68) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113) at org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:72) at org.geoserver.security.filter.GeoServerCompositeFilter.doFilter(GeoServerCompositeFilter.java:91) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323) at org.geoserver.security.filter.GeoServerAnonymousAuthenticationFilter.doFilter(GeoServerAnonymousAuthenticationFilter.java:53) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323) at org.geonode.security.GeoNodeAnonymousProcessingFilter.doFilter(GeoNodeAnonymousProcessingFilter.java:76) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323) at org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:68) at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:150) at org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:72) at org.geoserver.security.filter.GeoServerCompositeFilter.doFilter(GeoServerCompositeFilter.java:91) at org.geoserver.security.filter.GeoServerBasicAuthenticationFilter.doFilter(GeoServerBasicAuthenticationFilter.java:82) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323) at org.geonode.security.GeoNodeCookieProcessingFilter.doFilter(GeoNodeCookieProcessingFilter.java:96) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323) at org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:68) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87) at org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:72) at org.geoserver.security.filter.GeoServerCompositeFilter.doFilter(GeoServerCompositeFilter.java:91) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:173) at org.geoserver.security.GeoServerSecurityFilterChainProxy.doFilter(GeoServerSecurityFilterChainProxy.java:97) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1307) at org.geoserver.filters.LoggingFilter.doFilter(LoggingFilter.java:71) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1307) at org.geoserver.filters.GZIPFilter.doFilter(GZIPFilter.java:47) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1307) at org.geoserver.filters.SessionDebugFilter.doFilter(SessionDebugFilter.java:46) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1307) at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:453) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137) at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:560) at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231) at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1072) at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:382) at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193) at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1006) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135) at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:255) at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116) at org.eclipse.jetty.server.Server.handle(Server.java:365) at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:485) at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:926) at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:988) at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:635) at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235) at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82) at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:628) at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52) at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608) at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543) at java.lang.Thread.run(Unknown Source) 2013-02-05 13:01:38,946 WARN [print.PDFUtils] - Server returned an error for http://localhost:8080/geoserver/wms?BBOX=-310444.44%2C-340783.34%2C310444.44%2C340783.34&HEIGHT=503&WIDTH=458&CQL_FILTER=satellite+%3D+%27T%27&TRANSPARENT=true&VERSION=1.1.1&FORMAT=image%2Fpng&TILED=true&SERVICE=WMS&format_options=dpi%3A75&LAYERS=geonode%3Acountry&REQUEST=GetMap&STYLES=&SRS=EPSG%3A900913: The byte array is not a recognized imageformat. 2013-02-05 13:01:38,970 WARN [print.PDFCustomBlocks] - Error while adding a PDF elementjava.io.IOException: The byte array is not a recognized imageformat.

capooti commented 11 years ago

I made some more test, just to give a last try, without success. Here my attempts for future references.

Given this json request (in a spec.json file):

{ "comment": "a test map", "dpi": 75, "layers": [ { "baseURL": "http://otile1.mqcdn.com/tiles/1.0.0/osm/", "extension": "png", "maxExtent": [ -20037508.3392, -20037508.3392, 20037508.3392, 20037508.3392 ], "opacity": 1, "resolutions": [ 156543.03390625, 78271.516953125, 39135.7584765625, 19567.87923828125, 9783.939619140625, 4891.9698095703125, 2445.9849047851562, 1222.9924523925781, 611.4962261962891, 305.74811309814453, 152.87405654907226, 76.43702827453613, 38.218514137268066, 19.109257068634033, 9.554628534317017, 4.777314267158508, 2.388657133579254, 1.194328566789627, 0.5971642833948135 ], "tileSize": [ 256, 256 ], "type": "OSM" }, { "baseURL": "http://localhost:8080/geoserver/wms", "customParams": { "TILED": true, "TRANSPARENT": true }, "format": "image/png", "layers": [ "geonode:countries" ], "opacity": 1, "singleTile": false, "styles": [ "" ], "type": "WMS" } ], "layout": "A4 portrait", "mapTitle": "My map", "outputFilename": "mytest", "outputFormat": "png", "pages": [ { "center": [ -8277212.9169935, 293518.18777423 ], "rotation": 0, "scale": 4000000 } ], "srs": "EPSG:900913", "units": "m" }

passing basic auth credentials in headers:

$ curl -H "Content-Type: application/json" --data @spec.json --header "Authorization: Basic YWRtaW46Z2Vvc2VydmVy" http://localhost:8080/geoserver/pdf/create.json

no success, the layer is not displayed.

Passing basic auth credentials in urls:

spec.json file: ... { "baseURL": "http://admin:geoserver@localhost:8080/geoserver/wms", "customParams": { "TILED": true, ...

no success here as well:

$ curl -H "Content-Type: application/json" --data @spec.json http://localhost:8080/geoserver/pdf/create.json

As a last resort, I am trying to post to the MapFish list, and then look in more detail in printNG, as I do not want to reinvent the wheel.

capooti commented 11 years ago

thanks to @dwins for confirming on the GeoServer list that MapFish cannot handle private layers. Looking now in the printNG module, and closing this issue as there is not a workaround at this time.

capooti commented 10 years ago

I am reopening this, as printNG seems still not 100% operative, and meanwhile MapFish Print module seem to have fixed things: http://sourceforge.net/p/geoserver/mailman/message/32054646/

we just need to deploy GS with the MapFish Print newest version and test it now.

simod commented 10 years ago

Paolo have you tried to activate this? https://github.com/GeoNode/geonode/blob/master/geonode/settings.py#L306

capooti commented 10 years ago

Yes, it is a good workaround, but now we should have a clean solution for free without altering layers permissions just for a request. Thanks anyway for this nice effort.

simod commented 10 years ago

We need to test the new mapfish. While in the meantime we have a middleware for this I vote for closing.