Struct biscuit_auth::Biscuit
source ·
[−]pub struct Biscuit { /* private fields */ }Expand description
This structure represents a valid Biscuit token
It contains multiple Block elements, the associated symbol table,
and a serialized version of this data
extern crate biscuit_auth as biscuit;
use biscuit::{KeyPair, Biscuit, builder::*};
fn main() {
let root = KeyPair::new();
// first we define the authority block for global data,
// like access rights
// data from the authority block cannot be created in any other block
let mut builder = Biscuit::builder(&root);
builder.add_authority_fact(fact("right", &[string("/a/file1.txt"), s("read")]));
// facts and rules can also be parsed from a string
builder.add_authority_fact("right(\"/a/file1.txt\", \"read\")").expect("parse error");
let token1 = builder.build().unwrap();
// we can create a new block builder from that token
let mut builder2 = token1.create_block();
builder2.check_operation("read");
let token2 = token1.append(builder2).unwrap();
}Implementations
create the first block’s builder
call builder::BiscuitBuilder::build to create the token
deserializes a token and validates the signature using the root public key
deserializes a token and validates the signature using the root public key
serializes the token and encode it to a (URL safe) base64 string
serializes the token
creates a sealed version of the token
sealed tokens cannot be attenuated
creates a authorizer from this token
creates a new block builder
adds a new block to the token
since the public key is integrated into the token, the keypair can be discarded right after calling this function
returns the list of context elements of each block
the context is a free form text field in which application specific data can be stored
returns a list of revocation identifiers for each block, in order
if a token is generated with the same keys and the same content, those identifiers will stay the same
prints the content of a block as Datalog source code
create the first block’s builder, sing a provided symbol table
deserializes a token and validates the signature using the root public key, with a custom symbol table
deserializes a token and validates the signature using the root public key, with a custom symbol table
returns the internal representation of the token
pub fn append_with_keypair(
&self,
keypair: &KeyPair,
block_builder: BlockBuilder
) -> Result<Self, Token>
pub fn append_with_keypair(
&self,
keypair: &KeyPair,
block_builder: BlockBuilder
) -> Result<Self, Token>
adds a new block to the token, using the provided CSPRNG
since the public key is integrated into the token, the keypair can be discarded right after calling this function
gets the list of symbols from a block
returns the number of blocks (at least 1)
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Biscuit
impl UnwindSafe for Biscuit
Blanket Implementations
Mutably borrows from an owned value. Read more
