benchling_sdk.apps.helpers.webhook_helpers module¶

class GetJwksFunction¶

Bases: Protocol

Function for custom resolution of JWKs for an app definition.

__init__(*args, **kwargs)¶
class JwkUrlProvider¶

Bases: Protocol

Function for custom URL for resolving JWKs by app definition id.

Should generally never be used except in the event of specialized testing with internal Benchling.

__init__(*args, **kwargs)¶
class LegacyGetJwksFunction¶

Bases: Protocol

Function for custom resolution of JWKs for an app.

__init__(*args, **kwargs)¶
class LegacyJwkUrlProvider¶

Bases: Protocol

Function for custom URL for resolving JWKs by app.

Should generally never be used except in the event of specialized testing with internal Benchling.

__init__(*args, **kwargs)¶
exception WebhookVerificationError¶

Bases: Exception

Webhook Verification Error.

Indicates a webhook from Benchling could not be verified.

Some reasons this could happen include: - An app developer misconfiguration (e.g., wrong app) - A webhook was received too late - The webhook did not originate from Benchling (possible attack vector)

jwks_by_app(app_id: str, httpx_client: Optional[httpx.Client] = None, jwk_url_provider: Optional[LegacyJwkUrlProvider] = None) → jwcrypto.jwk.JWKSet¶

Get JWKs by App (Deprecated).

Please migrate to jwks_by_app_definition, which uses an app’s global app_definition_id.

Retrieves a set of JWKs assigned to an app used to verify webhooks.

JWKs generally should not be resolved on their own. We recommend using webhook verification functions such as verify_app_installation().

This method is provided for specialized cases such as customizing the httpx client.

jwks_by_app_definition(app_definition_id: str, httpx_client: Optional[httpx.Client] = None, jwk_url_provider: Optional[JwkUrlProvider] = None) → jwcrypto.jwk.JWKSet¶

Get JWKs for a Benchling App from its global app_definition_id.

Retrieves a set of JWKs assigned to an app definition used to verify webhooks.

JWKs generally should not be resolved on their own. We recommend using webhook verification functions such as verify().

This method is provided for specialized cases such as customizing the httpx client.

verify(app_definition_id: str, data: str, headers: dict, jwk_function: Optional[GetJwksFunction] = None) → None¶

Verify a webhook for a Benchling App from its global app_definition_id.

Verifies that a webhook was a valid webhook from Benchling. Raises WebhookVerificationError if the webhook could not be verified. Resolves JWKs from Benchling with default settings. Pass jwk_function for customization.

verify_app_installation(app_id: str, data: str, headers: dict, jwk_function: Optional[LegacyGetJwksFunction] = None) → None¶

Verify a webhook for an app installation (Deprecated).

Please migrate to verify, which uses an app’s global app_definition_id.

Verifies that a webhook was a valid webhook from Benchling. Raises WebhookVerificationError if the webhook could not be verified. Resolves JWKs from Benchling with default settings. Pass jwk_function for customization.