Commit ea82541
Changed files (1)
pkg
policies
pkg/policies/init.go
@@ -4,13 +4,13 @@ import (
"embed"
_ "embed"
"encoding/json"
- "fmt"
"io/fs"
"log"
"github.com/cedar-policy/cedar-go"
"github.com/cedar-policy/cedar-go/types"
"github.com/xlgmokha/x/pkg/x"
+ xlog "gitlab.com/mokhax/spike/pkg/log"
)
//go:embed *.cedar
@@ -65,8 +65,15 @@ func Allowed(request cedar.Request) bool {
x.Check(json.Unmarshal([]byte(entitiesJSON), &entities))
ok, diagnostic := All.IsAuthorized(entities, request)
- if len(diagnostic.Errors) > 0 || len(diagnostic.Reasons) > 0 {
- fmt.Printf("%v %v\n", diagnostic.Errors, diagnostic.Reasons)
+ if len(diagnostic.Errors) > 0 {
+ for err := range diagnostic.Errors {
+ xlog.Default.Printf("%v\n", err)
+ }
+ }
+ if len(diagnostic.Reasons) > 0 {
+ for reason := range diagnostic.Reasons {
+ xlog.Default.Printf("%v\n", reason)
+ }
}
return ok == types.Allow
}