Skip to main content
Attesta’s challenge system is pluggable. While the built-in challenges (Confirm, Quiz, Teach-Back, Multi-Party) cover common scenarios, you can build custom challenges for specialized verification workflows — TOTP/2FA, manager escalation, biometric confirmation, or domain-specific knowledge checks. This guide covers implementing the ChallengeProtocol, wiring custom challenges into the challenge map, and testing them.

The ChallengeProtocol

Every challenge must implement two members:
The present() method must be async. Even if your challenge implementation is synchronous, declare it as async def or the protocol check will fail.

Example: TOTP/2FA Challenge

A time-based one-time password challenge that requires the operator to enter a code from their authenticator app.
1

Install Dependencies

2

Implement the Challenge

3

Wire It Into the Challenge Map

Custom challenges integrate with Attesta through the renderer. The simplest approach is to create a renderer that delegates to your challenge:

Example: Manager Approval Challenge

A challenge that escalates the approval to a designated manager via an external notification system.

Example: Domain Knowledge Challenge

A challenge that asks domain-specific questions using templates from a DomainProfile.

Adding Custom Challenges to the Challenge Map

The challenge map in Attesta maps RiskLevel to ChallengeType. Since custom challenges implement the protocol and are presented through the renderer, the integration point is the renderer:
Override specific challenge types in a custom renderer:

Testing Custom Challenges


Best Practices

Always Return ChallengeResult

Never raise exceptions from present(). Return ChallengeResult(passed=False, ...) with a descriptive details dict on failure.

Enforce Timeouts

Every challenge that waits for external input should have a configurable timeout that defaults to denial.

Record Metadata

Use the details dict on ChallengeResult to record verification method, attempt counts, responder identity, and failure reasons for the audit trail.

Prevent Self-Approval

For multi-party or escalation challenges, verify that the responder is not the same entity that initiated the action.

Challenge System

How Attesta selects and presents challenges

Protocols

Full ChallengeProtocol specification