Installation
CalDAV support comes in a separate package. If you installed the zip file, you should already have the CalDAV source files. If you installed SabreDAV using pear, you might need to install it using the following command:
pear install sabredav/Sabre_CalDAV
Database setup
Example sql files are supplied for postgres, sqlite and mysql. The latter two are officially supported and unittested.
This example assumes you're using sqlite.
Create a 'data' directory where you're going to store the sqlite database.
mkdir data/
cat examples/sql/sqlite.* | sqlite3 data/db.sqlite
We'll add a calendar for the admin user.
INSERT INTO calendars (principaluri, displayname, uri, description, components, ctag) VALUES
('principals/admin','default calendar','default','','VEVENT,VTODO','1');Now, make sure the data/db.sqlite as well as it's containing directory are writable by the server. If you are lazy you could just do:
chmod -Rv a+rw data/
Create the server endpoint
Simply run the following:
cp examples/calendarserver.php calendarserver.php
Test in browser
Try opening the full url to your new server. Make sure you append a slash at the end of the url, without this the request will fail. Example:
http://www.example.org/~every/sabredav/calendarserver.php/
This url should prompt you with an authentication dialog. The default username and password are admin and admin.
Now you can use the url:
http://www.example.org/~every/sabredav/calendarserver.php/principals/admin/
for iCal and iPhone, or
http://www.example.org/~every/sabredav/calendarserver.php/calendars/admin/default
For Lightning or Evolution.
Note that the iCal and iPhone clients can auto-detect the principal url, if SabreDAV runs at the root of the domain.
Adding users
SabreDAV does not provide an administrative interface. While this may happen in the future, for now SabreDAV is mostly intended for developers. Adding new users is done directly on the database.
In order to allow a user to log in, add them to the users table. You must also add them to the principals table to enable calendar access.
Lastly, in order to enable support for calendar-delegation, the calendar-proxy-read and calendar-proxy-write principals must be added. Look at the sample .sql files for examples for these records.
Related topics
What kind of hash do I need for the password in de users table?
This is a standard HTTP Digest hash. Since the realm is currently hardcoded it's always SabreDAV.
Thanks! BTW, are you Dutch? ("Evert")
Yep! Born and raised =)
Oke, mag ik dan een vraag in het Nederland stellen?
Als ik meerdere users toevoeg en daaraan calendars toevoeg kunnen die gebruikers bij elkaars calendars. Hoe zorg ik ervoor dat dit niet kan?
T: When multiple users are added, these can access each others calendars.
There's unfortunately no security yet built in at all. If you can log in, you can see everything and you can edit everything. These things will be locked down in a later version, focus is just on the actual protocol for now.
P.S. Sorry for the english, but this is primarily an english site. You can by the way also try the mailing list for any questions http://groups.google.com/group/sabredav-discuss
Okay, one last question:
I'm owner of a hosting company, and I want to offer CalDAV hosting for my clients. I wanted to use this CalDAV 'framework', but it is still in beta and because there's no security, i'm now searching for another good (PHP) CalDAV framework, do you know one?
(P.S.: from now on I will post my questions to the mailinglist ;-) )
The SQL insert statement doesn't seem to be valid. It has 5 columns but only 4 values.
jtietema,
You're correct. Just fixed that. Thanks for pointing it out
Nice project.
I tried to get the calendar server running but get this error:
<d:error>
</d:error>I tried to place the calendarserver.php everywhere but no success :(
Hi Sven, The calendarserver.php needs to be opened directly. Try opening calendarserver.php in the browser.
If you want to run the calendar server on the root of your domain, open calendarserver.php and change the 'baseUri'.
Hi evert, thanks you for your answer.
I opened http://localhost/_system/SabreDAV/calendarserver.php/ directly (with / like it's descripted) and set $baseUri = '/system/SabreDAV/'; (without trailing slash I get Sabre_DAV_Exception_Forbidden?, without last slash the known filenotfound). Maybee there's something wrong?
Hi Sven,
The baseUri in this case should be: /system/SabreDAV/calendarserver.php/
If you want a 'nice' url, you can change this with mod_rewrite.
Let me know if that works, and also hit me up on the mailing list for anything else.
Hi, thank you for your prompt help! It's working now... Maybee I was confused by this line:
// $baseUri = '/';
I removed the // and changed directory to /system/SabreDAV/ - and I didn't read the comment above this line exactly :( Maybee it's a good idea to change the comment to
// $baseUri = '/calendarserver.php/';
:)
I'm currently installing CalDAV, and I followed all directions. I can open http://server/calendarserver.php/ and there is a authentication dialog. But after filling in admin:admin I get "SQLSTATEHY000?: General error: 1 no such table: users" I just checked the sqlite.calendars.sql file and there is no table "users" created. So I am missing some SQL queries.
I'm using SabreDAV-1.2.4 via pear. In Version 1.2.3 I saw 3 files in examples/sql/sqlite., in version 1.2.4 there is only one. I think that is the problem here.
Ah, I found the missing files, they are in Sabre_DAV/examples/sql and not in Sabre_CalDAV/examples/sql where I expected them.
Another little thing: In calendarserver.php I had to change require_once 'lib/Sabre/autoload.php'; to require_once 'Sabre/autoload.php'; to get it working.
After fixing that it works really good, great work!
Glad you figured it out.
Basically the PEAR packages are composed of parts of the standard directory tree. Because of this, the sql scripts get spread out a bit. It made the most sense to me at the time, but I could also just duplicate the user and lock sql files so it also appears in the CalDAV package.
This is great! I got everything working fine...
except.. I have a few questions.
1. What is "principals" used for?
2. why cant I create a folder inside "principals" or "calendars" for that matter. (I get "Sabre_DAV_Exception_Forbidden? Permission denied to create directory 1.2.5")
3. Where is CALENDARCOLOR, and DISPLAYNAME used?
4. What is CTAG?
None of it really matters, as the current setup fits my needs just fine, I'm just curious.
Hi Techiefreak,
Definitely ask any followup questions in the mailing list.
1. part of the standard, and used my ical to determine where a users' calendars are, and the identity of the user. 2. Simply didn't build the mechanism for that. It wasn't needed anyway. Those folders aren't 'real folders'. 3. CalendarColor? is a proprietary ical extension. Displayname is used by ical, but might also be used by some other clients. 4. Ctag is used to determine if the entire calendar changed (much like an etag for a single object.) It speeds up the syncing process if nothing changed.
hello all! great small project.
I can't login with admin/admin after the creation of the tables (calendarserver.php). I already recreated the md5 hash in the field digesta1 for the user admin.
thank you for your contribution
Hi Omat,
The mailing list is the place to go for any questions.
There's been issues with digest on certain webservers. Some of the mangle the realm which causes the hash to be incorrect.
shouldn't
chmod -Rv a+rw data/ be chmod -Rv a+rw examples/sql
jhansonworld,
No, the data directory will contain the sqlite database in this example.
Hello,
Is there a way to get calendar objects in a specific range of time (e.g., a specific month, etc)? Since the calendar data are stored as blobs, I thought is there an api that can do queries with specific event data such as date? Thanks very much.
Hi, I'm not sure what I did wrong, but I get this, when I open calendarserver.php: <d:error><s:exception>PDOException</s:exception><s:message>SQLSTATEHY000?: General error: 1 no such table: users</s:message><s:sabredav-version>1.5.4</s:sabredav-version></d:error>
I got the sqlfile from here: https://github.com/evert/SabreDAV/blob/master/examples/sql/sqlite.calendars.sql
It doesn't contain a user table, so I'm not sure if it just misses, or if I'm supposed to add it myself. And if i have to add it myself, which fields are needed?
Greetings Christian
There is also a 'users' sql file in that directory. You'll need that, as well as principals.
Please head to the mailing list for any followup questions.
I was able to get this to work with iCal, by using the following url http://caldav.dev/index.php/principals/admin/ where http://caldav.dev/index.php is the url to the server entry point.