# Example Apache HTTP server configuration snippet for WebDAV CGI
#
# Add the following lines to the Apache HTTP virtual host which should run
# WebDAV CGI.
#
# WebDAV CGI will be accessible via http://www.example.com/webdav/ and uses
# basic HTTP authentication (by default). For this to work, you need to add all
# valid users to the AuthUserFile with the help of the htpasswd command:
#
# htpasswd -c /etc/webdavcgi-1.1/default/users.htpasswd user1
# htpasswd /etc/webdavcgi-1.1/default/users.htpasswd user2
#
# Note, that if you have the UID/GID wrapper enabled (USE=suid), WebDAV CGI will
# switch to the login user after a successful login, thus the users within the
# AuthType need to be present on the system as well.
#
# You probably want to review and change the following settings:
# - /webdavcgi should point to your desired webdavwrapper, which is either
#   webdavwrapper, webdavwrapper-afs, webdavwrapper-krb or in case you disabled
#   the UID/GID wrapper (USE=-suid), webdav.pl
#
# - The /webdav location
#   If you change this location, make sure to reflect the new path within the
#   WebDAV CGI configuration (WEBDAVCONF -> $VIRTUAL_BASE) as well.
#
# - The authentication provider and/or AuthUserFile
#
# - The HOMEURL environment variable. After a user logs out, the browser will
#   be redirected to this URL.
#
# - The WEBDAVCONF environment variable has to point to your configuration
#
# For further information and other configuration possibilities consult the
# WebDAV CGI documentation and Apache HTTP server documentation:
# * https://danrohde.github.io/webdavcgi/doc.html
# * https://httpd.apache.org/docs/
#
    ScriptAlias /webdavcgi "/usr/libexec/webdavcgi-1.1/cgi-bin/webdavwrapper"
    ScriptAlias /webdav/logout "/usr/libexec/webdavcgi-1.1/cgi-bin/logout"

    <Location /webdav>
        Require all granted
        # Disable the line above and enable the two lines below
        # if you're still on Apache 2.2
        #Order Allow,Deny
        #Allow from all
    </Location>

    <Location /webdavcgi>
        AuthType Basic
        AuthName "WebDAV-CGI"
        AuthUserFile /etc/webdavcgi-1.1/default/users.htpasswd
        Require valid-user
        # Also enable the following two lines if you're still on Apache 2.2
        #Order Allow,Deny
        #Allow from all
    </Location>


    RewriteEngine On

    RewriteRule ^/webdav/logout -  [L,E=REALM:WebDAV-CGI,E=HOMEURL:/webdav,E=TIMEOUT:5]

    RewriteRule ^/webdav        /webdavcgi [PT,L,E=WEBDAVCONF:/etc/webdavcgi-1.1/default/webdav.conf,E=PERLLIB:/usr/share/webdavcgi-1.1/lib/perl,E=LOGOUTURL:/webdav/logout]
