Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: allow public calendars #105

Merged
merged 14 commits into from
Oct 29, 2023
Merged

Feature: allow public calendars #105

merged 14 commits into from
Oct 29, 2023

Conversation

tchapi
Copy link
Owner

@tchapi tchapi commented Aug 15, 2023

Override the default DAVACL plugin to allow public calendars, introducing a new ACCESS_PUBLIC constant

Public calendars

They are accessible without credentials, even in the browser

Screenshot 2023-08-15 at 21 22 37

Adds a new "Public" field when editing a calendar, to mark the calendar public (the user remains the sole owner as a public calendar cannot be shared for now)

Screenshot 2023-08-15 at 21 05 57

We add a badge in the list to indicate it's public

Screenshot 2023-08-15 at 21 06 08

Related PR: sabre-io/dav#820

@1Luc1
Copy link

1Luc1 commented Aug 16, 2023

Having events (todos, notes also?) within the public calendar does trigger the authentication dialog.
grafik

I guess this entries don't have the unauthenticated principal
grafik

@1Luc1
Copy link

1Luc1 commented Aug 16, 2023

Having a calender which is shared, can be changed to a public calender afterwards.
grafik

And the shared calender entry.
grafik

The Events got still synchronized. So it seems, this does work? Or should this be more restricted?

@david-raine
Copy link

Does this allow phonebooks to be shared?

@tchapi
Copy link
Owner Author

tchapi commented Aug 28, 2023

Thanks @1Luc1 for the tests!

Having events (todos, notes also?) within the public calendar does trigger the authentication dialog.

That's weird, I didn't have the same behavior (with events only but having the other ones should not change much)

Having a calender which is shared, can be changed to a public calender afterwards.

This is a bug, I'll fix asap (meaning: it should work, but it should also revoke all shared accesses since it's not used anymore and can lead to side effects) ✅ Fixed

@tchapi
Copy link
Owner Author

tchapi commented Aug 28, 2023

Hello @david-raine

Does this allow phonebooks to be shared?

Unfortunately no, because the underlying sabre-io/dav library does not support it. See #87

@tchapi tchapi force-pushed the feature/public-calendars branch 7 times, most recently from a1f7a61 to 9bc1352 Compare September 2, 2023 22:40
Comment on lines -22 to +27
public const INVITE_STATUS_NORESPONSE = 1;
public const INVITE_STATUS_ACCEPTED = 2;
public const INVITE_STATUS_DECLINED = 3;
public const INVITE_STATUS_INVALID = 4;
public const INVITE_NORESPONSE = 1;
public const INVITE_ACCEPTED = 2;
public const INVITE_DECLINED = 3;
public const INVITE_INVALID = 4;

public const ACCESS_OWNER = 1;
public const ACCESS_NOTSHARED = 0;
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🌱 This is mainly to comply with SabreDAV's namings

@1Luc1
Copy link

1Luc1 commented Sep 4, 2023

Tested with branch feature/public-calendars

Thanks @1Luc1 for the tests!

Having events (todos, notes also?) within the public calendar does trigger the authentication dialog.

That's weird, I didn't have the same behavior (with events only but having the other ones should not change much)

My I be more specific about the behavior. Calling the public calender with the link ( e.g.: davis.at/dav/calendars/public/test) within the browser (firefox) will trigger the authentication dialog only if there are events within the calender. If there are no events within the calender no authentication dialog will be called.

On the other hand, subscribing to the public calender within an email client (thunderbird) doesn't open any authentication dialog, even if there is a events within the calender.

So, this behavior is acceptable for my understanding. ✅


Having a calender which is shared, can be changed to a public calender afterwards.

This is a bug, I'll fix asap (meaning: it should work, but it should also revoke all shared accesses since it's not used anymore and can lead to side effects) ✅ Fixed

Tested ✅

@1Luc1
Copy link

1Luc1 commented Sep 4, 2023

Found an interesting security issue, which is mainly a problem from the user and thunderbirds behavior.
If an user is created same name and the password is possible to add events to an public calendar within thunderbird. This will probably apply to non public calendars too.

Subscribe to a public calendar
grafik

Thunderbird shows the calendar as read only
grafik

Change read only within the calendar properties
grafik

Add events to calendar without providing a password ❌

Maybe add another security check within the user creation to not allow username and password the same?

@tchapi
Copy link
Owner Author

tchapi commented Sep 4, 2023

will trigger the authentication dialog only if there are events within the calender.

Oh ok, understood, thanks a lot for the clarification! I will test that behavior, I have a feeling it's some edge case on the sabre/dav side, but it should be fixable I guess, will work on it.

If an user is created same name and the password is possible to add events to an public calendar

That's "funny" ... auth is managed by sabre/dav entirely, but it might be Thunderbird that tries to login optimistically by providing the username as a password? I'll try to reproduce

@tchapi
Copy link
Owner Author

tchapi commented Sep 10, 2023

Calling the public calender with the link ( e.g.: davis.at/dav/calendars/public/test) within the browser (firefox) will trigger the authentication dialog only if there are events within the calender.

I think c1b0a00 should fix it

