From 2b4cffe2a496a914d19d7baf198ad2a1b4a71d2e Mon Sep 17 00:00:00 2001 From: Ben Peachey Date: Thu, 20 Oct 2022 14:52:02 +0200 Subject: [PATCH 1/3] Change the JtiReplayDetector to use a hash rather than a full URL. --- solid/lib/JtiReplayDetector.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/solid/lib/JtiReplayDetector.php b/solid/lib/JtiReplayDetector.php index ce5c614d..bb449f52 100644 --- a/solid/lib/JtiReplayDetector.php +++ b/solid/lib/JtiReplayDetector.php @@ -22,11 +22,13 @@ public function __construct(private DateInterval $interval, private IDBConnectio public function detect(string $jti, string $targetUri): bool { + $hash = sha1($targetUri); + // @TODO: $this->rotateBuckets(); - $has = $this->has($jti, $targetUri); + $has = $this->has($jti, $hash); if ($has === false) { - $this->store($jti, $targetUri); + $this->store($jti, $hash); } return $has; From f68001fdcddfb1193401d561576ca3bf744665e0 Mon Sep 17 00:00:00 2001 From: Ben Peachey Date: Thu, 20 Oct 2022 15:17:10 +0200 Subject: [PATCH 2/3] Change DB migration to use URI hash rather than full URL. --- .../Version000000Date20220923134100.php | 55 ------------------ .../Version000000Date20221020145600.php | 58 +++++++++++++++++++ 2 files changed, 58 insertions(+), 55 deletions(-) delete mode 100644 solid/lib/Migration/Version000000Date20220923134100.php create mode 100644 solid/lib/Migration/Version000000Date20221020145600.php diff --git a/solid/lib/Migration/Version000000Date20220923134100.php b/solid/lib/Migration/Version000000Date20220923134100.php deleted file mode 100644 index 4aab8e6d..00000000 --- a/solid/lib/Migration/Version000000Date20220923134100.php +++ /dev/null @@ -1,55 +0,0 @@ -hasTable('solid_jti') === false) { - $table = $schema->createTable('solid_jti'); - - $table->addColumn('id', Types::INTEGER, [ - 'autoincrement' => true, - 'notnull' => true, - ]); - - $table->addColumn('jti', Types::STRING, [ - 'length' => 255, - 'notnull' => true, - ]); - - $table->addColumn('uri', Types::STRING, [ - 'length' => 2048, - 'notnull' => true, - ]); - - $table->addColumn('request_time', Types::DATETIME, [ - 'default' => 'CURRENT_TIMESTAMP', - 'notnull' => true, - ]); - - $table->setPrimaryKey(['id']); - $table->addIndex(['jti', 'uri']); - } - - return $schema; - } -} diff --git a/solid/lib/Migration/Version000000Date20221020145600.php b/solid/lib/Migration/Version000000Date20221020145600.php new file mode 100644 index 00000000..90b3eb1d --- /dev/null +++ b/solid/lib/Migration/Version000000Date20221020145600.php @@ -0,0 +1,58 @@ +hasTable('solid_jti') === true) { + $schema->dropTable('solid_jti'); + } + + $table = $schema->createTable('solid_jti'); + + $table->addColumn('id', Types::INTEGER, [ + 'autoincrement' => true, + 'notnull' => true, + ]); + + $table->addColumn('jti', Types::STRING, [ + 'length' => 255, + 'notnull' => true, + ]); + + $table->addColumn('uri', Types::STRING, [ + 'length' => 40, + 'notnull' => true, + ]); + + $table->addColumn('request_time', Types::DATETIME, [ + 'default' => 'CURRENT_TIMESTAMP', + 'notnull' => true, + ]); + + $table->setPrimaryKey(['id']); + $table->addIndex(['jti', 'uri']); + + return $schema; + } +} From a15400e3f82c5f246cd8488a7dad7e5c41759683 Mon Sep 17 00:00:00 2001 From: Ben Peachey Date: Fri, 11 Nov 2022 15:36:24 +0100 Subject: [PATCH 3/3] Trigger build