Refuse unless the request is for the grant's repository (and names no host workspace) and `named` — the view the request names, if any — is the grant's.
(
&self,
handle: &RepoHandle,
repository: &RepositoryRef,
named: Option<&ViewRef>,
)
| 507 | /// host workspace) and `named` — the view the request names, if any — is |
| 508 | /// the grant's. |
| 509 | pub fn require_target( |
| 510 | &self, |
| 511 | handle: &RepoHandle, |
| 512 | repository: &RepositoryRef, |
| 513 | named: Option<&ViewRef>, |
| 514 | ) -> Result<(), Status> { |
| 515 | if repository.workspace_id.is_some() { |
| 516 | return Err(domain_status( |
| 517 | ErrorCode::Forbidden, |
| 518 | "a sandbox request may not name a host workspace", |
| 519 | )); |
| 520 | } |
| 521 | if handle.repository_id() != self.grant.repository_id { |
| 522 | return Err(domain_status( |
| 523 | ErrorCode::Forbidden, |
| 524 | "this sandbox's grant is for another repository", |
| 525 | )); |
| 526 | } |
| 527 | if let Some(named) = named { |
| 528 | let by_name = named.name.as_deref().is_some_and(|n| n != self.grant.view); |
| 529 | let by_id = !named.view_id.is_empty() && named.view_id != view_ref_id(&self.grant.view); |
| 530 | if by_name || by_id { |
| 531 | return Err(domain_status( |
| 532 | ErrorCode::Forbidden, |
| 533 | format!( |
| 534 | "that view is not this sandbox's (view '{}')", |
| 535 | self.grant.view |
| 536 | ), |
| 537 | )); |
| 538 | } |
| 539 | } |
| 540 | Ok(()) |
| 541 | } |
| 542 | |
| 543 | /// Check the grant again — after time spent waiting for the repository, |
| 544 | /// it may have expired or been revoked. |
no test coverage detected