Skip to content
This repository has been archived by the owner on Apr 29, 2024. It is now read-only.

Commit

Permalink
radicle: Authorize certain changes if no-op
Browse files Browse the repository at this point in the history
For backwards compatibility, if a change is a no-op, we allow it even if
it's normall not authorized.
  • Loading branch information
cloudhead committed Feb 23, 2024
1 parent 0726754 commit 09f2bef
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
18 changes: 16 additions & 2 deletions radicle/src/cob/issue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down
9 changes: 8 additions & 1 deletion radicle/src/cob/patch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 09f2bef

Please sign in to comment.