Skip to content

Commit 3bf3894

Browse files
committed
implement jti
1 parent d5644f4 commit 3bf3894

1 file changed

Lines changed: 24 additions & 11 deletions

File tree

lib/Server.php

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
namespace PdsInterop\PhpSolid;
2+
namespace Pdsinterop\PhpSolid;
33

44
use Pdsinterop\Solid\Auth\Factory\AuthorizationServerFactory;
55
use Laminas\Diactoros\Response;
@@ -11,6 +11,7 @@
1111
use Pdsinterop\Solid\Auth\Utils\JtiValidator;
1212
use Pdsinterop\Solid\Auth\TokenGenerator;
1313
use Pdsinterop\PhpSolid\ClientRegistration;
14+
use Pdsinterop\PhpSolid\JtiStore;
1415

1516
class Server {
1617
public static function generateKeySet() {
@@ -84,14 +85,34 @@ public static function getConfigClient() {
8485
public static function getDpop() {
8586
$replayDetector = new ReplayDetector(
8687
function($jti, $targetUri) {
87-
// FIXME: check if the JTI exists in our store.
88-
// FIXME: store the JTI;
88+
if (JtiStore::hasJti($jti)) {
89+
return true;
90+
} else {
91+
JtiStore::saveJti($jti);
92+
return false;
93+
}
8994
return false;
9095
}
9196
);
9297
$jtiValidator = new JtiValidator($replayDetector);
9398
return new DPop($jtiValidator);
9499
}
100+
101+
public static function getBearer() {
102+
$replayDetector = new ReplayDetector(
103+
function($jti, $targetUri) {
104+
if (JtiStore::hasJti($jti)) {
105+
return true;
106+
} else {
107+
JtiStore::saveJti($jti);
108+
return false;
109+
}
110+
return false;
111+
}
112+
);
113+
$jtiValidator = new JtiValidator($replayDetector);
114+
return new Bearer($jtiValidator);
115+
}
95116

96117
public static function getEndpoints() {
97118
return array(
@@ -141,12 +162,4 @@ public static function respond($response) {
141162
}
142163
echo json_encode($body, JSON_PRETTY_PRINT);
143164
}
144-
145-
public static function getUser() {
146-
return [
147-
"id" => "1234567", // FIXME: Get the ID of the currently logged in user
148-
"allowedClients" => ["93b01f0953b07394bbe59217b3876041", "ebc22eebeecbe0e703647c229e18ddac"]
149-
];
150-
}
151165
}
152-

0 commit comments

Comments
 (0)