Documentation
¶
Overview ¶
Package securityprofile selects the security profile every session opens with and runs Customize, the one profile change that writes a policy file. The profile id lives in config.json; Customize copies the presets in force into the USER permissions file, then persists custom. A write's settings event goes out through Store.Publish; callers own the rest of what follows a change: recycling sessions and the permissions event.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoLivePolicy: the profile's own rules could not be read. An empty Custom drops every // grant and is indistinguishable from a session not yet started, so nothing is written. ErrNoLivePolicy = errors.New("no live policy to read preset rules from") // ErrUserFileUnreadable: the user permissions file exists and does not parse. ErrUserFileUnreadable = errors.New("the user permissions file could not be read") // ErrUserFileFull: the user permissions file is at its rule limit. ErrUserFileFull = errors.New("the user permissions file is at its rule limit") // ErrRestoreFailed: persisting custom failed AND the copied rules could not be taken back // out, so the user file holds them under the old profile. ErrRestoreFailed = errors.New("the copied rules could not be taken back out of the user permissions file") )
Customize's refusals. Each leaves both files as they were, except ErrRestoreFailed.
Functions ¶
This section is empty.
Types ¶
type Store ¶
type Store struct {
List func(ctx context.Context, scope string) ([]marotte.PolicyRule, error)
Publish func(context.Context, marotte.ServerEvent)
ConfigDir string
WorkDir string
}
Store resolves and changes the profile for one workspace. List reads the live policy of a session opened with the active profile; nil means no live policy. Publish gets the settings_updated event of each profile write (settings.Update's publish); nil sends none.
func (*Store) Active ¶
Active is the profile in force with the session door's fallback, so a reader shows what the sessions opened with.
func (*Store) Customize ¶
Customize copies the preset rules in force into the user file, then persists custom. The read comes first, and a failed persist puts the file back. It is durable from its first write: a caller walking away must not strand the copied grants. On Custom it refuses with ErrNoLivePolicy, since Custom carries no presets and a stale request could still read a session on the old profile and save over a rule KAS wrote since the switch.
func (*Store) EnsureCustom ¶
EnsureCustom runs Customize unless the profile already is Custom, deciding under the same lock, so of two concurrent callers only the first switches. switched reports whether this call did.