Kozea / Radicale

A simple CalDAV (calendar) and CardDAV (contact) server.
https://radicale.org
GNU General Public License v3.0
3.38k stars 442 forks source link

Addressbook sharing as read-only #779

Closed C0rn3j closed 8 months ago

C0rn3j commented 6 years ago

I've been trying to figure out how to share an address book.

What I want is an address book only one "admin" account can edit, and everyone else has it shared.

There are issues like this one https://github.com/Kozea/Radicale/issues/696 but perhaps addressbook sharing is an easier issue and is doable without some massive symlink hacks?

If not, how would I go about the symlink hack?

I've tried applying some of this https://github.com/Kozea/Radicale/blob/master/rights in my config to no avail.

Config so far: https://haste.rys.pw/iqerofeyol

JSzaszvari commented 6 years ago

I'm not sure its possible without symlinks

My setup is as follows

My rights/user file:

[admin]
user: admin.*
collection: .*
permission: rw

[readonly_contacts]
user: bio_contacts
collection: .*
permission: r

Then in my collections/collections-root folder:

drwxr-xr-x 3 jszaszvari 102 Jan 23 04:03 admin
lrwxr-xr-x 1 jszaszvari   5 Jan 23 03:28 readonly_contacts -> admin

What I did was

C0rn3j commented 6 years ago

Am a bit confused about your setup, do you give all those 1200 users the same username/password for bio_contacts account?

I've tried to replicate your setup but have it accessible to all users, but it doesn't seem to work for me

image

JSzaszvari commented 6 years ago

@C0rn3j We distribute it to iOS Devices, Both iPad and iPhones using a MDM solution by pushing out a Configuration Profile (.mobileconfig) to the devices that is pre-configured.

The users never actually know what the password is, the profile is just pushed out to all their devices and the account gets added and all the user sees is all the contacts showing up in their address book.

So yes, they are all using the same username and password for the read only user. We are distributing the exact same read only address book to all our devices.

Just in case your interested i've attached a copy of the .mobileconfig below (zipped up - Just open it in a text editor, its just XML) - CardDAV.mobileconfig.zip

I'll run through it as i write this so I'm sure I'm giving you the correct info. For a start, Here's a copy of my rights file and main config file - Config.zip

I've changed the location of the collections folder to be inside the Radicale folder, just makes the way I deploy it with docker easier. Should not matter where it is though.

So my folder structure is like this:

I've run through the below as i wrote this and can confirm it worked just now:

  1. Start the server, make sure your collections/colletions-root/ folder is completely empty.

  2. Log in with the admin account that has read/write access and create an addressbook collection like i've done here: 2018-02-09_23-30-30

  3. Stop the Radicale app

At this point in your collections-root should just be the one 'admin' folder which contains the collection you just created image

  1. Create the symbolic link for the read only user: image

Now both folders will appear to contain the same collection image

  1. Start the Radicale server back up and logging in as both users should display the exact same connection now 2018-02-09_23-39-43

Hope this helps you out, let me know either way..

C0rn3j commented 6 years ago

Thanks for the writeup and a noob-friendly how-to.

My biggest problem was not defining the rights backend in the config file, which means my rights attempts were completely ignored every single time.

The rights examples I found before now work as they should, I'll just have to symlink every single LDAP user we have (about a hundred) periodically, but that should be easy.

Really wish this was supported natively in Radicale without any symlink hacks

C0rn3j commented 6 years ago

For posterity - ended up using this not-so-pretty bash script that's executed by cron every once in a while to keep the symlink hack going for all LDAP users.

Keeping this issue open as I think this should be available natively.

#!/bin/bash
set -euo pipefail
superUser="carddavreadonly"
cd /etc/radicale/
wget -q -O people.txt https://example.com/getLDAPusers.php 
# ^ Gets LDAP users line-by line in user@company.com format
arr=($(while read line; do
        echo $line | cut -f1 -d"@"
done <people.txt))
cd /root/.var/lib/radicale/collections/collection-root/
echo ${arr[@]} | sed s/\ /\\n/g | sort | uniq | while read line; do
        echo $line
        if [[ -e $line ]]; then
                if [[ ! -L $line && $line != $superUser ]]; then
                        rm -f $line
                        ln -s $superUser $line
                fi
        else
                ln -s $superUser $line
        fi
done
NicoHood commented 3 years ago

Will this get implemented eventually?

pbiering commented 8 months ago

somehow related to https://github.com/Kozea/Radicale/discussions/1457

Using symlinks but no other magic in rights file would somehow require a per collection ACL feature, potentially also be able to be implemented by another custom extension to .Radicale.props and the DAV API.