fleet/server/test/context.go
Zach Wasserman 18faa5a06b
Add authorization checks in service (#938)
- Add policy.rego file defining authorization policies.
- Add Go integrations to evaluate Rego policies (via OPA).
- Add middleware to ensure requests without authorization check are rejected (guard against programmer error).
- Add authorization checks to most service endpoints.
2021-06-03 16:24:15 -07:00

14 lines
337 B
Go

package test
import (
"context"
"github.com/fleetdm/fleet/server/contexts/viewer"
"github.com/fleetdm/fleet/server/kolide"
)
// UserContext returns a new context with the provided user as the viewer.
func UserContext(user *kolide.User) context.Context {
return viewer.NewContext(context.Background(), viewer.Viewer{User: user})
}