mirror of
https://github.com/pomerium/pomerium.git
synced 2025-08-03 08:50:42 +02:00
authorize: add request IP to rego evaluation (#3107)
This commit is contained in:
parent
5ac55f68b6
commit
a0e64b1cf9
5 changed files with 15 additions and 1 deletions
|
@ -40,16 +40,24 @@ type RequestHTTP struct {
|
|||
URL string `json:"url"`
|
||||
Headers map[string]string `json:"headers"`
|
||||
ClientCertificate string `json:"client_certificate"`
|
||||
IP string `json:"ip"`
|
||||
}
|
||||
|
||||
// NewRequestHTTP creates a new RequestHTTP.
|
||||
func NewRequestHTTP(method string, requestURL url.URL, headers map[string]string, rawClientCertificate string) RequestHTTP {
|
||||
func NewRequestHTTP(
|
||||
method string,
|
||||
requestURL url.URL,
|
||||
headers map[string]string,
|
||||
rawClientCertificate string,
|
||||
ip string,
|
||||
) RequestHTTP {
|
||||
return RequestHTTP{
|
||||
Method: method,
|
||||
Path: requestURL.Path,
|
||||
URL: requestURL.String(),
|
||||
Headers: headers,
|
||||
ClientCertificate: rawClientCertificate,
|
||||
IP: ip,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -481,6 +481,7 @@ func TestEvaluator(t *testing.T) {
|
|||
*mustParseURL("https://from.example.com/"),
|
||||
nil,
|
||||
testValidCert,
|
||||
"",
|
||||
),
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
@ -494,6 +495,7 @@ func TestEvaluator(t *testing.T) {
|
|||
*mustParseURL("https://from.example.com/test"),
|
||||
nil,
|
||||
testValidCert,
|
||||
"",
|
||||
),
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue