From 09f2befa58dc6057e052904b6947bdd17d3b0553 Mon Sep 17 00:00:00 2001 From: cloudhead Date: Fri, 23 Feb 2024 18:29:07 +0100 Subject: [PATCH] radicle: Authorize certain changes if no-op For backwards compatibility, if a change is a no-op, we allow it even if it's normall not authorized. --- radicle/src/cob/issue.rs | 18 ++++++++++++++++-- radicle/src/cob/patch.rs | 9 ++++++++- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/radicle/src/cob/issue.rs b/radicle/src/cob/issue.rs index 71d2dbb03..5ac665cbc 100644 --- a/radicle/src/cob/issue.rs +++ b/radicle/src/cob/issue.rs @@ -329,7 +329,14 @@ impl Issue { let author: ActorId = *self.author().id().as_key(); let outcome = match action { // Only delegate can assign someone to an issue. - Action::Assign { .. } => Authorization::Deny, + Action::Assign { assignees } => { + if assignees == &self.assignees { + // No-op is allowed for backwards compatibility. + Authorization::Allow + } else { + Authorization::Deny + } + } // Issue authors can edit their own issues. Action::Edit { .. } => Authorization::from(*actor == author), // Issue authors can close or re-open their own issue. @@ -338,7 +345,14 @@ impl Issue { State::Open => *actor == author, }), // Only delegate can label an issue. - Action::Label { .. } => Authorization::Deny, + Action::Label { labels } => { + if labels == &self.labels { + // No-op is allowed for backwards compatibility. + Authorization::Allow + } else { + Authorization::Deny + } + } // All roles can comment on an issues Action::Comment { .. } => Authorization::Allow, // All roles can edit or redact their own comments. diff --git a/radicle/src/cob/patch.rs b/radicle/src/cob/patch.rs index 973b9e1bb..c33d91226 100644 --- a/radicle/src/cob/patch.rs +++ b/radicle/src/cob/patch.rs @@ -632,7 +632,14 @@ impl Patch { Lifecycle::Archived { .. } => actor == author, }), // Only delegates can carry out these actions. - Action::Label { .. } => Authorization::Deny, + Action::Label { labels } => { + if labels == &self.labels { + // No-op is allowed for backwards compatibility. + Authorization::Allow + } else { + Authorization::Deny + } + } Action::Assign { .. } => Authorization::Deny, Action::Merge { .. } => match self.target() { MergeTarget::Delegates => Authorization::Deny,