Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/opa-envoy-plugin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

"github.com/open-policy-agent/opa-envoy-plugin/plugin"
"github.com/open-policy-agent/opa/cmd"
"github.com/open-policy-agent/opa/runtime"
"github.com/open-policy-agent/opa/v1/runtime"
)

func main() {
Expand Down
18 changes: 9 additions & 9 deletions envoyauth/evaluation.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import (
"context"
"fmt"

"github.com/open-policy-agent/opa/ast"
"github.com/open-policy-agent/opa/config"
"github.com/open-policy-agent/opa/logging"
"github.com/open-policy-agent/opa/rego"
"github.com/open-policy-agent/opa/storage"
"github.com/open-policy-agent/opa/topdown/builtins"
iCache "github.com/open-policy-agent/opa/topdown/cache"
"github.com/open-policy-agent/opa/topdown/print"
"github.com/open-policy-agent/opa/tracing"
"github.com/open-policy-agent/opa/v1/ast"
"github.com/open-policy-agent/opa/v1/config"
"github.com/open-policy-agent/opa/v1/logging"
"github.com/open-policy-agent/opa/v1/rego"
"github.com/open-policy-agent/opa/v1/storage"
"github.com/open-policy-agent/opa/v1/topdown/builtins"
iCache "github.com/open-policy-agent/opa/v1/topdown/cache"
"github.com/open-policy-agent/opa/v1/topdown/print"
"github.com/open-policy-agent/opa/v1/tracing"
)

// EvalContext - This is an SPI that has to be provided if the envoy external authorization
Expand Down
28 changes: 13 additions & 15 deletions envoyauth/evaluation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,18 @@ import (
"sync"
"testing"

"github.com/open-policy-agent/opa/config"
"github.com/open-policy-agent/opa/tracing"

"github.com/open-policy-agent/opa/logging"
loggingtest "github.com/open-policy-agent/opa/logging/test"
"github.com/open-policy-agent/opa/plugins/logs"

"github.com/open-policy-agent/opa/ast"
"github.com/open-policy-agent/opa/plugins"
"github.com/open-policy-agent/opa/rego"
"github.com/open-policy-agent/opa/storage"
"github.com/open-policy-agent/opa/storage/inmem"
iCache "github.com/open-policy-agent/opa/topdown/cache"
"github.com/open-policy-agent/opa/topdown/print"
"github.com/open-policy-agent/opa/v1/ast"
"github.com/open-policy-agent/opa/v1/config"
"github.com/open-policy-agent/opa/v1/logging"
loggingtest "github.com/open-policy-agent/opa/v1/logging/test"
"github.com/open-policy-agent/opa/v1/plugins"
"github.com/open-policy-agent/opa/v1/plugins/logs"
"github.com/open-policy-agent/opa/v1/rego"
"github.com/open-policy-agent/opa/v1/storage"
"github.com/open-policy-agent/opa/v1/storage/inmem"
iCache "github.com/open-policy-agent/opa/v1/topdown/cache"
"github.com/open-policy-agent/opa/v1/topdown/print"
"github.com/open-policy-agent/opa/v1/tracing"
)

type testPrintHook struct {
Expand Down Expand Up @@ -116,7 +114,7 @@ func testAuthzServer(logger logging.Logger) (*mockExtAuthzGrpcServer, error) {

default allow = false

allow {
allow if {
input.parsed_body.firstname == "foo"
input.parsed_body.lastname == "bar"
print(input.parsed_body)
Expand Down
4 changes: 2 additions & 2 deletions envoyauth/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import (
"google.golang.org/protobuf/reflect/protoregistry"
"google.golang.org/protobuf/types/dynamicpb"

"github.com/open-policy-agent/opa/logging"
"github.com/open-policy-agent/opa/util"
"github.com/open-policy-agent/opa/v1/logging"
"github.com/open-policy-agent/opa/v1/util"
)

var v2Info = map[string]string{"ext_authz": "v2", "encoding": "encoding/json"}
Expand Down
4 changes: 2 additions & 2 deletions envoyauth/request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (

ext_authz "github.com/envoyproxy/go-control-plane/envoy/service/auth/v3"
internal_util "github.com/open-policy-agent/opa-envoy-plugin/internal/util"
"github.com/open-policy-agent/opa/logging"
"github.com/open-policy-agent/opa/util"
"github.com/open-policy-agent/opa/v1/logging"
"github.com/open-policy-agent/opa/v1/util"
"google.golang.org/protobuf/reflect/protoregistry"
)

Expand Down
13 changes: 7 additions & 6 deletions envoyauth/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@ import (
"context"
"encoding/json"
"fmt"
"net/http"
"slices"

ext_core_v3 "github.com/envoyproxy/go-control-plane/envoy/config/core/v3"
ext_type_v3 "github.com/envoyproxy/go-control-plane/envoy/type/v3"
_structpb "github.com/golang/protobuf/ptypes/struct"
"github.com/google/uuid"
"github.com/open-policy-agent/opa/bundle"
"github.com/open-policy-agent/opa/metrics"
"github.com/open-policy-agent/opa/storage"
"github.com/open-policy-agent/opa/topdown/builtins"
"github.com/open-policy-agent/opa/v1/bundle"
"github.com/open-policy-agent/opa/v1/metrics"
"github.com/open-policy-agent/opa/v1/storage"
"github.com/open-policy-agent/opa/v1/topdown/builtins"
"google.golang.org/protobuf/types/known/structpb"
"net/http"
"slices"
)

// EvalResult - Captures the result from evaluating a query against an input
Expand Down
6 changes: 3 additions & 3 deletions envoyauth/response_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (
"testing"

_structpb "github.com/golang/protobuf/ptypes/struct"
"github.com/open-policy-agent/opa/bundle"
"github.com/open-policy-agent/opa/storage"
"github.com/open-policy-agent/opa/storage/inmem"
"github.com/open-policy-agent/opa/v1/bundle"
"github.com/open-policy-agent/opa/v1/storage"
"github.com/open-policy-agent/opa/v1/storage/inmem"
"google.golang.org/protobuf/proto"
)

Expand Down
24 changes: 12 additions & 12 deletions internal/internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,18 @@ import (
"google.golang.org/protobuf/reflect/protoregistry"
"google.golang.org/protobuf/types/known/structpb"

"github.com/open-policy-agent/opa/ast"
"github.com/open-policy-agent/opa/config"
"github.com/open-policy-agent/opa/logging"
"github.com/open-policy-agent/opa/plugins"
"github.com/open-policy-agent/opa/plugins/logs"
"github.com/open-policy-agent/opa/rego"
"github.com/open-policy-agent/opa/server"
"github.com/open-policy-agent/opa/storage"
"github.com/open-policy-agent/opa/topdown"
iCache "github.com/open-policy-agent/opa/topdown/cache"
"github.com/open-policy-agent/opa/tracing"
"github.com/open-policy-agent/opa/util"
"github.com/open-policy-agent/opa/v1/ast"
"github.com/open-policy-agent/opa/v1/config"
"github.com/open-policy-agent/opa/v1/logging"
"github.com/open-policy-agent/opa/v1/plugins"
"github.com/open-policy-agent/opa/v1/plugins/logs"
"github.com/open-policy-agent/opa/v1/rego"
"github.com/open-policy-agent/opa/v1/server"
"github.com/open-policy-agent/opa/v1/storage"
"github.com/open-policy-agent/opa/v1/topdown"
iCache "github.com/open-policy-agent/opa/v1/topdown/cache"
"github.com/open-policy-agent/opa/v1/tracing"
"github.com/open-policy-agent/opa/v1/util"

"go.opentelemetry.io/otel/trace"

Expand Down
2 changes: 1 addition & 1 deletion internal/internal_bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
ext_authz "github.com/envoyproxy/go-control-plane/envoy/service/auth/v3"
"google.golang.org/genproto/googleapis/rpc/code"

"github.com/open-policy-agent/opa/util"
"github.com/open-policy-agent/opa/v1/util"
)

func BenchmarkCheck(b *testing.B) {
Expand Down
54 changes: 27 additions & 27 deletions internal/internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ import (
"google.golang.org/protobuf/proto"

"github.com/open-policy-agent/opa-envoy-plugin/envoyauth"
"github.com/open-policy-agent/opa/ast"
"github.com/open-policy-agent/opa/plugins"
"github.com/open-policy-agent/opa/plugins/logs"
"github.com/open-policy-agent/opa/storage"
"github.com/open-policy-agent/opa/storage/inmem"
"github.com/open-policy-agent/opa/topdown"
"github.com/open-policy-agent/opa/util"
"github.com/open-policy-agent/opa/v1/ast"
"github.com/open-policy-agent/opa/v1/plugins"
"github.com/open-policy-agent/opa/v1/plugins/logs"
"github.com/open-policy-agent/opa/v1/storage"
"github.com/open-policy-agent/opa/v1/storage/inmem"
"github.com/open-policy-agent/opa/v1/topdown"
"github.com/open-policy-agent/opa/v1/util"
)

const exampleAllowedRequest = `{
Expand Down Expand Up @@ -469,7 +469,7 @@ func TestCheckAllowWithLoggerNDBCache(t *testing.T) {

default allow = false

allow {
allow if {
res := http.send({"url": "%s", "method": "GET"})
res.status_code == 200
}
Expand Down Expand Up @@ -952,7 +952,7 @@ func TestCheckAllowObjectDecisionWithBadReqHeadersToRemoveWithLogger(t *testing.

default allow = false

allow {
allow if {
input.parsed_path = ["my", "test", "path"]
}

Expand Down Expand Up @@ -1150,7 +1150,7 @@ func TestCheckTwiceWithCachedBuiltinCall(t *testing.T) {
package envoy.authz

default allow = false
allow {
allow if {
resp := http.send({"url": "%s", "method":"GET",
"force_cache": true, "force_cache_duration_seconds": 10})
resp.body.count == 1
Expand Down Expand Up @@ -1379,7 +1379,7 @@ func TestCheckAllowObjectDecisionDynamicMetadata(t *testing.T) {

default allow = false

allow {
allow if {
input.parsed_path = ["my", "test", "path"]
}

Expand Down Expand Up @@ -1433,7 +1433,7 @@ func TestCheckAllowObjectDecisionDynamicMetadataDecisionID(t *testing.T) {

default allow = false

allow {
allow if {
input.parsed_path = ["my", "test", "path"]
}

Expand Down Expand Up @@ -1469,7 +1469,7 @@ func TestCheckAllowBooleanDecisionDynamicMetadata(t *testing.T) {

default allow = false

allow {
allow if {
input.parsed_path = ["my", "test", "path"]
}
`
Expand Down Expand Up @@ -1499,7 +1499,7 @@ func TestCheckAllowBooleanDecisionDynamicMetadataDecisionID(t *testing.T) {

default allow = false

allow {
allow if {
input.parsed_path = ["my", "test", "path"]
}
`
Expand Down Expand Up @@ -1573,7 +1573,7 @@ func TestCheckAllowObjectDecisionReqHeadersToRemove(t *testing.T) {

default allow = false

allow {
allow if {
input.parsed_path = ["my", "test", "path"]
}

Expand Down Expand Up @@ -1625,7 +1625,7 @@ func TestCheckAllowObjectDecisionResponseHeadersToAdd(t *testing.T) {

default allow = false

allow {
allow if {
input.parsed_path = ["my", "test", "path"]
}

Expand Down Expand Up @@ -1677,7 +1677,7 @@ func TestCheckAllowObjectDecisionMultiValuedHeaders(t *testing.T) {

default allow = false

allow {
allow if {
input.parsed_path = ["my", "test", "path"]
}

Expand Down Expand Up @@ -1976,34 +1976,34 @@ func testAuthzServer(customConfig *Config, customPluginFuncs ...customPluginFunc

default allow = false

allow {
allow if {
roles_for_user[r]
required_roles[r]
}

allow {
allow if {
input.parsed_path = ["my", "test", "path"]
input.parsed_query.a = ["1", "2"]
input.parsed_query.x = ["y"]
}

allow {
allow if {
input.parsed_body.firstname == "foo"
input.parsed_body.lastname == "bar"
input.parsed_body.dept.it == "eng"
}

roles_for_user[r] {
roles_for_user[r] if {
r := user_roles[user_name][_]
}

required_roles[r] {
required_roles[r] if {
perm := role_perms[r][_]
perm.method = http_request.method
perm.path = http_request.path
}

user_name = parsed {
user_name = parsed if {
[_, encoded] := split(http_request.headers.authorization, " ")
[parsed, _] := split(base64url.decode(encoded), ":")
}
Expand Down Expand Up @@ -2080,7 +2080,7 @@ func testAuthzServerWithObjectDecision(customConfig *Config, customPluginFuncs .
"dynamic_metadata": {"test": "foo", "bar": "baz"}
}

allow = response {
allow = response if {
input.parsed_path = ["my", "test", "path"]
response := {
"allowed": true,
Expand All @@ -2098,7 +2098,7 @@ func testAuthzServerWithTruncatedBody(customConfig *Config, customPluginFuncs ..

default allow = false

allow {
allow if {
not input.truncated_body
}
`
Expand Down Expand Up @@ -2197,7 +2197,7 @@ func TestVersionInfoInputV3(t *testing.T) {
module := `
package envoy.authz

allow {
allow if {
input.version.ext_authz == "v3"
input.version.encoding == "protojson"
}
Expand All @@ -2224,7 +2224,7 @@ func TestVersionInfoInputV2(t *testing.T) {
module := `
package envoy.authz

allow {
allow if {
input.version.ext_authz == "v2"
input.version.encoding == "encoding/json"
}
Expand Down
10 changes: 5 additions & 5 deletions opa/decisionlog/decision_log.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import (
"context"

"github.com/open-policy-agent/opa-envoy-plugin/envoyauth"
"github.com/open-policy-agent/opa/ast"
"github.com/open-policy-agent/opa/plugins/logs"
"github.com/open-policy-agent/opa/server"
"github.com/open-policy-agent/opa/storage"
"github.com/open-policy-agent/opa/topdown"
"github.com/open-policy-agent/opa/v1/ast"
"github.com/open-policy-agent/opa/v1/plugins/logs"
"github.com/open-policy-agent/opa/v1/server"
"github.com/open-policy-agent/opa/v1/storage"
"github.com/open-policy-agent/opa/v1/topdown"
)

type internalError struct {
Expand Down
2 changes: 1 addition & 1 deletion plugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
package plugin

import (
"github.com/open-policy-agent/opa/plugins"
"github.com/open-policy-agent/opa/v1/plugins"

"github.com/open-policy-agent/opa-envoy-plugin/internal"
)
Expand Down
Loading
Loading