Comments (4)
I've also discovered in the meantime that querying is only possible for tuples out of the box, and if you'd expect a singular string, you have to use (String, )
, so I can also try to add TryFrom<Fact>
for some commonly used "base" types
from biscuit-rust.
After a bit of investigating it seems to be that when the authorizer is constructed from the token, it doesn't populate the world with the information from the token, which it seems that it should do that?
pub(crate) fn from_token(token: &'t Biscuit) -> Result<Self, error::Token> {
let mut v = Authorizer::new()?;
v.token = Some(token);
Ok(v)
}
Or the querying must be extended in the same way that authorize_with_limits
extends the world with information from the token if it's present:
if let Some(token) = self.token.as_ref() {
for fact in token.authority.facts.iter().cloned() {
let fact = Fact::convert_from(&fact, &token.symbols).convert(&mut self.symbols);
self.world.facts.insert(fact);
}
let mut revocation_ids = token.revocation_identifiers();
let revocation_id_sym = self.symbols.get("revocation_id").unwrap();
for (i, id) in revocation_ids.drain(..).enumerate() {
self.world.facts.insert(datalog::Fact::new(
revocation_id_sym,
&[datalog::Term::Integer(i as i64), datalog::Term::Bytes(id)],
));
}
for rule in token.authority.rules.iter().cloned() {
let r = Rule::convert_from(&rule, &token.symbols);
let rule = r.convert(&mut self.symbols);
if let Err(_message) = r.validate_variables() {
return Err(
error::Logic::InvalidBlockRule(0, token.symbols.print_rule(&rule)).into(),
);
}
}
}
however re-adding information to the world each time one of these functions is called seems off, so I think the best way forward would be to extract the above snippet into the functions that set the token, to ensure the world is populated once.
If you agree I'll create a PR for this approach.
from biscuit-rust.
Did this ever go anywhere? I'm having a similar issue of pulling data from a Biscuit. It'd be great to have easy access to user/expiration facts inside the token.
from biscuit-rust.
@johnhainline , the issues I had were resolved in #52
from biscuit-rust.
Related Issues (20)
- Parsing chained method calls HOT 1
- Datalog boolean expression == does not evaluate properly HOT 3
- CLI long execution time HOT 3
- boolean logic should be lazy
- samples validation failure HOT 3
- Make biscuit-auth token::RootKeyProviter public HOT 3
- use separate version git tags for the different crates
- Detect free variables in expressions
- `RUSTSEC-2022-0093` security advisory
- Support heterogeneous sets
- `query_exactly_one()`
- Can't query facts added with authorizer_merge! HOT 2
- Non-deterministic output of `Authorizer.dump_code()` HOT 1
- Hidden state in `Authorizer` HOT 1
- Merging block builders with scope annotations
- Consider adding `impl TryFrom<Fact> for String` HOT 1
- Create new release HOT 1
- Proposal: Use padding free Base64 encoding/decoding HOT 4
- Proposal: add generic interface for external key registries HOT 2
- Cleanup free variables detection HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from biscuit-rust.