Skip to content

Agent Mesh

fix(identity): translate mesh policy roles to Datalog facts during Biscuit minting

Antonio Ojeaac97ed0c40bd
diff --git a/api/datalog.go b/api/datalog.go
index 3648efbe..ddb05088 100644
--- a/api/datalog.go
+++ b/api/datalog.go
@@ -17,6 +17,7 @@ package api
import (
"fmt"
"maps"
+ "strings"
"github.com/biscuit-auth/biscuit-go/v2"
"github.com/biscuit-auth/biscuit-go/v2/parser"
@@ -333,3 +334,63 @@ func init() {
panic(fmt.Sprintf("failed to parse static allow policy: %v", err))
}
}
+
+// BuildServiceDatalogFact translates a service pattern string into a Datalog Fact.
+func BuildServiceDatalogFact(serviceStr string) biscuit.Fact {
+ svcType, svcName := ParseServiceTarget(serviceStr)
+ if svcType == "*" && svcName == "*" {
+ return biscuit.Fact{Predicate: biscuit.Predicate{
+ Name: FactGrantedServiceAllTypes,
+ IDs: []biscuit.Term{},
+ }}
+ } else if svcName == "*" {
+ return biscuit.Fact{Predicate: biscuit.Predicate{
+ Name: FactGrantedServiceAll,
+ IDs: []biscuit.Term{biscuit.String(svcType)},
+ }}
+ } else if strings.HasPrefix(svcName, "*.") {
+ return biscuit.Fact{Predicate: biscuit.Predicate{
+ Name: FactGrantedServiceSuffix,
+ IDs: []biscuit.Term{biscuit.String(svcType), biscuit.String(svcName[1:])},
+ }}
+ } else if strings.HasSuffix(svcName, ".*") {
+ return biscuit.Fact{Predicate: biscuit.Predicate{
+ Name: FactGrantedServicePrefix,
+ IDs: []biscuit.Term{biscuit.String(svcType), biscuit.String(svcName[:len(svcName)-1])},
+ }}
+ }
+ return biscuit.Fact{Predicate: biscuit.Predicate{
+ Name: FactGrantedServiceExact,
+ IDs: []biscuit.Term{biscuit.String(svcType), biscuit.String(svcName)},
+ }}
+}
+
+// BuildTargetDatalogFact translates a target pattern string into a Datalog Fact.
+func BuildTargetDatalogFact(targetStr string) biscuit.Fact {
+ tFact, tVal := ParseServiceTarget(targetStr)
+ if tFact == "*" && tVal == "*" {
+ return biscuit.Fact{Predicate: biscuit.Predicate{
+ Name: FactGrantedTargetAllFacts,
+ IDs: []biscuit.Term{},
+ }}
+ } else if tVal == "*" {
+ return biscuit.Fact{Predicate: biscuit.Predicate{
+ Name: FactGrantedTargetAll,
+ IDs: []biscuit.Term{biscuit.String(tFact)},
+ }}
+ } else if strings.HasPrefix(tVal, "*.") {
+ return biscuit.Fact{Predicate: biscuit.Predicate{
+ Name: FactGrantedTargetSuffix,
+ IDs: []biscuit.Term{biscuit.String(tFact), biscuit.String(tVal[1:])},
+ }}
+ } else if strings.HasSuffix(tVal, ".*") {
+ return biscuit.Fact{Predicate: biscuit.Predicate{
+ Name: FactGrantedTargetPrefix,
+ IDs: []biscuit.Term{biscuit.String(tFact), biscuit.String(tVal[:len(tVal)-1])},
+ }}
+ }
+ return biscuit.Fact{Predicate: biscuit.Predicate{
+ Name: FactGrantedTargetExact,
+ IDs: []biscuit.Term{biscuit.String(tFact), biscuit.String(tVal)},
+ }}
+}
diff --git a/api/datalog_test.go b/api/datalog_test.go
index a416927c..13e7ae5c 100644
--- a/api/datalog_test.go
+++ b/api/datalog_test.go
@@ -366,3 +366,73 @@ func TestOIDCClaimToFact(t *testing.T) {
t.Errorf("OIDCClaimToFact() returned map is not a clone, modifications affect internal state")
}
}
+
+func TestBuildServiceDatalogFact(t *testing.T) {
+ tests := []struct {
+ input string
+ expected biscuit.Fact
+ }{
+ {
+ input: "*",
+ expected: biscuit.Fact{Predicate: biscuit.Predicate{Name: FactGrantedServiceAllTypes, IDs: []biscuit.Term{}}},
+ },
+ {
+ input: "mcp://*",
+ expected: biscuit.Fact{Predicate: biscuit.Predicate{Name: FactGrantedServiceAll, IDs: []biscuit.Term{biscuit.String("mcp")}}},
+ },
+ {
+ input: "mcp://*.local",
+ expected: biscuit.Fact{Predicate: biscuit.Predicate{Name: FactGrantedServiceSuffix, IDs: []biscuit.Term{biscuit.String("mcp"), biscuit.String(".local")}}},
+ },
+ {
+ input: "mcp://calc.*",
+ expected: biscuit.Fact{Predicate: biscuit.Predicate{Name: FactGrantedServicePrefix, IDs: []biscuit.Term{biscuit.String("mcp"), biscuit.String("calc.")}}},
+ },
+ {
+ input: "mcp://calculator",
+ expected: biscuit.Fact{Predicate: biscuit.Predicate{Name: FactGrantedServiceExact, IDs: []biscuit.Term{biscuit.String("mcp"), biscuit.String("calculator")}}},
+ },
+ }
+
+ for _, tt := range tests {
+ got := BuildServiceDatalogFact(tt.input)
+ if got.String() != tt.expected.String() {
+ t.Errorf("BuildServiceDatalogFact(%q) = %s, want %s", tt.input, got.String(), tt.expected.String())
+ }
+ }
+}
+
+func TestBuildTargetDatalogFact(t *testing.T) {
+ tests := []struct {
+ input string
+ expected biscuit.Fact
+ }{
+ {
+ input: "*",
+ expected: biscuit.Fact{Predicate: biscuit.Predicate{Name: FactGrantedTargetAllFacts, IDs: []biscuit.Term{}}},
+ },
+ {
+ input: "user:*",
+ expected: biscuit.Fact{Predicate: biscuit.Predicate{Name: FactGrantedTargetAll, IDs: []biscuit.Term{biscuit.String("user")}}},
+ },
+ {
+ input: "group:*.internal",
+ expected: biscuit.Fact{Predicate: biscuit.Predicate{Name: FactGrantedTargetSuffix, IDs: []biscuit.Term{biscuit.String("group"), biscuit.String(".internal")}}},
+ },
+ {
+ input: "group:backend.*",
+ expected: biscuit.Fact{Predicate: biscuit.Predicate{Name: FactGrantedTargetPrefix, IDs: []biscuit.Term{biscuit.String("group"), biscuit.String("backend.")}}},
+ },
+ {
+ input: "group:backend",
+ expected: biscuit.Fact{Predicate: biscuit.Predicate{Name: FactGrantedTargetExact, IDs: []biscuit.Term{biscuit.String("group"), biscuit.String("backend")}}},
+ },
+ }
+
+ for _, tt := range tests {
+ got := BuildTargetDatalogFact(tt.input)
+ if got.String() != tt.expected.String() {
+ t.Errorf("BuildTargetDatalogFact(%q) = %s, want %s", tt.input, got.String(), tt.expected.String())
+ }
+ }
+}
diff --git a/internal/controlplane/server.go b/internal/controlplane/server.go
index c61bb12e..2a786c78 100644
--- a/internal/controlplane/server.go
+++ b/internal/controlplane/server.go
@@ -370,9 +370,16 @@ func (s *Server) HandleRegister(w http.ResponseWriter, r *http.Request) {
finalRoles := []string{req.RequestedRole}
finalRoles = append(finalRoles, customAccessRoles...)
+ policyRoles, _, err := s.store.GetMeshPolicy(ctx)
+ if err != nil {
+ logger.Errorf("Failed to retrieve mesh policy: %v", err)
+ http.Error(w, "Internal server error", http.StatusInternalServerError)
+ return
+ }
+
// Mint token
biscuitExpiry := time.Now().Add(api.BiscuitTokenTTL)
- biscuitData, _, err := identity.MintBiscuitToken(privKey, claims, token, pID, biscuitExpiry, finalRoles)
+ biscuitData, _, err := identity.MintBiscuitToken(privKey, claims, token, pID, biscuitExpiry, finalRoles, policyRoles)
if err != nil {
logger.Errorw("Biscuit minting failed", "peer_id", req.PeerId, "error", err)
http.Error(w, "Failed to mint biscuit: "+err.Error(), http.StatusForbidden)
@@ -587,7 +594,13 @@ func (s *Server) HandleRefresh(w http.ResponseWriter, r *http.Request) {
finalRoles := []string{nodeRecord.Role}
finalRoles = append(finalRoles, customAccessRoles...)
- bBytes, _, err := identity.MintBiscuitToken(privKey, claims, nil, pID, biscuitExpiry, finalRoles)
+ policyRoles, _, err := s.store.GetMeshPolicy(ctx)
+ if err != nil {
+ logger.Errorf("Failed to retrieve mesh policy for node %s: %v", nodeRecord.PeerID, err)
+ http.Error(w, "Internal server error", http.StatusInternalServerError)
+ return
+ }
+ bBytes, _, err := identity.MintBiscuitToken(privKey, claims, nil, pID, biscuitExpiry, finalRoles, policyRoles)
if err != nil {
logger.Errorf("Failed to mint refreshed token for node %s: %v", nodeRecord.PeerID, err)
http.Error(w, "Internal server error", http.StatusInternalServerError)
@@ -596,7 +609,13 @@ func (s *Server) HandleRefresh(w http.ResponseWriter, r *http.Request) {
biscuitBytes = bBytes
} else {
// Bootstrap node
- bBytes, err := identity.MintBootstrapBiscuitToken(privKey, pID, nodeRecord.Role, biscuitExpiry)
+ policyRoles, _, err := s.store.GetMeshPolicy(ctx)
+ if err != nil {
+ logger.Errorf("Failed to retrieve mesh policy for node %s: %v", nodeRecord.PeerID, err)
+ http.Error(w, "Internal server error", http.StatusInternalServerError)
+ return
+ }
+ bBytes, err := identity.MintBootstrapBiscuitToken(privKey, pID, nodeRecord.Role, biscuitExpiry, policyRoles)
if err != nil {
logger.Errorf("Failed to mint refreshed token for node %s: %v", nodeRecord.PeerID, err)
http.Error(w, "Internal server error", http.StatusInternalServerError)
@@ -1027,7 +1046,13 @@ func (s *Server) HandleEnroll(w http.ResponseWriter, r *http.Request) {
if s.config.AutoApproveEnrollment {
// Mode A: Auto-Approve
- biscuitBytes, err := identity.MintBootstrapBiscuitToken(privKey, pID, tokenRecord.Role, time.Now().Add(api.BiscuitTokenTTL))
+ policyRoles, _, err := s.store.GetMeshPolicy(ctx)
+ if err != nil {
+ logger.Errorf("Failed to retrieve mesh policy: %v", err)
+ http.Error(w, "Internal server error", http.StatusInternalServerError)
+ return
+ }
+ biscuitBytes, err := identity.MintBootstrapBiscuitToken(privKey, pID, tokenRecord.Role, time.Now().Add(api.BiscuitTokenTTL), policyRoles)
if err != nil {
logger.Errorf("Failed to mint bootstrap biscuit: %v", err)
http.Error(w, "Internal server error", http.StatusInternalServerError)
@@ -1369,7 +1394,13 @@ func (s *Server) HandleAdminEnrollmentAction(w http.ResponseWriter, r *http.Requ
return
}
- biscuitBytes, err := identity.MintBootstrapBiscuitToken(privKey, pID, tokenRecord.Role, time.Now().Add(api.BiscuitTokenTTL))
+ policyRoles, _, err := s.store.GetMeshPolicy(ctx)
+ if err != nil {
+ logger.Errorf("Failed to retrieve mesh policy: %v", err)
+ http.Error(w, "Internal server error", http.StatusInternalServerError)
+ return
+ }
+ biscuitBytes, err := identity.MintBootstrapBiscuitToken(privKey, pID, tokenRecord.Role, time.Now().Add(api.BiscuitTokenTTL), policyRoles)
if err != nil {
logger.Errorf("Failed to mint bootstrap biscuit: %v", err)
http.Error(w, "Internal server error", http.StatusInternalServerError)
diff --git a/internal/identity/biscuit.go b/internal/identity/biscuit.go
index e5254e99..9c46d4a7 100644
--- a/internal/identity/biscuit.go
+++ b/internal/identity/biscuit.go
@@ -19,6 +19,7 @@ import (
"errors"
"fmt"
"sort"
+ "strings"
"time"
"github.com/biscuit-auth/biscuit-go/v2"
@@ -31,35 +32,19 @@ import (
)
// MintBiscuitToken generates a signed Biscuit token for a peer with policy rules based on JWT claims.
-//
-// Role Authorization Rationale:
-// The system has two distinct kinds of roles:
-// 1. Capability Roles (prefixed with "sam:role:"): These authorize the client's binary startup role
-// (e.g., sam:role:node, sam:role:router, sam:role:sambox) under Zero Trust.
-// 2. Custom Access Roles (all other roles): These define authorization permissions for custom
-// services and targets (e.g., restricted-role).
-//
-// When enrolling:
-// - The client binary must explicitly request a single capability role (requestedRole).
-// - We verify if the client's OIDC identity is authorized to claim that requested capability role:
-// - If the user has explicitly mapped capability roles (from policy/claims), they must only request one of those.
-// - If the user has no capability roles mapped, they are allowed to request the standard fallback role ("sam:role:node").
-// - Once authorized, the generated Biscuit is minted with:
-// - The requested capability role (enforcing least privilege).
-// - All other custom access roles mapped to the identity (so they preserve their resource permissions).
-func MintBiscuitToken(signingKey ed25519.PrivateKey, claims jwt.MapClaims, token *oidc.IDToken, remotePeer peer.ID, biscuitExpiry time.Time, roles []string) ([]byte, []string, error) {
+func MintBiscuitToken(signingKey ed25519.PrivateKey, claims jwt.MapClaims, token *oidc.IDToken, remotePeer peer.ID, biscuitExpiry time.Time, roles []string, policyRoles []*api.PolicyRole) ([]byte, []string, error) {
if claims == nil {
return nil, nil, fmt.Errorf("claims cannot be nil")
}
- biscuitBytes, err := mintBiscuit(signingKey, remotePeer, roles, biscuitExpiry, claims)
+ biscuitBytes, err := mintBiscuit(signingKey, remotePeer, roles, biscuitExpiry, claims, policyRoles)
if err != nil {
return nil, nil, err
}
return biscuitBytes, roles, nil
}
-func mintBiscuit(signingKey ed25519.PrivateKey, remotePeer peer.ID, roles []string, expiration time.Time, claims jwt.MapClaims) ([]byte, error) {
+func mintBiscuit(signingKey ed25519.PrivateKey, remotePeer peer.ID, roles []string, expiration time.Time, claims jwt.MapClaims, policyRoles []*api.PolicyRole) ([]byte, error) {
builder := biscuit.NewBuilder(signingKey)
addedFacts := make(map[string]bool)
addFact := func(fact biscuit.Fact) error {
@@ -101,6 +86,15 @@ func mintBiscuit(signingKey ed25519.PrivateKey, remotePeer peer.ID, roles []stri
}
}
+ rolesMap := make(map[string]*api.PolicyRole)
+ for _, pr := range policyRoles {
+ if pr != nil {
+ rolesMap[pr.Name] = pr
+ }
+ }
+
+ hasTargets := false
+ hasServices := false
sort.Strings(roles)
var errs []error
for _, role := range roles {
@@ -125,8 +119,50 @@ func mintBiscuit(signingKey ed25519.PrivateKey, remotePeer peer.ID, roles []stri
}}); err != nil {
errs = append(errs, fmt.Errorf("failed to add target unrestricted: %w", err))
}
+ hasTargets = true
+ hasServices = true
continue
}
+
+ if pr, ok := rolesMap[role]; ok {
+ if len(pr.AllowedServices) > 0 {
+ hasServices = true
+ for _, svc := range pr.AllowedServices {
+ _ = addFact(api.BuildServiceDatalogFact(svc))
+ }
+ }
+
+ if len(pr.AllowedTargets) > 0 {
+ hasTargets = true
+ for _, target := range pr.AllowedTargets {
+ _ = addFact(api.BuildTargetDatalogFact(target))
+ }
+ }
+
+ for _, customFact := range pr.CustomDatalog {
+ trimmed := strings.TrimRight(strings.TrimSpace(customFact), ";")
+ if trimmed == "" {
+ continue
+ }
+ fact, err := parser.FromStringFact(trimmed)
+ if err == nil {
+ _ = addFact(fact)
+ }
+ }
+ }
+ }
+
+ if !hasServices && len(policyRoles) == 0 {
+ _ = addFact(biscuit.Fact{Predicate: biscuit.Predicate{
+ Name: api.FactGrantedServiceAllTypes,
+ IDs: []biscuit.Term{},
+ }})
+ }
+ if !hasTargets && len(policyRoles) == 0 {
+ _ = addFact(biscuit.Fact{Predicate: biscuit.Predicate{
+ Name: api.FactTargetUnrestricted,
+ IDs: []biscuit.Term{},
+ }})
}
if len(errs) > 0 {
@@ -280,8 +316,8 @@ func toStringSlice(val any) []string {
}
// MintBootstrapBiscuitToken generates a signed Biscuit token for a peer using a bootstrap role.
-func MintBootstrapBiscuitToken(signingKey ed25519.PrivateKey, remotePeer peer.ID, role string, expiration time.Time) ([]byte, error) {
- return mintBiscuit(signingKey, remotePeer, []string{role}, expiration, nil)
+func MintBootstrapBiscuitToken(signingKey ed25519.PrivateKey, remotePeer peer.ID, role string, expiration time.Time, policyRoles []*api.PolicyRole) ([]byte, error) {
+ return mintBiscuit(signingKey, remotePeer, []string{role}, expiration, nil, policyRoles)
}
// VerifyAndExtractPeerID checks that the biscuit is signed by one of the trusted keys and returns the peer ID.
diff --git a/internal/identity/biscuit_test.go b/internal/identity/biscuit_test.go
index c7917491..fa895ec2 100644
--- a/internal/identity/biscuit_test.go
+++ b/internal/identity/biscuit_test.go
@@ -25,6 +25,7 @@ import (
"github.com/biscuit-auth/biscuit-go/v2/datalog"
"github.com/coreos/go-oidc/v3/oidc"
"github.com/golang-jwt/jwt/v5"
+ "github.com/google/sam/api"
"github.com/libp2p/go-libp2p/core/crypto"
"github.com/libp2p/go-libp2p/core/peer"
)
@@ -70,7 +71,7 @@ func TestVerifyBiscuit_Expiration(t *testing.T) {
"roles": []any{"admin"},
}
- biscuitData, _, err := MintBiscuitToken(priv, claims, token, dummyPeer, token.Expiry, []string{"admin"})
+ biscuitData, _, err := MintBiscuitToken(priv, claims, token, dummyPeer, token.Expiry, []string{"admin"}, nil)
if err != nil {
t.Fatalf("MintBiscuitToken failed: %v", err)
}
@@ -111,7 +112,7 @@ func TestMintBiscuitToken_ClaimsTranslation(t *testing.T) {
"groups": []any{"beta-testers", "engineering"},
}
- biscuitData, _, err := MintBiscuitToken(priv, claims, token, dummyPeer, token.Expiry, nil)
+ biscuitData, _, err := MintBiscuitToken(priv, claims, token, dummyPeer, token.Expiry, nil, nil)
if err != nil {
t.Fatalf("Failed to mint biscuit: %v", err)
}
@@ -201,7 +202,7 @@ func TestVerifyBiscuit_Concurrent(t *testing.T) {
"roles": []any{"admin"},
}
- biscuitData, _, err := MintBiscuitToken(priv, claims, token, dummyPeer, token.Expiry, []string{"admin"})
+ biscuitData, _, err := MintBiscuitToken(priv, claims, token, dummyPeer, token.Expiry, []string{"admin"}, nil)
if err != nil {
t.Fatalf("MintBiscuitToken failed: %v", err)
}
@@ -249,7 +250,7 @@ func TestMintBiscuitToken(t *testing.T) {
"groups": []any{"group1", "group2"},
"roles": []any{"admin", "user"},
}
- biscuitData, _, err := MintBiscuitToken(priv, claims, token, dummyPeer, token.Expiry, []string{"admin", "user"})
+ biscuitData, _, err := MintBiscuitToken(priv, claims, token, dummyPeer, token.Expiry, []string{"admin", "user"}, nil)
if err != nil {
t.Fatal(err)
}
@@ -348,7 +349,7 @@ func TestMintBiscuitToken_VariousClaimsTypes(t *testing.T) {
claims["groups"] = tt.groupsClaim
}
- biscuitData, _, err := MintBiscuitToken(priv, claims, token, dummyPeer, token.Expiry, tt.expectedRoles)
+ biscuitData, _, err := MintBiscuitToken(priv, claims, token, dummyPeer, token.Expiry, tt.expectedRoles, nil)
if err != nil {
t.Fatalf("MintBiscuitToken failed: %v", err)
}
@@ -396,3 +397,89 @@ func TestMintBiscuitToken_VariousClaimsTypes(t *testing.T) {
})
}
}
+
+func TestMintBiscuitToken_WithPolicyRoles(t *testing.T) {
+ pub, priv, err := ed25519.GenerateKey(rand.Reader)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ privNode, _, err := crypto.GenerateKeyPair(crypto.Ed25519, -1)
+ if err != nil {
+ t.Fatal(err)
+ }
+ dummyPeer, err := peer.IDFromPrivateKey(privNode)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ token := &oidc.IDToken{
+ Expiry: time.Now().Add(1 * time.Hour),
+ }
+ claims := jwt.MapClaims{"sub": "alice"}
+
+ policyRoles := []*api.PolicyRole{
+ {
+ Name: "data-scientist",
+ AllowedServices: []string{"mcp://calculator"},
+ AllowedTargets: []string{"group:backend"},
+ CustomDatalog: []string{"right(\"data:read\");"},
+ },
+ }
+
+ t.Run("Mint with matching policy role", func(t *testing.T) {
+ biscuitData, _, err := MintBiscuitToken(priv, claims, token, dummyPeer, token.Expiry, []string{"data-scientist"}, policyRoles)
+ if err != nil {
+ t.Fatalf("MintBiscuitToken failed: %v", err)
+ }
+
+ b, err := biscuit.Unmarshal(biscuitData)
+ if err != nil {
+ t.Fatalf("Unmarshal biscuit failed: %v", err)
+ }
+
+ authorizer, err := b.Authorizer(pub)
+ if err != nil {
+ t.Fatalf("Authorizer failed: %v", err)
+ }
+
+ // Verify granted_service_exact, granted_target_exact, and custom datalog right fact
+ authorizer.AddCheck(biscuit.Check{Queries: []biscuit.Rule{
+ {Body: []biscuit.Predicate{{Name: api.FactGrantedServiceExact, IDs: []biscuit.Term{biscuit.String("mcp"), biscuit.String("calculator")}}}},
+ {Body: []biscuit.Predicate{{Name: api.FactGrantedTargetExact, IDs: []biscuit.Term{biscuit.String("group"), biscuit.String("backend")}}}},
+ {Body: []biscuit.Predicate{{Name: api.FactRight, IDs: []biscuit.Term{biscuit.String("data:read")}}}},
+ }})
+ authorizer.AddPolicy(api.AllowIfTruePolicy)
+
+ if err := authorizer.Authorize(); err != nil {
+ t.Errorf("Expected policy facts to be present in Biscuit, got error: %v\nWorld:\n%s", err, authorizer.PrintWorld())
+ }
+ })
+
+ t.Run("Mint with unmapped role when policy exists", func(t *testing.T) {
+ biscuitData, _, err := MintBiscuitToken(priv, claims, token, dummyPeer, token.Expiry, []string{"unmapped-role"}, policyRoles)
+ if err != nil {
+ t.Fatalf("MintBiscuitToken failed: %v", err)
+ }
+
+ b, err := biscuit.Unmarshal(biscuitData)
+ if err != nil {
+ t.Fatalf("Unmarshal biscuit failed: %v", err)
+ }
+
+ authorizer, err := b.Authorizer(pub)
+ if err != nil {
+ t.Fatalf("Authorizer failed: %v", err)
+ }
+
+ // Verify target_unrestricted and granted_service_all_types are NOT present
+ authorizer.AddCheck(biscuit.Check{Queries: []biscuit.Rule{
+ {Body: []biscuit.Predicate{{Name: api.FactTargetUnrestricted, IDs: []biscuit.Term{}}}},
+ }})
+ authorizer.AddPolicy(api.AllowIfTruePolicy)
+
+ if err := authorizer.Authorize(); err == nil {
+ t.Errorf("Expected target_unrestricted check to fail for unmapped role, but it succeeded\nWorld:\n%s", authorizer.PrintWorld())
+ }
+ })
+}