-
Notifications
You must be signed in to change notification settings - Fork 27
Description
Hi,
We're in charge of taking over a component that generates and consumes biscuits.
The component is developed in Java and we want to rewrite it in Go.
I wanted to retrieve a fact from a unmarshalled biscuit.
Example in Java of retrieving the facts (here, the first one)
biscuit.context().stream().filter(Option::isDefined).map(Option::get).findFirst()
.orElseThrow(() -> forbidden());And the biscuit
user(1233);
In Go, we have no function that allows us to get the facts of a biscuit...
I suppose it could be done by performing Query on the World structure, and the Biscuit structure has a generateWorld method that can create this needed World, but it is private and only used by the tests...
func (b *Biscuit) generateWorld(symbols *datalog.SymbolTable) (*datalog.World, error) {
world := datalog.NewWorld()
for _, fact := range *b.authority.facts {
world.AddFact(fact)
}
for _, rule := range b.authority.rules {
world.AddRule(rule)
}
for _, block := range b.blocks {
for _, fact := range *block.facts {
world.AddFact(fact)
}
for _, rule := range block.rules {
world.AddRule(rule)
}
}
if err := world.Run(symbols); err != nil {
return nil, err
}
return world, nil
}Is this a bug ?
Shouldn't it be available for consumption ?
If not, how can I retrieve the facts of an unmarshalled biscuit properly ? (no regex and other ugly stuff like that)
Thank you very much