@tchapi tchapi force-pushed the feature/public-calendars branch from 62d39b6 to c1b0a00 Compare September 10, 2023 20:32
@tchapi tchapi marked this pull request as ready for review September 10, 2023 20:35
@1Luc1
Copy link

1Luc1 commented Sep 11, 2023

Calling the public calender with the link ( e.g.: davis.at/dav/calendars/public/test) within the browser (firefox) will trigger the authentication dialog only if there are events within the calender.

I think c1b0a00 should fix it

Thanks. Just tested your changes and within the browser no authentication dialog appears. ✅

Unfortunately, within Thunderbird an authentication dialog shows up if subscribing to a public calender. ❌

@tchapi
Copy link
Owner Author

tchapi commented Sep 26, 2023

Unfortunately, within Thunderbird an authentication dialog shows up if subscribing to a public calender. ❌

This protocol is making me go nuts. Will have a look!

@1Luc1
Copy link

1Luc1 commented Oct 11, 2023

Unfortunately, within Thunderbird an authentication dialog shows up if subscribing to a public calender. ❌

This protocol is making me go nuts. Will have a look!

Can you tell, when you can get another look?

@tchapi
Copy link
Owner Author

tchapi commented Oct 11, 2023

Can you tell, when you can get another look?

Unfortunately I'm quite busy on various other subjects so I can't really commit (as it takes quite some time to investigate the code for this feature); I'll do my best to finish next week

@1Luc1
Copy link

1Luc1 commented Oct 13, 2023

Just checked your changes and tried to replicated the usecase where subscribing to a public calendar within thunderbird once worked, but couldn't really redo your changes to make it work. Now I doubt it ever worked 😖

@1Luc1
Copy link

1Luc1 commented Oct 16, 2023

Did some further digin and found that within getAcl method from PublicAwareDAVACLPlugin adding the following checks

$node instanceof \Sabre\CalDAV\SharedCalendar
$node instanceof \Sabre\CalDAV\CalendarHome
$node instanceof \Sabre\CalDAV\Principal\User

within an own if condition returning {DAV:}unauthenticated ... won't show the authentication dialog within Thunderbird. So maybe that's something to work with?

@tchapi tchapi force-pushed the feature/public-calendars branch from c1b0a00 to 5874935 Compare October 17, 2023 22:18
@tchapi
Copy link
Owner Author

tchapi commented Oct 17, 2023

Thanks for your ideas. I've tried Thunderbird and could find a potential fix that I implemented in 5874935.

@tchapi
Copy link
Owner Author

tchapi commented Oct 17, 2023

Happy to get your feedback on it. Sorry this is taking quite some time 🙇🏼

@1Luc1
Copy link

1Luc1 commented Oct 21, 2023

Thanks for your fix. Tested it as good as possible and subscribing without username/password works as intended. Unfortunately, it is now not possible as an owner of the calender to subscribe to the calender with username and password, within Thunderbird. This is of course necessary to write events into the "public" calendar.

@1Luc1
Copy link

1Luc1 commented Oct 21, 2023

During testing I came across a use case, which should be covered within this PR. I mentioned it some comments above and thought it was a problem. Now I think the following use case should be covered:

Having a calender which should be shared with other users. The other users have read/write access to the shared calender, meaning a group of users can edit one calender. This calender can also be a public calender.

A good example is having an event calender. Some people add/edit events within this calender and want to make the event calender public available to publicity.

Before you changed this behavior, you talked about side effects. I'm curious, are there any?

@tchapi
Copy link
Owner Author

tchapi commented Oct 27, 2023

Having a calender which should be shared with other users.

This will be another use case that I won't cover right now

it is now not possible as an owner of the calender to subscribe to the calender with username and password, within Thunderbird.

I have tested and it is possible on my side. Either you provide the credentials and uncheck "read-only" — Thunderbird will ask for the password once (you can store it), and you can create event (as the owner of the calendar). Or you check "read only" and you don't need to authenticate, and will just retrieve the events

Below: private version (auth) is the calendar I used to create both events. They appear in the "public" version (of the same calendar)
Screenshot 2023-10-27 at 20 57 51

@tchapi
Copy link
Owner Author

tchapi commented Oct 27, 2023

So all in all, I think it's correctly working as of now (at last!). Will leave it open for a while and then merge to the master

@1Luc1
Copy link

1Luc1 commented Oct 29, 2023

Thanks for re-testing. Your are right, it works as intended. Thanks again for your work!

Having a calender which should be shared with other users.

This will be another use case that I won't cover right now

Alright. Should a make a new Issue for this case?

@tchapi
Copy link
Owner Author

tchapi commented Oct 29, 2023

Your are right, it works as intended. Thanks again for your work!

🎉 🎉 🎉 🎉 🎉 🎉 🎉

Should a make a new Issue for this case?

Yes please. Given the time it takes to fiddle with sabre/dav code, I'm not promising anything though sorry. It's really a pain to find circumvention ways for something that should be standard

@tchapi tchapi merged commit 275bada into master Oct 29, 2023
8 checks passed
@tchapi tchapi deleted the feature/public-calendars branch October 29, 2023 19:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Crosspost] Have a calender to be subscribable without authentication
3 participants