Skip to content

feat: add @x402_required decorator for FastAPI and Flask - #22

Open
zhuyh1606-oss wants to merge 1 commit into
nirium-protocol:mainfrom
zhuyh1606-oss:feat/x402-fastapi-decorator
Open

feat: add @x402_required decorator for FastAPI and Flask#22
zhuyh1606-oss wants to merge 1 commit into
nirium-protocol:mainfrom
zhuyh1606-oss:feat/x402-fastapi-decorator

Conversation

@zhuyh1606-oss

Copy link
Copy Markdown

Summary

Adds a framework-agnostic @x402_required\ decorator that works with both FastAPI and Flask.

Changes

  • \x402_required.py: Decorator that enforces x402 micropayment before accessing an endpoint
    • Compatible with FastAPI & Flask
    • Inspects \X-PAYMENT\ header and validates Stellar USDC payment proofs
    • Returns clean 402 Payment Required with x402 payment requirements
  • \ est_x402_required.py: Unit tests for header validation and integration tests for both frameworks

Acceptance Criteria

  • Compatible with FastAPI & Flask
  • Inspects \X-402-Signature\ header (also supports \X-PAYMENT)
  • Validates settlement via Stellar transaction verification
  • Returns clean 402 HTTP status codes with payment requirements

Addresses #10

- Framework-agnostic decorator that works with both FastAPI and Flask
- Inspects X-PAYMENT header and validates Stellar USDC payment proofs
- Returns clean 402 Payment Required with x402 payment requirements
- Includes unit tests for header validation and integration tests for both frameworks
- Addresses nirium-protocol#10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant