Skip to content

Commit a0984ff

Browse files
committed
✨(calendar) add link to a CalDAV instance to accept events directly
1 parent cdd8be1 commit a0984ff

55 files changed

Lines changed: 7015 additions & 650 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/backend/core/api/openapi.json

Lines changed: 442 additions & 0 deletions
Large diffs are not rendered by default.

src/backend/core/api/permissions.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,3 +691,22 @@ def has_permission(self, request, view):
691691
return models.MailboxAccess.objects.filter(
692692
user=request.user, mailbox=view.kwargs.get("mailbox_id")
693693
).exists()
694+
695+
696+
class HasWriteAccessToMailbox(IsAuthenticated):
697+
"""Allows access only to users with an editor-or-above role on the mailbox.
698+
699+
Use for state-changing endpoints whose effect is observable beyond the
700+
mailbox itself (e.g. writing to the mailbox's CalDAV calendar, which a
701+
VIEWER access shouldn't be able to do).
702+
"""
703+
704+
def has_permission(self, request, view):
705+
if not super().has_permission(request, view):
706+
return False
707+
708+
return models.MailboxAccess.objects.filter(
709+
user=request.user,
710+
mailbox=view.kwargs.get("mailbox_id"),
711+
role__in=enums.MAILBOX_ROLES_CAN_EDIT,
712+
).exists()

src/backend/core/api/serializers.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1965,6 +1965,10 @@ class Meta:
19651965
# generators write directly to ``encrypted_settings`` instead.
19661966
RESERVED_SETTINGS_KEYS = {
19671967
enums.ChannelTypes.API_KEY: ["api_key_hashes"],
1968+
# CalDAV credentials must live in ``encrypted_settings``, never in
1969+
# the plaintext ``settings`` JSONField — a DB read would otherwise
1970+
# surface every user's CalDAV password.
1971+
enums.ChannelTypes.CALDAV: ["username", "password"],
19681972
}
19691973

19701974
def create(self, validated_data):

0 commit comments

Comments
 (0)