Documentation ¶
Index ¶
- func Create(client *resty.Client, builder *Builder) error
- func IDFromMethodPath(method string, path string) string
- func IDFromRequest(req *restful.Request) string
- func InputFromRequest(req *restful.Request) (map[Input]interface{}, error)
- type Builder
- type Input
- type PolicyHandler
- func (h *PolicyHandler) Filter(req *restful.Request, resp *restful.Response, chain *restful.FilterChain)
- func (h *PolicyHandler) Handle(req *restful.Request, resp *restful.Response)
- func (h *PolicyHandler) Name() string
- func (h *PolicyHandler) Setup(ctx context.Context, add sharedmain.AddToRestContainer, ...) error
- type Store
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IDFromMethodPath ¶
IDFromMethodPath generates a unique ID for the policy based on the method and path.
func IDFromRequest ¶
func IDFromRequest(req *restful.Request) string
IDFromRequest generates a unique ID for the policy based on request
func InputFromRequest ¶
InputFromRequest extracts different types of inputs (auth, meta, etc.) from a restful request.
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder is a struct for building fake policies. It holds information about the method, path, input, value, status, and result of a policy.
func NewPolicyBuilder ¶
func (*Builder) Complete ¶
Complete finalizes the policy construction and returns the policy. It uses a template to generate the policy based on the set conditions.
type Input ¶
type Input string
Input is a custom type representing different types of request inputs.
type PolicyHandler ¶
type PolicyHandler struct { *zap.SugaredLogger Store Store }
PolicyHandler is a struct that handles OPA policies requests.
func (*PolicyHandler) Filter ¶
func (h *PolicyHandler) Filter(req *restful.Request, resp *restful.Response, chain *restful.FilterChain)
Filter is a method that intercepts and processes incoming HTTP requests using OPA policies. It evaluates the request against a specific policy identified by the request's method and path, and modifies the response based on the policy's evaluation results.
func (*PolicyHandler) Handle ¶
func (h *PolicyHandler) Handle(req *restful.Request, resp *restful.Response)
func (*PolicyHandler) Name ¶
func (h *PolicyHandler) Name() string
func (*PolicyHandler) Setup ¶
func (h *PolicyHandler) Setup(ctx context.Context, add sharedmain.AddToRestContainer, logger *zap.SugaredLogger) error