Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
254 changes: 215 additions & 39 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ name = "biscuit_auth"
crate-type = ["cdylib"]

[dependencies]
biscuit-auth = { version = "5.0.0", features = ["pem"] }
biscuit-auth = { version = "6.0.0-beta.3", features = ["pem"] }
pyo3 = { version = "0.22.6", features = ["extension-module", "chrono"] }
hex = "0.4"
base64 = "0.13.0"
Expand Down
56 changes: 39 additions & 17 deletions biscuit_auth.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ PublicKeyProvider: TypeAlias = Union[
Callable[[], PublicKey], Callable[[int], PublicKey]
]

class Algorithm:
pass

class BiscuitBuilder:
# Create a builder from a datalog snippet and optional parameter values
#
Expand Down Expand Up @@ -179,7 +182,7 @@ class Biscuit:
@property
def revocation_ids(self) -> List[str]: ...

class Authorizer:
class AuthorizerBuilder:
# Create a new authorizer from a datalog snippet and optional parameter values
#
# :param source: a datalog snippet
Expand All @@ -193,7 +196,7 @@ class Authorizer:
source: Optional[str] = None,
parameters: Parameters = None,
scope_parameters: ScopeParameters = None,
) -> Authorizer: ...
) -> AuthorizerBuilder: ...

# Add code to the builder, using the provided parameters.
#
Expand Down Expand Up @@ -250,12 +253,43 @@ class Authorizer:
# :type builder: BlockBuilder
def merge_block(self, builder: BlockBuilder) -> None: ...

# Take a snapshot of the authorizer builder and return it, base64-encoded
#
# :return: a snapshot as a base64-encoded string
# :rtype: str
def base64_snapshot(self) -> str: ...

# Take a snapshot of the authorizer builder and return it, as raw bytes
#
# :return: a snapshot as raw bytes
# :rtype: bytes
def raw_snapshot(self) -> bytes: ...

# Build an authorizer builder from a base64-encoded snapshot
#
# :param input: base64-encoded snapshot
# :type input: str
# :return: the authorizer builder
# :rtype: AuthorizerBuilder
@classmethod
def from_base64_snapshot(cls, input: str) -> AuthorizerBuilder: ...

# Build an authorizer builder from a snapshot's raw bytes
#
# :param input: raw snapshot bytes
# :type input: bytes
# :return: the authorizer builder
# :rtype: AuthorizerBuilder
@classmethod
def from_raw_snapshot(cls, input: bytes) -> AuthorizerBuilder: ...

# Add a `Biscuit` to this `Authorizer`
#
# :param token: the token to authorize
# :type token: Biscuit
def add_token(self, token: Biscuit) -> None: ...
def build(self, token: Biscuit) -> Authorizer: ...

class Authorizer:
# Runs the authorization checks and policies
#
# Returns the index of the matching allow policy, or an error containing the matching deny
Expand Down Expand Up @@ -405,12 +439,6 @@ class PublicKey:
# :rtype: list
def to_bytes(self) -> bytes: ...

# Serializes a public key to a hexadecimal string
#
# :return: the public key bytes (hex-encoded)
# :rtype: str
def to_hex(self) -> str: ...

# Deserializes a public key from raw bytes
#
# :param data: the raw bytes
Expand All @@ -427,7 +455,7 @@ class PublicKey:
# :return: the public key
# :rtype: PublicKey
@classmethod
def from_hex(cls, data: str) -> PublicKey: ...
def __new__(cls, data: str) -> PublicKey: ...

# ed25519 private key
class PrivateKey:
Expand All @@ -437,12 +465,6 @@ class PrivateKey:
# :rtype: list
def to_bytes(self) -> bytes: ...

# Serializes a private key to a hexadecimal string
#
# :return: the private key bytes (hex-encoded)
# :rtype: str
def to_hex(self) -> str: ...

# Deserializes a private key from raw bytes
#
# :param data: the raw bytes
Expand All @@ -459,7 +481,7 @@ class PrivateKey:
# :return: the private key
# :rtype: PrivateKey
@classmethod
def from_hex(cls, data: str) -> PrivateKey: ...
def __new__(cls, data: str) -> PrivateKey: ...

# A single datalog Fact
#
Expand Down
Loading