FastAPI/BotProtection.pm

filter: Statementstmt 87.5% 14 / 16 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 60.0% 3 / 5 Podpod 0.0% 0 / 2 totaltotal 73.9% 17 / 23 CC 1 SCAR 3.4
CC
1
Cov
88%
create_challenge
2.0
verify
2.0
BEGIN
1.0
CRAP 1.4
« FastAPI/RateLimit/Driver.pm ↑ Summary FastAPI/Queue/Driver.pm »
1 package PAGI::FastAPI::BotProtection;
2  
3 1 ▶use v5.38;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use experimental 'class';
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use version;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 our $VERSION = qv('v1.7.3');
8 1 our $AUTHORITY = 'cpan:MANWAR';
9  
10 1 class PAGI::FastAPI::BotProtection {
11 0 ▶ method create_challenge ($client_ip) {
Subroutine create_challenge: not called CC=1 SCAR=6.9
Pod undocumented
12 0 die "create_challenge() must be implemented by subclass";
13 1 }
14  
15 0 ▶ method verify ($challenge_str, $nonce, $client_ip) {
Subroutine verify: not called CC=1 SCAR=6.9
Pod undocumented
16 0 die "verify() must be implemented by subclass";
17 1 }
18 }
19  
20 =encoding utf-8
21  
22 =head1 NAME
23  
24 PAGI::FastAPI::BotProtection - Base Interface for PAGI::FastAPI Bot Protection
25  
26 =head1 VERSION
27  
28 Version v1.7.3
29  
30 =head1 SYNOPSIS
31  
32 use PAGI::FastAPI;
33  
34 my $app = PAGI::FastAPI->new();
35  
36 # Enables default Proof-of-Work bot mitigation
37 $app->add_bot_protection(
38 difficulty => 3,
39 secret => $ENV{BOT_PROTECTION_SECRET},
40 );
41  
42 =head1 DESCRIPTION
43  
44 C<PAGI::FastAPI::BotProtection> serves as the base interface for bot
45 mitigation mechanisms in L<PAGI::FastAPI>.
46  
47 By default, the framework utilises L<PAGI::FastAPI::BotProtection::ProofOfWork>
48 to issue stateless cryptographic challenges to unverified clients, shielding
49 API routes from scrapers, credential stuffers, and automated flood bots.
50  
51 =head1 SUBCLASSES
52  
53 =over 4
54  
55 =item * L<PAGI::FastAPI::BotProtection::ProofOfWork>
56  
57 Default stateless SHA-256 HMAC Proof-of-Work challenge engine.
58  
59 =back
60  
61 =head1 SEE ALSO
62  
63 L<PAGI::FastAPI::Middleware::BotProtection>, L<PAGI::FastAPI::BotProtection::ProofOfWork>, L<PAGI::FastAPI>
64  
65 =head1 AUTHOR
66  
67 Mohammad Sajid Anwar, C<< <mohammad.anwar at yahoo.com> >>
68  
69 =head1 BUGS
70  
71 Please report any bugs or feature requests through the web interface at L<https://github.com/manwar/PAGI-FastAPI/issues>.
72 I will be notified and then you'll automatically be notified of progress on your
73 bug as I make changes.
74  
75 =head1 SUPPORT
76  
77 You can find documentation for this module with the perldoc command.
78  
79 perldoc PAGI::FastAPI::BotProtection
80  
81 You can also look for information at:
82  
83 =over 4
84  
85 =item * BUG Report
86  
87 L<https://github.com/manwar/PAGI-FastAPI/issues>
88  
89 =item * Search MetaCPAN
90  
91 L<https://metacpan.org/dist/PAGI-FastAPI/>
92  
93 =back
94  
95 =head1 LICENSE AND COPYRIGHT
96  
97 Copyright (C) 2026 Mohammad Sajid Anwar.
98  
99 This program is free software; you can redistribute it and/or modify it under
100 the terms of the Artistic License (2.0).
101  
102 =cut
103  
104 1 1; # End of PAGI::FastAPI::BotProtection
« FastAPI/RateLimit/Driver.pm ↑ Summary FastAPI/Queue/Driver.pm »