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

Add SetContext on Builder interface and GetContext on Biscuit struct. #153

Merged
merged 1 commit into from
Jan 9, 2025

Conversation

Benoit12345
Copy link
Contributor

To be able to set a context and retrieve it form a biscuit.

@seh
Copy link
Contributor

seh commented Dec 5, 2024

What is a "context" in this context?

@Benoit12345
Copy link
Contributor Author

Benoit12345 commented Dec 6, 2024

"context" is the second field of the block liked it is indicated into the spec:

message Block {
  repeated string symbols = 1;
  optional string context = 2;
  optional uint32 version = 3;
  repeated FactV2 facts_v2 = 4;
  repeated RuleV2 rules_v2 = 5;
  repeated CheckV2 checks_v2 = 6;
  repeated Scope scope = 7;
  repeated PublicKey publicKeys = 8;
}

And the goal is to be able to be equivalent to the java biscuit library (https://github.com/biscuit-auth/biscuit-java/blob/a863cd8c0bd45ad1e36390ce777741e49417da0e/src/main/java/org/biscuitsec/biscuit/token/builder/Biscuit.java#L119)

if you're question is "are you talking about a Go std context ?", the answer is no but the context from biscuit specification.

@seh
Copy link
Contributor

seh commented Dec 6, 2024

"context" is the second field of the block liked it is indicated into the spec:

I did see that field in the IDL before asking the question here, but I'm wondering what a typical value would be for such a "context", who sets it, who consumes it, and why.

@divarvel
Copy link
Contributor

divarvel commented Dec 6, 2024

"context" is the second field of the block liked it is indicated into the spec:

I did see that field in the IDL before asking the question here, but I'm wondering what a typical value would be for such a "context", who sets it, who consumes it, and why.

It is intended as a way to embed a payload outside datalog. so something freeform that would not be directly used in the authorization context. It’s a remnant of early biscuit days, meant as some kind of escape hatch.

@seh
Copy link
Contributor

seh commented Dec 17, 2024

It’s a remnant of early biscuit days, meant as some kind of escape hatch.

It sounds like something we'd like to get rid of, but can't now, because the libraries for other languages allow writing to and reading from this Protocol Buffer message field. This patch makes it more likely that we'll preserve this field for a long while.

@Benoit12345
Copy link
Contributor Author

Benoit12345 commented Dec 18, 2024

Hello @seh,
Thank you for your feedback.
That may be so. But if you want to break the backwards compatibility, you need to do it in a major release. This fix can be applied to a minor version and allow compatibility with older/current versions in other languages (which is not the case at the moment).

@tnerolftnerolf
Copy link

Hello @seh,
Our issue is that we need to implement in Go something compatible with an existing Java application that currently uses this field , and which we can't change this "legacy" java app..
The biscuits tokens generated by our Go code currently fail to be validated by the existing Java application.
We really would like to avoid to fork your repo if we can avoid it - but we're currently blocked on both sides.

@seh
Copy link
Contributor

seh commented Jan 6, 2025

We really would like to avoid to fork your repo if we can avoid it - but we're currently blocked on both sides.

Thank you for the explanation, but as much as I'd like to help, I'm not your intended audience, as I'm merely a contributor here for now, and not a maintainer. I don't have any authority to approve proposed changes within this repository.

I expect that you'll need to appeal to @divarvel, who has been handling reviews at least since I started proposing changes here.

@tnerolftnerolf
Copy link

Thanks @seh . @divarvel can you please provide your feedback ?

@divarvel
Copy link
Contributor

divarvel commented Jan 9, 2025

I think that for consistency, reading the context of not just the authority block would be good as well, but definitely not a blocker, given how little context is used in practice

@divarvel divarvel merged commit e51c1c2 into biscuit-auth:main Jan 9, 2025
3 checks passed
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

Successfully merging this pull request may close these issues.

4 participants