diff --git a/biscuit.go b/biscuit.go index 2f532e7..cd6cdfd 100644 --- a/biscuit.go +++ b/biscuit.go @@ -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