MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / authorizeDoc

Method authorizeDoc

db/crud.go:674–687  ·  view source on GitHub ↗

Returns an HTTP 403 error if the User is not allowed to access any of this revision's channels.

(doc *Document, revid string)

Source from the content-addressed store, hash-verified

672
673// Returns an HTTP 403 error if the User is not allowed to access any of this revision's channels.
674func (col *DatabaseCollectionWithUser) authorizeDoc(doc *Document, revid string) error {
675 user := col.user
676 if doc == nil || user == nil {
677 return nil // A nil User means access control is disabled
678 }
679
680 if revChannels, ok := doc.channelsForRevTreeID(revid); ok {
681 // Authenticate against specific revision:
682 return col.user.AuthorizeAnyCollectionChannel(col.ScopeName, col.Name, revChannels)
683 } else {
684 // No such revision; let the caller proceed and return a 404
685 return nil
686 }
687}
688
689// Gets a revision of a document. If it's obsolete it will be loaded from the database if possible.
690// inline "_attachments" properties in the body will be extracted and returned separately if present (pre-2.5 metadata, or backup revisions)

Callers 1

get1xRevFromDocMethod · 0.95

Calls 2

channelsForRevTreeIDMethod · 0.80

Tested by

no test coverage detected