sabre-io / dav

sabre/dav is a CalDAV, CardDAV and WebDAV framework for PHP
http://sabre.io
BSD 3-Clause "New" or "Revised" License
1.53k stars 346 forks source link

Create Carddav user with read only access? #1052

Open x3LPh0r opened 6 years ago

x3LPh0r commented 6 years ago

I've been building up a sabredav server and have it nearly completed. The last piece is/would be to create a user account with access to another address book as read only (or it's own). I want to share this user account between users to access a company directory basically that only admins can edit as necessary.

I tried creating another user and giving that user group membership to the main/admin users read (calendar) principal. (I found this after doing it that states this SHOULD work https://github.com/sabre-io/dav/issues/844). Basically I have the user I want to be able to access the other users address book as the member_id (it's principal) and the users address book (read only) I want to share's principal entered as the principal_id. (Just not working.) I tried to set the principal_id to the write principal as well as a test with the same result(s).

sqlite> select * from groupmembers; 1|5|10

sqlite> select * from principals; 5|principals/UserA/calendar-proxy-read|| 10|principals/UserB||UserB

However in doing so, I see the group membership in the browser GUI but when selected I get:

3.2.2Sabre\DAV\Exception\NotFoundCould not find node at path: principals/UserA/calendar-proxy-read Also when I log in with our address book I don't see any contacts. Is there a way for me to effectively achieve this with sabredav? I was hoping it was as easy as removing the write principal for a user or something, a switch etc, but that did not seem to work in my testing either. Thank you.
AndrewArmstrong commented 6 years ago

I am looking for a solution to the exact same problem - I want a read-only address book shared by multiple people.

kidk commented 6 years ago

Did you ever figure it out?

risototh commented 5 years ago

I needed exactly the same. CardDAV service from our system, but read only. So i implemented the Sabre\DAV\Auth\Backend\AbstractBasic for authentication from our system, Sabre\DAVACL\PrincipalBackend\AbstractBackend for virtual principals (it's from our own users and ACL database) and Sabre\CardDAV\Backend\AbstractBackend as a datasource for address books (one virtual for all) and cards provider (from our own contacts DB). I know, that it's not the 100% proper solution, but i simply left empty (for now), the methods in the class, that are responsible for updating/changing the data.

As i told, maybe not a 100% correct solution, but it works for now.

BRUCH05 commented 4 years ago

I needed exactly the same. CardDAV service from our system, but read only. So i implemented the Sabre\DAV\Auth\Backend\AbstractBasic for authentication from our system, Sabre\DAVACL\PrincipalBackend\AbstractBackend for virtual principals (it's from our own users and ACL database) and Sabre\CardDAV\Backend\AbstractBackend as a datasource for address books (one virtual for all) and cards provider (from our own contacts DB). I know, that it's not the 100% proper solution, but i simply left empty (for now), the methods in the class, that are responsible for updating/changing the data.

As i told, maybe not a 100% correct solution, but it works for now.

Hello Richard,

Your workaround is very interesting, could you please post the file (or contain) here because i'm not a specialist and it's a little bit complex for me. I think it's server.php file to update but i don't know how to do.

Thanks a million by advance Christophe (Charity Association in Paris)

risototh commented 4 years ago

Hi Christophe, I have removed most of our company code, so maybe it will not be working out of the box, but as an example, it will be fine. Our server.php is called dav.php here...

dav.zip

pbruining commented 3 years ago

I needed exactly the same. CardDAV service from our system, but read only. So i implemented the Sabre\DAV\Auth\Backend\AbstractBasic for authentication from our system, Sabre\DAVACL\PrincipalBackend\AbstractBackend for virtual principals (it's from our own users and ACL database) and Sabre\CardDAV\Backend\AbstractBackend as a datasource for address books (one virtual for all) and cards provider (from our own contacts DB). I know, that it's not the 100% proper solution, but i simply left empty (for now), the methods in the class, that are responsible for updating/changing the data.

As i told, maybe not a 100% correct solution, but it works for now.

If you throw a Sabre\DAV\Exception\Forbidden exception in the backend method, changes made in, for example macOS AddressBook, wil be reverted after the PUT. This is a very workable mechanism for our situation.

Guenni99 commented 1 year ago

Hi @pbruining thanks for this comment, it sounds like a "simple" Workaround for the exact problem i also have. In my case im using the Sabre DAV Baikal Docker Image to share addressbooks.

Is it possible to get the same mechanism for this Image? And could you please be so kind and explain your doings a bit more? Im really new to this at all.

thanks in advance Paul