Folks,
I'd like to put some effort into the DefaultServlet and the WebDAV servlet
to align them more with mod_autoindex and add some minor improvements if I
can cover my usecases here at work.
Currently, I use mod_dav which I want to replace with the WebDAV servlet
because I don't have the authz components in HTTPd like I have in Tomcat
(it is rather a pain since I need to sync groups into a local file).
The config in HTTPd is straight forward:
<LocationMatch "^/(backend-dev|content-dev|prod)/dav(/|$)(.*)">
ProxyPassMatch "!"
</LocationMatch>
AliasMatch "^/(backend-dev|content-dev|prod)/dav(/|$)(.*)" "/var/foo/$1$2$3"
<DirectoryMatch "^/var/foo/(backend-dev|content-dev|prod)(/|$)(.*)">
Dav On
AuthType GSSAPI
AuthName "Foo WebDAV Repository"
AuthzSendForbiddenOnFailure On
Options Indexes
IndexOptions FancyIndexing FoldersFirst Charset=UTF-8 NameWidth=*
SuppressDescription
<Limit GET HEAD OPTIONS PROPFIND>
AuthGroupFile /var/foo/db/apache-groups.txt
Require group foo-maintainers bar-maintainers baz-maintainers
</Limit>
AddDefaultCharset utf-8
AddType text/plain .log .tex
</DirectoryMatch>
/(backend-dev|content-dev|prod) are proxied to three Tomcat instances, the
config above would be replaced with subcontexts at
/(backend-dev|content-dev|prod)#dav
(solely for the DAV purpose) where the web.xml contains:
<servlet>
<servlet-name>webdav</servlet-name>
<servlet-class>org.apache.catalina.servlets.WebdavServlet</servlet-class>
<init-param>
<param-name>listings</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>showServerInfo</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<param-name>sortListings</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>sortDirectoriesFirst</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>fileEncoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>webdav</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
<security-constraint>
<web-resource-collection>
<web-resource-name>WebDAV</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>Foo Maintainer</role-name>
<role-name>Bar Maintainer</role-name>
<role-name>Baz Maintainer</role-name>
</auth-constraint>
</security-constraint>
and the context.xml (for backend-dev):
<?xml version="1.0" encoding="UTF-8"?>
<Context>
<Listener
className="org.apache.catalina.core.PropertiesRoleMappingListener" />
<Valve
className="net.sf.michaelo.tomcat.authenticator.SpnegoAuthenticator"
loginEntryName="tomcat-accept" sendAuthInfoResponseHeaders="true"
/>
<Realm
className="net.sf.michaelo.tomcat.realm.PacDataActiveDirectoryRealm"
loginEntryName="tomcat-accept" />
<Resources>
<PostResources base="/var/foo/backend-dev"
className="org.apache.catalina.webresources.DirResourceSet"
webAppMount="/" />
</Resources>
</Context>
It just works from the browser, CarotDAV, the Windows Explorer, and
py-webdavclient3.
Now my question/concern is the Javadoc of the servlet [1] says:
The WebDAVServlet must not be used as the default servlet (ie mapped to '/') as
it will not work in this configuration.
Well, it works, doesn't it? And the sample below maps to root as well:
<servlet-mapping>
<servlet-name>webdav</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
So what is it now, can I safely use the servlet with this setup?
There is nothing else in this WAR file except context.xml, web.xml and
a properties file.