Help us shape the future of Go! Take the 2026 Go Developer Survey

sourcerule

package
v1.152.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 29, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package sourcerule is who may run a managed script for which webhook source (#2332). A run reads every event its source stores, so naming a source is reading it: an administrator may name any source, and anyone else only the source made for a form whose script they own.

Index

Constants

This section is empty.

Variables

View Source
var ErrSourceRefused = errors.New("this script cannot run for that webhook source")

ErrSourceRefused is a script naming a webhook source its owner may not run it for.

Functions

func OwnerOf

func OwnerOf(get func(ctx context.Context, id string) (*script.Script, error)) func(ctx context.Context, scriptID string) (string, error)

OwnerOf is Rule.FormOwner over a script read: the owner's email of the script with the id, "" for a script that does not exist, which owns nothing.

Types

type Rule

type Rule struct {
	Sources SourceReader
	// FormOwner is the owner's email of the script a form source was made
	// for.
	FormOwner func(ctx context.Context, scriptID string) (string, error)
}

Rule is who may run a script for which webhook source (#2332). A run reads every event the source stores, so naming a source is reading it: an administrator may name any source, and anyone else only the source made for a form whose script they own, which holds the submissions their own form collected.

func NewRule

func NewRule(db *sql.DB, get func(ctx context.Context, id string) (*script.Script, error)) *Rule

NewRule is the rule over the stored webhook sources and the scripts get reads, nil without a database. A source is read only for its name and its form, so its secrets are not decrypted.

func (Rule) Check

func (r Rule) Check(ctx context.Context, source, callerEmail string, admin bool) error

Check reports why a script may not run for source when the caller names it, nil when it may. An empty source runs the script for none, which anyone who may edit the script may choose.

func (*Rule) Set

func (r *Rule) Set(ctx context.Context, sc *script.Script, source *string, callerEmail string, admin bool) error

Set sets the webhook source sc runs for to source once the caller may name it; a nil source leaves it alone. A nil Rule refuses naming any source.

type SourceReader

type SourceReader interface {
	Get(ctx context.Context, name string) (whsource.Source, error)
}

SourceReader reads a webhook source by name (whsource.Store).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL