ppl: add support for http_path and http_method (#2813)

* ppl: add support for http_path and http_method

* fix import ordering
This commit is contained in:
Caleb Doxsey 2021-12-10 07:28:51 -07:00 committed by GitHub
parent 54ec88fb93
commit 2d04106e6d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 257 additions and 18 deletions

View file

@ -6,6 +6,7 @@ import (
"encoding/base64"
"fmt"
"net/http"
"net/url"
"github.com/go-jose/go-jose/v3"
"github.com/open-policy-agent/opa/rego"
@ -35,11 +36,23 @@ type Request struct {
// RequestHTTP is the HTTP field in the request.
type RequestHTTP struct {
Method string `json:"method"`
Path string `json:"path"`
URL string `json:"url"`
Headers map[string]string `json:"headers"`
ClientCertificate string `json:"client_certificate"`
}
// NewRequestHTTP creates a new RequestHTTP.
func NewRequestHTTP(method string, requestURL url.URL, headers map[string]string, rawClientCertificate string) RequestHTTP {
return RequestHTTP{
Method: method,
Path: requestURL.Path,
URL: requestURL.String(),
Headers: headers,
ClientCertificate: rawClientCertificate,
}
}
// RequestSession is the session field in the request.
type RequestSession struct {
ID string `json:"id"`