Documentation
¶
Overview ¶
Package webhookroute manages an app's webhook routes (R-425, R-432): the routes themselves, which are in the spec, and their secrets, which are not. The proxy decides on a delivery; this package only changes what it decides by.
Index ¶
- type Authorizer
- type Policy
- type Revisions
- type Route
- type Saved
- type Secret
- type Secrets
- type Service
- func (s *Service) Add(ctx context.Context, p authz.Principal, app state.App, r spec.WebhookRoute, ...) (Saved, error)
- func (s *Service) List(ctx context.Context, app state.App) (View, error)
- func (s *Service) Remove(ctx context.Context, p authz.Principal, app state.App, name string) (int, error)
- func (s *Service) SetSecret(ctx context.Context, p authz.Principal, app state.App, name, supplied string) (*Secret, error)
- type View
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Authorizer ¶
type Authorizer interface {
CheckControl(ctx context.Context, p authz.Principal, appID string, verb authz.Verb) error
}
Authorizer is the question this package asks beyond the handler's verb. *authz.Authorizer answers it.
type Revisions ¶
type Revisions interface {
PinnedAndNewest(ctx context.Context, app state.App) (pinned, newest state.Revision, err error)
CreateRevision(ctx context.Context, appID string, s *spec.AppSpec, origin spec.Origin, createdBy string) (state.Revision, error)
}
Revisions reads and writes an app's specs. *state.Apps is one.
type Route ¶
type Route struct {
spec.WebhookRoute
// SecretSet is whether the route has a secret. Without one it refuses
// every delivery (R-430).
SecretSet bool `json:"secret_set"`
// Deployed is whether the app is running this route as it stands. A
// change takes effect at the app's next deploy.
Deployed bool `json:"deployed"`
}
Route is a route as the API shows it.
type Saved ¶
type Saved struct {
Route Route `json:"route"`
Revision int `json:"revision"`
// Secret is set when Pando generated one: the only time it is shown.
Secret *Secret `json:"secret,omitempty"`
}
Saved is a change to an app's routes.
type Secret ¶
type Secret struct {
// contains filtered or unexported fields
}
Secret is a generated secret, shown once. R-194 holds everywhere else: the one response that carries it marshals it in the clear, on purpose (R-427).
func (Secret) MarshalJSON ¶
MarshalJSON writes the secret itself.
type Secrets ¶
type Secrets interface {
Put(ctx context.Context, appID, route string, v secret.Value) error
Names(ctx context.Context, appID string) (map[string]bool, error)
Delete(ctx context.Context, appID, route string) error
}
Secrets keeps routes' secrets. *state.WebhookRouteSecrets is one.
type Service ¶
type Service struct {
Apps Revisions
Secrets Secrets
Policy Policy
Authz Authorizer
Audit func(ctx context.Context, e audit.Event)
}
Service reads and changes an app's webhook routes.
func (*Service) Add ¶
func (s *Service) Add(ctx context.Context, p authz.Principal, app state.App, r spec.WebhookRoute, supplied string) (Saved, error)
Add declares a route and gives it a secret: the one supplied, or a generated one, which comes back in Saved. Declaring is the handler's app.spec.edit; the secret needs app.secrets.write as well (R-427).
func (*Service) Remove ¶
func (s *Service) Remove(ctx context.Context, p authz.Principal, app state.App, name string) (int, error)
Remove takes a route out of the next revision and removes its secret now, so the running route refuses every delivery from here on rather than at the next deploy (R-430).
func (*Service) SetSecret ¶
func (s *Service) SetSecret(ctx context.Context, p authz.Principal, app state.App, name, supplied string) (*Secret, error)
SetSecret replaces a route's secret at once, with no overlap (R-427): the one supplied, or a generated one, which it returns. The handler checks app.secrets.write.