Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Different functional behavior between the Rust library and the Go module #128

Open
euskadi31 opened this issue Oct 14, 2023 · 1 comment

Comments

@euskadi31
Copy link

Hi,

I wanted to retrieve the user id via a Query but it returned an empty slice.

Example:

Public Key iWlbYg08RKVFTobd/O5U9UOkgtc4vyp6I3eOXLRp7AE= // use base64.StdEncoding.DecodeString

Token: EnkKDxIAGAMiCQoHCAoSAxDRCRIkCAASIDw-FMjPGu38xq_hhpx7__ESWLn4TaPP25SiOIkK3AJAGkAmyrsV1iJn7x8fRBra2f9VPAtO1wuOQwlqU-GUivSNdLef8ksUUGTwKMeQXrZzOyWthKOodgCrSqAet9DimPYFIiIKIHekAqed-ehAMGbz1eXeul0J5j_CvnF7U-kw-Lwe_7o9 // use base64.URLEncoding.DecodeString

Biscuit Authority Block :

user(1233);

PoC:

authorizer, _ := b.Authorizer(ed25519.PublicKey(...))

rule, _ := parser.FromStringRule(`data($id) <- user($id)`)

facts, _ := authorizer.Query(rule)

spew.Dump(facts)

Current

(biscuit.FactSet) []

Expected:

(biscuit.FactSet) (len=1 cap=1) [
	data(1233)
]

Problem:

In Go the world is build in func (v *authorizer) Authorize() error see:

func (v *authorizer) Authorize() error {

In Rust the world is build in pub fn authorizer(&self) -> Result<Authorizer, error::Token> see: https://github.com/biscuit-auth/biscuit-rust/blob/132b0c9ddc02d2266ab9e06b3a0ef6808fe040f7/biscuit-auth/src/token/authorizer.rs#L150

Thx @Akanoa for help !

@divarvel
Copy link
Contributor

Hi, thanks for the report! So currently the workaround would be to create an authorizer and call authorize before querying it.

I think that the go library could benefit from an API overhaul anyway, to make it consistent with other libraries. The issues you mentioned would be in the list of needed improvements.

I have limited time and go knowledge to handle it myself, but i would be happy providing guidance to anyone willing to carry this project out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants