radicale: Redirect to well-known URLs according to version

- Radicale 1 needs to have /radicale/.well-known/*dav to the URLs where as
  Radicale 2 needs to have /radicale to be the URLs. Hence have two separate
  apache configuration files.

- Use expr= when setting X-REMOTE-USER header to set the authenticated user name
  properly. Without this all users are using a single user '(null)' data.

Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa 2019-01-04 22:22:10 -08:00 committed by James Valleroy
parent 49acfa5ad1
commit 7cf279ccd0
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808
3 changed files with 39 additions and 15 deletions

View File

@ -77,7 +77,7 @@ def subcommand_setup(_):
action_utils.service_enable('radicale')
action_utils.service_restart('radicale')
action_utils.webserver_enable('radicale-plinth')
action_utils.webserver_enable(_get_web_config(current_version))
def subcommand_configure(arguments):
@ -92,12 +92,12 @@ def subcommand_configure(arguments):
def subcommand_enable(_):
"""Start service."""
action_utils.service_enable('radicale')
action_utils.webserver_enable('radicale-plinth')
action_utils.webserver_enable(_get_web_config())
def subcommand_disable(_):
"""Stop service."""
action_utils.webserver_disable('radicale-plinth')
action_utils.webserver_disable(_get_web_config())
action_utils.service_disable('radicale')
@ -113,6 +113,17 @@ def _get_version():
return LV(version)
def _get_web_config(current_version=None):
"""Return the name of the webserver configuration based on version."""
if current_version is None:
current_version = _get_version()
if current_version and current_version < VERSION_2:
return 'radicale-plinth'
return 'radicale2-freedombox'
def load_augeas():
"""Initialize Augeas."""
aug = augeas.Augeas(flags=augeas.Augeas.NO_LOAD +

View File

@ -6,19 +6,8 @@ Redirect 301 /.well-known/carddav /radicale/.well-known/carddav
Redirect 301 /.well-known/caldav /radicale/.well-known/caldav
<Location /radicale>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/radicale$
RewriteRule .* /radicale/ [R=301,L]
</IfModule>
</Location>
ProxyPass http://localhost:5232
<Location /radicale/>
Include includes/freedombox-auth-ldap.conf
Require valid-user
ProxyPass http://localhost:5232/
ProxyPassReverse http://localhost:5232/
RequestHeader set X-Script-Name /radicale/
RequestHeader set X-Remote-User %{REMOTE_USER}s
</Location>

View File

@ -0,0 +1,24 @@
##
## On all sites, provide Radicale on a path: /radicale
## Allow all valid users.
##
Redirect 301 /.well-known/carddav /radicale/
Redirect 301 /.well-known/caldav /radicale/
<Location ~ ^/radicale$>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/radicale$
RewriteRule .* /radicale/ [R=301,L]
</IfModule>
</Location>
<Location /radicale/>
Include includes/freedombox-auth-ldap.conf
Require valid-user
ProxyPass http://localhost:5232/
ProxyPassReverse http://localhost:5232/
RequestHeader set X-Script-Name /radicale/
RequestHeader set X-Remote-User expr=%{REMOTE_USER}
</Location>