diff --git a/carddav/server.go b/carddav/server.go index 915c49e..dff05da 100644 --- a/carddav/server.go +++ b/carddav/server.go @@ -431,6 +431,13 @@ func (b *backend) propFindRoot(ctx context.Context, propfind *internal.PropFind) } props := map[xml.Name]internal.PropFindFunc{ + internal.CurrentUserPrivilegeSetName: func(*internal.RawXMLValue) (interface{}, error) { + return &internal.CurrentUserPrivilegeSet{ + Privileges: []internal.Privilege{ + {Read: true, Write: true}, + }, + }, nil + }, internal.CurrentUserPrincipalName: func(*internal.RawXMLValue) (interface{}, error) { return &internal.CurrentUserPrincipal{Href: internal.Href{Path: principalPath}}, nil }, @@ -452,6 +459,13 @@ func (b *backend) propFindUserPrincipal(ctx context.Context, propfind *internal. } props := map[xml.Name]internal.PropFindFunc{ + internal.CurrentUserPrivilegeSetName: func(*internal.RawXMLValue) (interface{}, error) { + return &internal.CurrentUserPrivilegeSet{ + Privileges: []internal.Privilege{ + {Read: true, Write: true}, + }, + }, nil + }, internal.CurrentUserPrincipalName: func(*internal.RawXMLValue) (interface{}, error) { return &internal.CurrentUserPrincipal{Href: internal.Href{Path: principalPath}}, nil }, @@ -477,6 +491,13 @@ func (b *backend) propFindHomeSet(ctx context.Context, propfind *internal.PropFi // TODO anything else to return here? props := map[xml.Name]internal.PropFindFunc{ + internal.CurrentUserPrivilegeSetName: func(*internal.RawXMLValue) (interface{}, error) { + return &internal.CurrentUserPrivilegeSet{ + Privileges: []internal.Privilege{ + {Read: true, Write: true}, + }, + }, nil + }, internal.CurrentUserPrincipalName: func(*internal.RawXMLValue) (interface{}, error) { return &internal.CurrentUserPrincipal{Href: internal.Href{Path: principalPath}}, nil }, @@ -489,6 +510,13 @@ func (b *backend) propFindHomeSet(ctx context.Context, propfind *internal.PropFi func (b *backend) propFindAddressBook(ctx context.Context, propfind *internal.PropFind, ab *AddressBook) (*internal.Response, error) { props := map[xml.Name]internal.PropFindFunc{ + internal.CurrentUserPrivilegeSetName: func(*internal.RawXMLValue) (interface{}, error) { + return &internal.CurrentUserPrivilegeSet{ + Privileges: []internal.Privilege{ + {Read: true, Write: true}, + }, + }, nil + }, internal.CurrentUserPrincipalName: func(*internal.RawXMLValue) (interface{}, error) { path, err := b.Backend.CurrentUserPrincipal(ctx) if err != nil { @@ -554,6 +582,13 @@ func (b *backend) propFindAllAddressBooks(ctx context.Context, propfind *interna func (b *backend) propFindAddressObject(ctx context.Context, propfind *internal.PropFind, ao *AddressObject) (*internal.Response, error) { props := map[xml.Name]internal.PropFindFunc{ + internal.CurrentUserPrivilegeSetName: func(*internal.RawXMLValue) (interface{}, error) { + return &internal.CurrentUserPrivilegeSet{ + Privileges: []internal.Privilege{ + {Read: true, Write: true}, + }, + }, nil + }, internal.CurrentUserPrincipalName: func(*internal.RawXMLValue) (interface{}, error) { path, err := b.Backend.CurrentUserPrincipal(ctx) if err != nil { diff --git a/internal/elements.go b/internal/elements.go index db7d960..56feec8 100644 --- a/internal/elements.go +++ b/internal/elements.go @@ -21,7 +21,8 @@ var ( GetLastModifiedName = xml.Name{Namespace, "getlastmodified"} GetETagName = xml.Name{Namespace, "getetag"} - CurrentUserPrincipalName = xml.Name{Namespace, "current-user-principal"} + CurrentUserPrincipalName = xml.Name{Namespace, "current-user-principal"} + CurrentUserPrivilegeSetName = xml.Name{Namespace, "current-user-privilege-set"} ) type Status struct { @@ -417,6 +418,15 @@ type CurrentUserPrincipal struct { Unauthenticated *struct{} `xml:"unauthenticated,omitempty"` } +// https://datatracker.ietf.org/doc/html/rfc3744#section-5.4 +type CurrentUserPrivilegeSet struct { + XMLName xml.Name `xml:"DAV: current-user-privilege-set"` + Privileges []Privilege `xml:"privilege>dynamic"` +} +type Privilege struct { + XMLName xml.Name +} + // https://tools.ietf.org/html/rfc4918#section-14.19 type PropertyUpdate struct { XMLName xml.Name `xml:"DAV: propertyupdate"`