mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-13 19:22:26 +00:00
dav: Implement some principal props for WebDAV ACL
This commit is contained in:
@@ -63,6 +63,15 @@ impl Resource for PrincipalResource {
|
|||||||
PrincipalPropName::CalendarUserAddressSet => {
|
PrincipalPropName::CalendarUserAddressSet => {
|
||||||
PrincipalProp::CalendarUserAddressSet(principal_url.into())
|
PrincipalProp::CalendarUserAddressSet(principal_url.into())
|
||||||
}
|
}
|
||||||
|
PrincipalPropName::GroupMembership => {
|
||||||
|
PrincipalProp::GroupMembership(GroupMembership(
|
||||||
|
user.memberships_without_self()
|
||||||
|
.iter()
|
||||||
|
.map(|principal| puri.principal_uri(principal).into())
|
||||||
|
.collect(),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
PrincipalPropName::AlternateUriSet => PrincipalProp::AlternateUriSet,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
PrincipalPropWrapperName::Common(prop) => PrincipalPropWrapper::Common(
|
PrincipalPropWrapperName::Common(prop) => PrincipalPropWrapper::Common(
|
||||||
|
|||||||
@@ -14,6 +14,10 @@ pub enum PrincipalProp {
|
|||||||
// WebDAV Access Control (RFC 3744)
|
// WebDAV Access Control (RFC 3744)
|
||||||
#[xml(ns = "rustical_dav::namespace::NS_DAV", rename = b"principal-URL")]
|
#[xml(ns = "rustical_dav::namespace::NS_DAV", rename = b"principal-URL")]
|
||||||
PrincipalUrl(HrefElement),
|
PrincipalUrl(HrefElement),
|
||||||
|
#[xml(ns = "rustical_dav::namespace::NS_DAV")]
|
||||||
|
GroupMembership(GroupMembership),
|
||||||
|
#[xml(ns = "rustical_dav::namespace::NS_DAV", rename = b"alternate-URI-set")]
|
||||||
|
AlternateUriSet,
|
||||||
|
|
||||||
// CalDAV (RFC 4791)
|
// CalDAV (RFC 4791)
|
||||||
#[xml(ns = "rustical_dav::namespace::NS_CALDAV")]
|
#[xml(ns = "rustical_dav::namespace::NS_CALDAV")]
|
||||||
@@ -29,3 +33,6 @@ pub enum PrincipalPropWrapper {
|
|||||||
|
|
||||||
#[derive(XmlDeserialize, XmlSerialize, PartialEq, Clone)]
|
#[derive(XmlDeserialize, XmlSerialize, PartialEq, Clone)]
|
||||||
pub struct CalendarHomeSet(#[xml(ty = "untagged", flatten)] pub(super) Vec<HrefElement>);
|
pub struct CalendarHomeSet(#[xml(ty = "untagged", flatten)] pub(super) Vec<HrefElement>);
|
||||||
|
|
||||||
|
#[derive(XmlDeserialize, XmlSerialize, PartialEq, Clone)]
|
||||||
|
pub struct GroupMembership(#[xml(ty = "untagged", flatten)] pub(super) Vec<HrefElement>);
|
||||||
|
|||||||
@@ -59,6 +59,15 @@ impl Resource for PrincipalResource {
|
|||||||
PrincipalProp::AddressbookHomeSet(home_set)
|
PrincipalProp::AddressbookHomeSet(home_set)
|
||||||
}
|
}
|
||||||
PrincipalPropName::PrincipalAddress => PrincipalProp::PrincipalAddress(None),
|
PrincipalPropName::PrincipalAddress => PrincipalProp::PrincipalAddress(None),
|
||||||
|
PrincipalPropName::GroupMembership => {
|
||||||
|
PrincipalProp::GroupMembership(GroupMembership(
|
||||||
|
user.memberships_without_self()
|
||||||
|
.iter()
|
||||||
|
.map(|principal| puri.principal_uri(principal).into())
|
||||||
|
.collect(),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
PrincipalPropName::AlternateUriSet => PrincipalProp::AlternateUriSet,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,10 @@ pub enum PrincipalProp {
|
|||||||
#[xml(rename = b"principal-URL")]
|
#[xml(rename = b"principal-URL")]
|
||||||
#[xml(ns = "rustical_dav::namespace::NS_DAV")]
|
#[xml(ns = "rustical_dav::namespace::NS_DAV")]
|
||||||
PrincipalUrl(HrefElement),
|
PrincipalUrl(HrefElement),
|
||||||
|
#[xml(ns = "rustical_dav::namespace::NS_DAV")]
|
||||||
|
GroupMembership(GroupMembership),
|
||||||
|
#[xml(ns = "rustical_dav::namespace::NS_DAV", rename = b"alternate-URI-set")]
|
||||||
|
AlternateUriSet,
|
||||||
|
|
||||||
// CardDAV (RFC 6352)
|
// CardDAV (RFC 6352)
|
||||||
#[xml(ns = "rustical_dav::namespace::NS_CARDDAV")]
|
#[xml(ns = "rustical_dav::namespace::NS_CARDDAV")]
|
||||||
@@ -25,3 +29,6 @@ pub enum PrincipalPropWrapper {
|
|||||||
Principal(PrincipalProp),
|
Principal(PrincipalProp),
|
||||||
Common(CommonPropertiesProp),
|
Common(CommonPropertiesProp),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(XmlDeserialize, XmlSerialize, PartialEq, Clone)]
|
||||||
|
pub struct GroupMembership(#[xml(ty = "untagged", flatten)] pub(super) Vec<HrefElement>);
|
||||||
|
|||||||
@@ -108,6 +108,10 @@ impl User {
|
|||||||
memberships.push(self.id.as_str());
|
memberships.push(self.id.as_str());
|
||||||
memberships
|
memberships
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn memberships_without_self(&self) -> Vec<&str> {
|
||||||
|
self.memberships.iter().map(String::as_str).collect()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl rustical_dav::Principal for User {
|
impl rustical_dav::Principal for User {
|
||||||
|
|||||||
Reference in New Issue
Block a user