Documentation
¶
Overview ¶
Package foldergrant keeps write grants on Global folders (#2684): an administrator grants a person (by address) or a persona write on one folder of the Global library, and the grant covers that folder and everything beneath it (resource.PathUnder). A grant is a share whose target is the folder's path (portal_shares.folder_path), read on every request a resources check asks about, through the source installed in pkg/resource.
Only administrators list, add and remove grants; a grantee only learns that they can write somewhere.
Index ¶
- Variables
- type API
- type AddInput
- type Deps
- type Grant
- type GrantList
- type Source
- type Store
- func (s *Store) Add(ctx context.Context, g *Grant) error
- func (s *Store) ByPersona(ctx context.Context, persona string) ([]Grant, error)
- func (s *Store) FolderExists(ctx context.Context, path string) (bool, error)
- func (s *Store) List(ctx context.Context, folder string) ([]Grant, error)
- func (s *Store) Remove(ctx context.Context, id string) (*Grant, error)
- func (s *Store) Sites(ctx context.Context, path string) ([]string, error)
- func (s *Store) Writable(ctx context.Context, g grantsource.Grantee) ([]string, error)
Constants ¶
This section is empty.
Variables ¶
var ErrDuplicate = errors.New("this folder already grants write to that person or persona")
ErrDuplicate is a grant the folder already holds for the same grantee.
var ErrNotFound = errors.New("folder grant not found")
ErrNotFound is a grant that does not exist or was already removed.
Functions ¶
This section is empty.
Types ¶
type AddInput ¶
type AddInput struct {
Folder string `json:"folder" example:"reports"`
Email string `json:"email,omitempty" example:"jane@example.com"`
Persona string `json:"persona,omitempty" example:"finance"`
}
AddInput grants write on a Global folder to a person or a persona.
type Deps ¶
type Deps struct {
Store *Store
// Actor is the administrator's address; every request passed the admin
// API's authentication.
Actor func(*http.Request) string
// PersonaExists reports whether a persona is defined.
PersonaExists func(name string) bool
// ExternalPersona reports whether a persona is external.
ExternalPersona func(name string) bool
// ExternalPerson reports whether the person at an address resolves to an
// external persona now; nil reads nobody as one.
ExternalPerson func(ctx context.Context, email string) bool
// FolderExists reports whether a Global folder exists (stored, or holding
// a file).
FolderExists func(ctx context.Context, path string) (bool, error)
// Sites names the sites serving a Global folder or one above it as media;
// nil names none.
Sites func(ctx context.Context, path string) ([]string, error)
// Audit records every change; nil records none.
Audit middleware.AuditLogger
}
Deps is what the routes act through.
type Grant ¶
type Grant struct {
ID string `json:"id" example:"fg_9c1e"`
// Folder is the Global folder the grant is on.
Folder string `json:"folder" example:"reports"`
// Email is the person it is for, "" for a persona grant.
Email string `json:"email,omitempty" example:"jane@example.com"`
// Persona is the persona it is for, "" for a person's grant.
Persona string `json:"persona,omitempty" example:"finance"`
CreatedBy string `json:"created_by" example:"admin@example.com"`
CreatedAt time.Time `json:"created_at"`
// Inherited is a grant on a folder above the one asked about, which
// covers it too.
Inherited bool `json:"inherited"`
}
Grant is one write grant on a Global folder.
type GrantList ¶
type GrantList struct {
Folder string `json:"folder" example:"reports"`
Grants []Grant `json:"grants"`
// Sites are the sites serving the folder, or one above it, as media: a
// grantee's write changes what they serve.
Sites []string `json:"sites"`
}
GrantList is the grants covering a Global folder.
type Source ¶
type Source struct {
Store *Store
// External reports whether a persona is external; nil reads none as one.
External func(persona string) bool
}
Source is the resource.FolderGrantSource the platform installs: a grantee's grants, none for a person any of whose personas is now external, since a person of an external persona never sees Global.
func (Source) WritableFolders ¶
WritableFolders is resource.FolderGrantSource.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store reads and writes grants.
func (*Store) FolderExists ¶
FolderExists reports whether the Global folder exists.
func (*Store) List ¶
List is the grants covering folder, its own first after the inherited ones, each marked inherited when it is on a folder above.