appReadmitBeforeWrite re-admits a write after its body is read and before its write, and reports false after answering: a body can arrive slowly, and the person a delegated token acts for can lose access meanwhile. A full re-admission (the credential, the install, the person, their membership and ro
(w http.ResponseWriter, r *http.Request, itemID, collectionID string)
| 381 | // checks the install and the companion again; what remains is the gap |
| 382 | // between this check and that transaction, the one an upload has. |
| 383 | func (s *Server) appReadmitBeforeWrite(w http.ResponseWriter, r *http.Request, itemID, collectionID string) bool { |
| 384 | ac := appContextFrom(r) |
| 385 | if err := s.appRevalidate(r); err != nil { |
| 386 | switch { |
| 387 | case errors.Is(err, errAppAdmitInternal): |
| 388 | writeInternalError(w, err) |
| 389 | case errors.Is(err, errAppCredential): |
| 390 | writeAppUnauthorized(w) |
| 391 | default: |
| 392 | writeError(w, http.StatusForbidden, "forbidden", "This app may no longer write here") |
| 393 | } |
| 394 | return false |
| 395 | } |
| 396 | if !appWriteAllows(r, collectionID) { |
| 397 | writeError(w, http.StatusForbidden, "forbidden", "This app may no longer write here") |
| 398 | return false |
| 399 | } |
| 400 | ok, err := s.canEditInCollection(r, ac.WorkspaceID, itemID, collectionID) |
| 401 | if err != nil { |
| 402 | writeInternalError(w, err) |
| 403 | return false |
| 404 | } |
| 405 | if !ok { |
| 406 | writeError(w, http.StatusForbidden, "forbidden", "This app may no longer write here") |
| 407 | return false |
| 408 | } |
| 409 | if s.appAfterWriteReadmit != nil { |
| 410 | s.appAfterWriteReadmit() |
| 411 | } |
| 412 | return true |
| 413 | } |
no test coverage detected