Documentation
¶
Overview ¶
Package protoperm is the one place the protocol front ends (ftpsrv, sftpsrv, nfssrv, dav, s3api) ask per-user permissions (package perm) about a path.
Each protocol owns the shape of its refusal — NoSuchFile, 550, EACCES, AccessDenied — and none of them owns the question. Written once per protocol, the question drifted before it was ever asked: one front end checked the level and forgot the permission, another the lock. Here it is the level, the lock and the permission, in one call.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CanDo ¶
func CanDo(ctx context.Context, set *acl.Set, st *model.Storage, resolver *acl.Resolver, rel string, p perm.Perm) bool
CanDo is the door for every change: the storage exists and is writable, no app lock refuses the path (read through resolver, so a freeze taken a second ago counts), and the caller may take action p there — the level it needs (≥editor for every mutation) AND the per-user permission, blocked file types included.
func CanRead ¶
CanRead is the door for a file's CONTENT over a protocol: viewer on the path itself (never inherited from being on the way to a grant — that is acl.Set.CanSee's traversal), AND files.download, because reading a file's bytes over a protocol IS a download: there is no preview to leave open.
func VerbFor ¶
VerbFor is the API-token verb (auth.VerbRead / VerbWrite / VerbDelete) the action p needs when the credential behind a protocol session is an API token used as the password: reading content is `read`, removing to the trash or for good is `delete`, every other change is `write` — the same split /dav, /api/files and /api/ai make. A password or a public key carries every verb (protocolauth.Principal.HasScope), so it changes nothing there.
⚠ One mapping, asked by every protocol front end inside its canRead/canDo: a front end that checks the permission and forgets the verb hands a read-only token the right to delete (the gap #112 closed).
Types ¶
This section is empty.