benchling_sdk.apps.helpers.webhook_helpers module¶
- class GetJwksFunction¶
Bases:
Protocol
Function for custom resolution of JWKs for an app.
- __init__(*args, **kwargs)¶
- class JwkUrlProvider¶
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[JwkUrlProvider] = None) jwcrypto.jwk.JWKSet ¶
Get JWKs by App.
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.
- verify_app_installation(app_id: str, data: str, headers: dict, jwk_function: Optional[GetJwksFunction] = None) None ¶
Verify a webhook for an app installation.
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.
This method will eventually be replaced with verify(app_definition_id) once Benchling Apps are migrated to global.