Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
499 commits
Select commit Hold shift + click to select a range
5c2d81c
chore: upgrade composer lock
TorstenDittmann Apr 27, 2023
49a180c
Merge pull request #48 from utopia-php/chore-upgrade-database
TorstenDittmann Apr 27, 2023
69432e4
Doc: Wrong comparison
May 25, 2023
56c3b3a
Update database
abnegate Jun 15, 2023
fb73180
Merge pull request #55 from utopia-php/chore-update-database
abnegate Jun 15, 2023
b06249d
Bump database version
stnguyen90 Jul 14, 2023
d141307
Fix codeql issues
stnguyen90 Jul 14, 2023
d1115f5
Merge pull request #56 from utopia-php/chore-bump-database
eldadfux Jul 15, 2023
c0553b8
bump update database
fanatic75 Jul 26, 2023
dcab1cb
updates composer lock file
fanatic75 Jul 26, 2023
256584e
Merge pull request #57 from utopia-php/chore-upgrade-database
christyjacob4 Jul 27, 2023
f707cbc
Merge pull request #52 from milanobrtlik/doc-readme-check-is-wrong
eldadfux Jul 31, 2023
979d389
bump db upgrade version
fanatic75 Aug 3, 2023
7589d0c
Merge pull request #58 from utopia-php/chore-upgrade-database
lohanidamodar Aug 3, 2023
3bca9cb
bump db version
fanatic75 Aug 9, 2023
9ba1b9c
Merge pull request #59 from utopia-php/chore-upgrade-database
christyjacob4 Aug 9, 2023
af09e89
Update database
abnegate Aug 10, 2023
d771c2c
Merge pull request #60 from utopia-php/chore-update-database
abnegate Aug 11, 2023
9eb3ff2
Upgrade DB version
Meldiron Aug 29, 2023
b2ad372
Merge pull request #61 from utopia-php/feat-upgrade-db-lib2
eldadfux Aug 29, 2023
8efe079
Update database
abnegate Oct 17, 2023
5b51084
chore bump db update
Oct 18, 2023
9717ffb
Merge pull request #64 from utopia-php/bump_db_update
abnegate Oct 18, 2023
d57fe4b
Merge remote-tracking branch 'origin/master' into chore-update-database
abnegate Nov 1, 2023
0c50745
Update database
abnegate Nov 1, 2023
1ba8d5f
Merge pull request #65 from utopia-php/chore-update-database
abnegate Nov 1, 2023
171eda0
Ignore duplicate collection for shared table isolation modes
abnegate Nov 22, 2023
2c54030
Update database
abnegate Dec 8, 2023
49f84ab
Merge pull request #66 from utopia-php/feat-isolation-modes
eldadfux Dec 8, 2023
0240ee8
Update database
abnegate Dec 14, 2023
8e5a80b
Merge pull request #67 from utopia-php/chore-update-database
abnegate Dec 14, 2023
db5f936
Update database
abnegate Jan 19, 2024
d3d09b4
Merge pull request #68 from utopia-php/chore-update-database
abnegate Jan 19, 2024
5032d52
Upgrade DB lib
Meldiron Mar 5, 2024
02a0911
Update lockfile
Meldiron Mar 6, 2024
2de5c12
Merge pull request #69 from utopia-php/feat-database-proxy
abnegate Mar 6, 2024
55b34b5
Introduce auth instance
Meldiron Mar 8, 2024
6f44bd8
abuse adapter using redis
lohanidamodar Mar 12, 2024
126cadf
fix cleanup
lohanidamodar Mar 12, 2024
ed30e8a
fix format
lohanidamodar Mar 12, 2024
9bfe913
fix code analysis errors
lohanidamodar Mar 12, 2024
fdb39d5
refactor and tests
lohanidamodar Mar 13, 2024
304c4d5
support multiple php version for test
lohanidamodar Mar 24, 2024
c167c67
fix script
lohanidamodar Mar 24, 2024
2a1e279
give default value for local test
lohanidamodar Mar 24, 2024
05b2059
Merge pull request #71 from utopia-php/feat-test-multiple-php-version
eldadfux Apr 1, 2024
b6b5a41
Merge remote-tracking branch 'origin/main' into feat-redis-adapter
lohanidamodar Apr 7, 2024
34177da
refactor adapter
lohanidamodar Apr 10, 2024
5cc6a70
fix
lohanidamodar Apr 10, 2024
b015f9c
fix dockerfile
lohanidamodar Apr 10, 2024
d9b9957
add phpbench
lohanidamodar Apr 10, 2024
6cd9a15
basic benchmark
lohanidamodar Apr 10, 2024
71c93e1
fix format
lohanidamodar Apr 10, 2024
f60b259
benchmark
lohanidamodar Apr 10, 2024
4eb7fc5
aggregate
lohanidamodar Apr 10, 2024
36113ab
composer.lock
fogelito Apr 17, 2024
46f3177
composer.lock
fogelito Apr 17, 2024
88f74c0
auth test
fogelito Apr 17, 2024
7cd611b
Question
fogelito Apr 17, 2024
a58454e
Add objects
fogelito Apr 17, 2024
db3dbb5
Question
fogelito Apr 17, 2024
70a3a0a
Use db auth
fogelito Apr 18, 2024
56e6723
setAuthorization
fogelito Apr 18, 2024
fffd9c0
remove setAuthorization
fogelito Apr 18, 2024
a2292d7
Formatting
fogelito Apr 18, 2024
1d40508
benchmark workflow
lohanidamodar May 13, 2024
06d6518
fix codeql errors
lohanidamodar May 13, 2024
a9495d2
benchmark
lohanidamodar May 13, 2024
ea1392d
change separator
lohanidamodar May 19, 2024
bb957a6
Update Dockerfile.php-8.1
lohanidamodar May 21, 2024
35ee385
Update Dockerfile.php-8.2
lohanidamodar May 21, 2024
684c3cd
Update Dockerfile.php-8.3
lohanidamodar May 21, 2024
59c64af
Merge pull request #73 from utopia-php/feat-use-utopia-base-for-tests
eldadfux May 21, 2024
5251153
version change
shimonewman Jun 5, 2024
4dfcff4
Merge pull request #75 from utopia-php/database-lib-ver
christyjacob4 Jun 5, 2024
9f43c3c
chore: bump utopia-php/database version
stnguyen90 Jun 21, 2024
b7be908
Merge pull request #76 from utopia-php/chore-bump-database
abnegate Jun 24, 2024
2bd2a7a
Merge remote-tracking branch 'origin/main' into feat-redis-adapter
lohanidamodar Jun 30, 2024
0116fba
fix codeql
lohanidamodar Jun 30, 2024
21a14d4
fix dockerfile
lohanidamodar Jun 30, 2024
55e184d
Merge pull request #70 from utopia-php/feat-redis-adapter
eldadfux Jul 7, 2024
deccfc6
Merge branch 'refs/heads/main' into feat-framework-v2
byawitz Jul 19, 2024
b3105b3
chore: merge
byawitz Jul 19, 2024
4f49bbb
chore: updating to latest database
byawitz Aug 7, 2024
7ff88da
chore: updating to the latest database
byawitz Aug 9, 2024
42db504
Update database
abnegate Aug 16, 2024
69748a6
Merge pull request #77 from utopia-php/chore-update-database
abnegate Aug 16, 2024
d303673
Update namespaces to better reflect adapters
abnegate Aug 19, 2024
961019a
Merge pull request #78 from utopia-php/refactor-namespaces
abnegate Aug 19, 2024
25f0683
Update database
abnegate Aug 21, 2024
08cf17e
Merge pull request #79 from utopia-php/chore-update-database
abnegate Aug 21, 2024
2a94103
Chore: Update Database Lib
PineappleIOnic Aug 30, 2024
6346a3b
Merge pull request #80 from utopia-php/chore-update-database
abnegate Aug 30, 2024
90b5d98
Merge branch 'main' into feat-framework-v2
byawitz Sep 4, 2024
0059ae5
chore: merge, lint
byawitz Sep 4, 2024
4008035
chore: updating to latest database
byawitz Sep 5, 2024
6f0a7dc
chore: changing to stable
byawitz Sep 5, 2024
cd37bba
Merge pull request #72 from utopia-php/feat-framework-v2
christyjacob4 Sep 5, 2024
1c7d468
Chore: findOne now returns empty documents instead of false on miss
PineappleIOnic Sep 17, 2024
4198352
Chore: Update Database Library
PineappleIOnic Sep 18, 2024
9e5edb3
Merge pull request #81 from utopia-php/chore-findones-empties
stnguyen90 Sep 18, 2024
b76dd68
chore: update db library
christyjacob4 Oct 7, 2024
ab09ecf
Merge pull request #82 from utopia-php/chore-update-db-library
christyjacob4 Oct 7, 2024
e404c21
Expose attributes and indexes
abnegate Oct 23, 2024
27cd99b
Chore: findOne now returns empty documents instead of false on miss
PineappleIOnic Sep 17, 2024
8aec34d
Update dependencies
Meldiron Dec 12, 2024
374536b
Merge pull request #84 from utopia-php/fix-document-check
Meldiron Dec 12, 2024
572c416
feat: add support for redis cluster
christyjacob4 Dec 17, 2024
3b78c86
feat: cleanup
christyjacob4 Dec 17, 2024
9b338b6
feat: cleanup
christyjacob4 Dec 17, 2024
1dfcdac
feat: cleanup
christyjacob4 Dec 17, 2024
aa15eda
feat: cleanup
christyjacob4 Dec 17, 2024
76fc3da
fix: codeql
christyjacob4 Dec 18, 2024
2663547
fix: tests
christyjacob4 Dec 18, 2024
627d1ba
fix: tests
christyjacob4 Dec 18, 2024
b3e9735
Revert "chore: update db library"
christyjacob4 Dec 18, 2024
57ab7a7
Merge pull request #87 from utopia-php/revert-82-chore-update-db-library
christyjacob4 Dec 18, 2024
9760fee
Revert "Chore: findOne now returns empty documents instead of false o…
christyjacob4 Dec 18, 2024
7c983d7
Merge pull request #88 from utopia-php/revert-81-chore-findones-empties
christyjacob4 Dec 18, 2024
f0c49a6
Revert "Framework"
christyjacob4 Dec 18, 2024
2b215d5
Merge pull request #89 from utopia-php/revert-72-feat-framework-v2
christyjacob4 Dec 18, 2024
0648def
Merge branch 'main' of https://github.com/utopia-php/abuse into sync-…
christyjacob4 Dec 18, 2024
44a84fd
Merge pull request #90 from utopia-php/sync-main-with-0.43.x
christyjacob4 Dec 18, 2024
25b9654
Merge pull request #86 from utopia-php/add-support-for-sharding-adapter
christyjacob4 Dec 18, 2024
397a49d
chore: update tests and change timestamp type
christyjacob4 Dec 20, 2024
82a0215
Merge branch 'main' of github.com:utopia-php/abuse into add-support-f…
christyjacob4 Dec 20, 2024
d311923
chore: codeql and linter
christyjacob4 Dec 20, 2024
82f77e2
chore: review comment
christyjacob4 Dec 20, 2024
54a5835
Merge pull request #91 from utopia-php/add-support-for-sharding-adapter
christyjacob4 Dec 20, 2024
d985da2
chore: optimise abuse
loks0n Dec 27, 2024
a9c7993
fix: check
loks0n Dec 27, 2024
79c8ce6
chore: fmt
loks0n Dec 27, 2024
cf97de1
chore: remove obselete version
loks0n Dec 27, 2024
03cf65c
feat: redis cluster
loks0n Dec 27, 2024
7f2b6b0
fix: redis scan
loks0n Dec 27, 2024
e7c208f
chore: revert redis
loks0n Dec 27, 2024
b63b782
chore: fmt
loks0n Dec 27, 2024
d7b8cf5
fix: tests
loks0n Dec 27, 2024
91091d6
chore: remove test cleanup
loks0n Dec 27, 2024
a59fe2a
chore: fix benchmarking
loks0n Dec 27, 2024
440ebd6
fix: bench
loks0n Dec 27, 2024
072725d
chore: bench
loks0n Dec 27, 2024
bef426a
Merge pull request #92 from utopia-php/feat-improve-redis
eldadfux Dec 27, 2024
8c950cc
bumb database version
fogelito Jan 2, 2025
4214cd6
Merge pull request #93 from utopia-php/database-0.53.29
christyjacob4 Jan 2, 2025
c8a403b
Update db
abnegate Jan 10, 2025
2f5d9dc
Update database
abnegate Jan 10, 2025
ba83ba8
Merge branch 'main' into 0.43.x
abnegate Jan 13, 2025
59749df
Merge pull request #94 from utopia-php/0.43.x
abnegate Jan 13, 2025
79a32e5
Update database
abnegate Jan 15, 2025
2b52bb3
Merge pull request #95 from utopia-php/chore-update-database
abnegate Jan 15, 2025
6f66803
Update database
abnegate Jan 23, 2025
8387c65
Merge pull request #96 from utopia-php/chore-update-database
abnegate Jan 23, 2025
1bd0a16
Update database to 0.58
PineappleIOnic Feb 4, 2025
6403c8e
Update version to fix 8.1
PineappleIOnic Feb 4, 2025
76612c2
Merge pull request #97 from utopia-php/chore-update-database
abnegate Feb 4, 2025
f2f9cc0
Update database
abnegate Feb 12, 2025
3ff6781
Merge pull request #98 from utopia-php/chore-update-database
abnegate Feb 12, 2025
3763248
Update database
abnegate Feb 17, 2025
661687b
Merge pull request #99 from utopia-php/chore-update-database
abnegate Feb 17, 2025
bc3e917
Track latest database
abnegate Mar 6, 2025
acf5711
Merge branch 'main' into chore-update-database
abnegate Mar 6, 2025
a0d6421
Merge pull request #100 from utopia-php/chore-update-database
abnegate Mar 6, 2025
899feb6
Update lock
abnegate Aug 13, 2025
c5e2232
Merge pull request #102 from utopia-php/chore-update-db
abnegate Aug 13, 2025
cb8707a
Update DB
abnegate Sep 4, 2025
cd59156
Merge pull request #103 from utopia-php/chore-update-db
abnegate Sep 4, 2025
cb92c59
Fix PSR autoload
abnegate Oct 20, 2025
79ac753
Unpin DB
abnegate Oct 20, 2025
ae497a7
Merge remote-tracking branch 'origin/main' into chore-update-db
abnegate Oct 20, 2025
f517e66
Fix image refs
abnegate Oct 20, 2025
3ee9320
Remove adminer
abnegate Oct 20, 2025
611fa66
Merge pull request #104 from utopia-php/chore-update-db
abnegate Oct 20, 2025
947d16c
Implement AppwriteTablesDB adapter
Meldiron Nov 13, 2025
04dc655
Shorten code
Meldiron Nov 13, 2025
b1a2319
Update adapter namespace
Meldiron Nov 13, 2025
25e4c02
Update docs
Meldiron Nov 13, 2025
6520245
Fix linter
Meldiron Nov 13, 2025
b378c5b
Merge pull request #105 from utopia-php/feat-appwrite-adapter
eldadfux Nov 13, 2025
96b8499
Refactor: assertions
lohanidamodar Nov 26, 2025
36edca6
Merge pull request #106 from utopia-php/refactor-assertions
Meldiron Nov 26, 2025
8a72773
Initial plan
Copilot Jan 5, 2026
14ccf84
Implement reset() method for Abuse interface and adapters
Copilot Jan 5, 2026
2694a0a
Improve error messages in Database and TablesDB adapters
Copilot Jan 5, 2026
f9ed068
Fix docblock and improve string concatenation consistency
Copilot Jan 5, 2026
c5bfa4d
Remove limit check from set() methods and simplify TablesDB logic
Copilot Jan 5, 2026
b51d34f
Improve PR quality
Meldiron Jan 5, 2026
b9aa135
Merge branch 'copilot/add-reset-method-to-abuse-interface' of https:/…
Meldiron Jan 5, 2026
31e4225
Revert changes
Meldiron Jan 5, 2026
7bece2f
Upgrade Appwrite SDK
Meldiron Jan 5, 2026
3339d05
Merge pull request #107 from utopia-php/copilot/add-reset-method-to-a…
Meldiron Jan 5, 2026
33a24ad
Update deps
abnegate Jan 15, 2026
98c6d7b
Update authz
abnegate Jan 15, 2026
b7fc951
Lint
abnegate Jan 15, 2026
15cd5db
Merge pull request #108 from utopia-php/chore-update-database
abnegate Jan 15, 2026
251856e
chore: upgrade utopia-php/database to 5.*
premtsd-code Jan 30, 2026
20bee84
Merge pull request #109 from utopia-php/chore-upgrade-database-5
abnegate Feb 2, 2026
3ee854f
Remove deprecated curl_close calls
ChiragAgg5k Apr 29, 2026
d2c834f
Clean up curl_close removal formatting
ChiragAgg5k Apr 29, 2026
53f4274
Merge pull request #110 from utopia-php/codex/remove-curl-close-php85
loks0n Apr 29, 2026
2a1fb79
feat: bump appwrite/appwrite to 23.* (typed models, TablesDBIndexType)
premtsd-code May 8, 2026
cfd290a
fix: require PHP >=8.2, fix latent ColumnStatus filter
premtsd-code May 11, 2026
a7a9bc3
fix: drop stale Utopia\Exception import (phpstan level max)
premtsd-code May 11, 2026
c20ded6
ci: add PHP 8.4 to test matrix
premtsd-code May 11, 2026
5d7efbe
Merge pull request #111 from utopia-php/feat/sdk-23
abnegate May 11, 2026
5f1b5e2
feat: bump appwrite/appwrite to 24.*
premtsd-code May 20, 2026
00e59c8
Merge pull request #113 from utopia-php/feat-bump-sdk-24
abnegate Jun 3, 2026
0ecd54f
Update PHP SDK to 26
ChiragAgg5k Jun 17, 2026
e340f2c
Merge pull request #114 from utopia-php/codex/update-php-sdk-26
loks0n Jun 17, 2026
8f5df02
chore(deps): require utopia-php/database ^6.0.0 (#116)
abnegate Jun 18, 2026
3b52718
Add no-op and Redis pool time limit adapters (#115)
premtsd-code Jun 19, 2026
f4f0320
chore(deps)!: upgrade to utopia-php/pools 2.x
loks0n Jul 31, 2026
03cc86e
chore(deps): bump utopia-php/database to 7.x and refresh lock
loks0n Jul 31, 2026
460d941
Merge pull request #118 from utopia-php/chore/pools-2
loks0n Jul 31, 2026
1c928b3
chore: drop unused PHP 8.2 and 8.3 test images
loks0n Jul 31, 2026
47d8270
Merge pull request #119 from utopia-php/chore/php-8.4
loks0n Jul 31, 2026
43c6979
feat(appwrite): create the abuse table schema inline
claudear Aug 11, 2026
6b358a2
fix(tests): read listed indexes as models, columns as raw payloads
claudear Aug 11, 2026
0f0d16d
Merge pull request #120 from utopia-php/feat/inline-tablesdb-schema
abnegate Aug 11, 2026
d275ce3
feat(sliding-window): add storage-agnostic SlidingWindow adapter cont…
ArnabChatterjee20k Aug 12, 2026
0dbc1f0
feat(sliding-window): add RedisBase with atomic Lua check-and-increment
ArnabChatterjee20k Aug 12, 2026
f281091
feat(sliding-window): add Redis adapter
ArnabChatterjee20k Aug 12, 2026
d68199f
feat(sliding-window): add RedisCluster adapter with hash-tagged keys
ArnabChatterjee20k Aug 12, 2026
2d15f05
feat(sliding-window): add RedisPool adapter
ArnabChatterjee20k Aug 12, 2026
5daae51
test(sliding-window): add shared adapter test base
ArnabChatterjee20k Aug 12, 2026
4d8c86b
test(sliding-window): add Redis, RedisCluster and RedisPool test cases
ArnabChatterjee20k Aug 12, 2026
47a5459
Merge branch 'main' into strategy/sliding-window
ArnabChatterjee20k Aug 12, 2026
5c016a8
refactor(sliding-window): reduce adapter seams to eval/get/delete pri…
ArnabChatterjee20k Aug 12, 2026
bf8336d
fix(sliding-window): validate window/ttl bounds and cache weighted es…
ArnabChatterjee20k Aug 12, 2026
25016c0
refactor(sliding-window): improve window computation and state manage…
ArnabChatterjee20k Aug 12, 2026
252a10d
feat(token-bucket): add agnostic adapter and Redis-family base
ArnabChatterjee20k Aug 13, 2026
1830b61
feat(token-bucket): add Redis, RedisCluster and RedisPool adapters
ArnabChatterjee20k Aug 13, 2026
84f4424
test(token-bucket): add Redis, RedisCluster and RedisPool test cases
ArnabChatterjee20k Aug 13, 2026
70e1e4c
fix(token-bucket): floor available balance before deriving consumed c…
ArnabChatterjee20k Aug 13, 2026
6c152d3
fix(token-bucket): always read a fresh refill estimate in count()
ArnabChatterjee20k Aug 13, 2026
6a011fe
fix(token-bucket): scan every cluster master fully before paginating …
ArnabChatterjee20k Aug 13, 2026
e5000d3
feat(sliding-window): add None adapter
ArnabChatterjee20k Aug 13, 2026
4afb6a2
feat(token-bucket): add None adapter
ArnabChatterjee20k Aug 13, 2026
1eecb5e
Merge branch 'strategy/sliding-window' into strategy/token-bucket
ArnabChatterjee20k Aug 13, 2026
fba428f
fix(sliding-window): guard None against zero-sized window
ArnabChatterjee20k Aug 13, 2026
49ac83a
fix(sliding-window): drop stale count cache so estimate keeps decaying
ArnabChatterjee20k Aug 13, 2026
d75bb51
Merge pull request #122 from utopia-php/strategy/token-bucket
ArnabChatterjee20k Aug 13, 2026
821a188
Merge pull request #121 from utopia-php/strategy/sliding-window
abnegate Aug 13, 2026
d35e92d
Add 'packages/abuse/' from commit '821a1884c8067736e1a27d9fc70bdb2cc8…
ChiragAgg5k Sep 28, 2026
972431b
chore(abuse): mirror plumbing
ChiragAgg5k Sep 28, 2026
7086f0b
refactor: load abuse from packages/
ChiragAgg5k Sep 28, 2026
596eb0d
Merge remote-tracking branch 'origin/main' into chore/absorb-abuse
ChiragAgg5k Sep 28, 2026
f3edba3
Merge remote-tracking branch 'origin/main' into chore/absorb-abuse
ChiragAgg5k Sep 28, 2026
6131e11
Merge remote-tracking branch 'origin/main' into chore/absorb-abuse
ChiragAgg5k Sep 28, 2026
5776212
Merge remote-tracking branch 'origin/main' into chore/absorb-abuse
ChiragAgg5k Sep 28, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"psr-4": {
"Appwrite\\": "src/Appwrite",
"Executor\\": "src/Executor",
"Utopia\\Abuse\\": "packages/abuse/src",
"Utopia\\Agents\\": "packages/agents/src",
"Utopia\\Audit\\": "packages/audit/src",
"Utopia\\Auth\\": "packages/auth/src",
Expand Down Expand Up @@ -78,6 +79,7 @@
"Tests\\E2E\\": "tests/e2e",
"Tests\\Unit\\": "tests/unit",
"Appwrite\\Tests\\": "tests/extensions",
"Utopia\\Abuse\\Tests\\": "packages/abuse/tests",
"Utopia\\Agents\\Tests\\": "packages/agents/tests",
"Utopia\\Audit\\Tests\\": "packages/audit/tests",
"Utopia\\Auth\\Tests\\": "packages/auth/tests",
Expand Down Expand Up @@ -144,7 +146,6 @@
"ext-sockets": "*",
"appwrite/php-runtimes": "0.20.*",
"appwrite/php-clamav": "2.0.*",
"utopia-php/abuse": "2.0.*",
"utopia-php/config": "1.*",
"utopia-php/database": "^7.3.11",
"utopia-php/migration": "^2.0.0",
Expand All @@ -164,7 +165,8 @@
"psr/http-factory": "^1.0",
"psr/http-client": "^1.0",
"psr/http-message": "^2.0",
"psr/container": "^2.0"
"psr/container": "^2.0",
"appwrite/appwrite": "^27.1"
},
"require-dev": {
"ext-fileinfo": "*",
Expand Down Expand Up @@ -193,6 +195,7 @@
}
},
"replace": {
"utopia-php/abuse": "*",
"utopia-php/agents": "*",
"utopia-php/audit": "*",
"utopia-php/auth": "*",
Expand Down
55 changes: 1 addition & 54 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions packages/abuse/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
APPWRITE_ENDPOINT=
APPWRITE_PROJECT_ID=
APPWRITE_API_KEY=
17 changes: 17 additions & 0 deletions packages/abuse/.github/workflows/mirror.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Mirror

on:
pull_request_target:
types: [opened]
issues:
types: [opened]

permissions:
issues: write
pull-requests: write

jobs:
redirect:
uses: appwrite/appwrite/.github/workflows/mirror-redirect.yml@main
with:
package: abuse
5 changes: 5 additions & 0 deletions packages/abuse/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/vendor/
/.idea/
.env
.phpunit.cache
composer.lock
76 changes: 76 additions & 0 deletions packages/abuse/CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Contributor Covenant Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to make participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity, expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment
include:

- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

- The use of sexualized language or imagery and unwelcome sexual attention or
advances
- Trolling, insulting/derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or electronic
address, without explicit permission
- Other conduct which could reasonably be considered inappropriate in a
professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at team@appwrite.io. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq
20 changes: 20 additions & 0 deletions packages/abuse/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
The MIT License (MIT)

Copyright (c) 2013 Eldad Fux

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
135 changes: 135 additions & 0 deletions packages/abuse/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
# Utopia Abuse

> [!IMPORTANT]
> This repository is a read-only mirror of [`packages/abuse`](https://github.com/appwrite/appwrite/tree/main/packages/abuse) in [appwrite/appwrite](https://github.com/appwrite/appwrite). Development happens there — please open issues and pull requests against appwrite/appwrite.

![Total Downloads](https://img.shields.io/packagist/dt/utopia-php/abuse.svg)
[![Discord](https://img.shields.io/discord/564160730845151244)](https://appwrite.io/discord)

Utopia framework abuse library is simple and lite library for managing application usage limits. This library is aiming to be as simple and easy to learn and use. This library is maintained by the [Appwrite team](https://appwrite.io).

Although this library is part of the [Utopia Framework](https://github.com/utopia-php/framework) project it is dependency free, and can be used as standalone with any other PHP project or framework.

## Getting Started

Install using composer:

```bash
composer require utopia-php/abuse
```

**Time Limit Abuse**

The time limit abuse allow each key (action) to be performed [X] times in given time frame.
This adapter uses a MySQL / MariaDB to store usage attempts. Before using it, call `$adapter->setup()` once to create the collection it stores attempts in.

### Database adapter

```php
<?php

require_once __DIR__ . '/../../vendor/autoload.php';

use Utopia\Abuse\Abuse;
use Utopia\Abuse\Adapters\TimeLimit;
use Utopia\Cache\Adapter\None as NoCache;
use Utopia\Cache\Cache;
use Utopia\Database\Adapter\MySQL;
use Utopia\Database\Database;

$dbHost = '127.0.0.1';
$dbUser = 'travis';
$dbPass = '';
$dbPort = '3306';

$pdo = new PDO("mysql:host={$dbHost};port={$dbPort};charset=utf8mb4", $dbUser, $dbPass, [
PDO::ATTR_TIMEOUT => 3, // Seconds
PDO::ATTR_PERSISTENT => true,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_EMULATE_PREPARES => true,
PDO::ATTR_STRINGIFY_FETCHES => true,
]);

$db = new Database(new MySQL($pdo), new Cache(new NoCache()));
$db->setNamespace('namespace');

// Limit login attempts to 10 time in 5 minutes time frame
$adapter = new TimeLimit('login-attempt-from-{{ip}}', 10, (60 * 5), $db);

$adapter->setup(); //setup database as required
$adapter->setParam('{{ip}}', '127.0.0.1')
;

$abuse = new Abuse($adapter);

// Use vars to resolve adapter key

if($abuse->check()) {
throw new Exception('Service was abused!'); // throw error and return X-Rate limit headers here
}
```

### Appwrite TablesDB adapter

```php
<?php

require_once __DIR__ . '/../../vendor/autoload.php';

use Utopia\Abuse\Abuse;
use Utopia\Abuse\Adapters\TimeLimit\Appwrite\TablesDB as TablesDBAdapter;
use Appwrite\Client;

$client = (new Client())
->setEndpoint('[YOUR_ENDPOINT]')
->setProject('[YOUR_PROJECT_ID]')
->setKey('[YOUR_API_KEY]');
$databaseId = 'abuse';

// Limit login attempts to 10 time in 5 minutes time frame
$adapter = new TablesDBAdapter('login-attempt-from-{{ip}}', 10, (60 * 5), $client, $databaseId);

$adapter->setup(); //setup database as required
$adapter->setParam('{{ip}}', '127.0.0.1');

$abuse = new Abuse($adapter);

// Use vars to resolve adapter key

if($abuse->check()) {
throw new Exception('Service was abused!'); // throw error and return X-Rate limit headers here
}
```

**ReCaptcha Abuse**

The ReCaptcha abuse controller is using Google ReCaptcha service to detect when service is being abused by bots.
To use this adapter you need to create an API key from the Google ReCaptcha service [admin console](https://www.google.com/recaptcha/admin).

```php
<?php

require_once __DIR__ . '/../../vendor/autoload.php';

use Utopia\Abuse\Abuse;
use Utopia\Abuse\Adapters\ReCaptcha;

// Limit login attempts to 10 time in 5 minutes time frame
$adapter = new ReCaptcha('secret-api-key', $_POST['g-recaptcha-response'], $_SERVER['REMOTE_ADDR']);
$abuse = new Abuse($adapter);

if($abuse->check()) {
throw new Exception('Service was abused!'); // throw error and return X-Rate limit headers here
}
```

*Notice: The code above is for example purpose only. It is always recommended to validate user input before using it in your code. If you are using a load balancer or any proxy server you might need to get user IP from the HTTP_X_FORWARDE‌​D_FOR header.*

## System Requirements

Utopia Framework requires PHP 8.0 or later. We recommend using the latest PHP version whenever possible.

## Copyright and license

The MIT License (MIT) [http://www.opensource.org/licenses/mit-license.php](http://www.opensource.org/licenses/mit-license.php)
Loading
Loading