Skip to content
Open
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
31 changes: 31 additions & 0 deletions biscuit.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,37 @@ func (b *Biscuit) Seal(rng io.Reader) (*Biscuit, error) {
}, nil
}

func (b *Biscuit) Lookup(factName string) []string {
symbols := b.symbols.Clone()
datalogFactName := symbols.Sym(factName)

if b.authority.facts == nil {
return nil
}

for _, f := range *b.authority.facts {
if f.Name != datalogFactName {
continue
}

terms := make([]string, len(f.Terms))
for i, term := range f.Terms {
switch t := term.(type) {
case datalog.String:
terms[i] = symbols.Str(t)
case datalog.Variable:
terms[i] = symbols.Var(t)
default:
terms[i] = t.String()
}
}

return terms
}

return nil
}

type (
// A PublickKeyByIDProjection inspects an optional ID for a public key and returns the
// corresponding public key, if any. If it doesn't recognize the ID or can't find the public
Expand Down