Skip to content

Commit b9cfc26

Browse files
authored
Merge pull request #14 from pdsinterop/feature/podpro-compat-flag
add compatibility mode for podpro, which has an issue with long refre…
2 parents 927a663 + 44c80d2 commit b9cfc26

File tree

4 files changed

+30
-2
lines changed

4 files changed

+30
-2
lines changed

config.php.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
const FRONTENDDIR = __DIR__ . "/frontend/";
77
const DBPATH = __DIR__ . "/db/solid.db";
88
const CLEANUP_FILE = __DIR__ . "/db/lastcleanup";
9+
const PODPRO_COMPATIBILITY = false;
910

1011
const MAILER = [
1112
"host" => "mailpit",

lib/Routes/SolidIdp.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,15 @@ public static function respondToToken() {
204204
);
205205
}
206206

207-
Server::respond($response);
207+
// Hack for podpro
208+
if (PODPRO_COMPATIBILITY && strstr($clientId, "podpro.dev")) {
209+
$response->getBody()->rewind();
210+
$responseBody = $response->getBody()->getContents();
211+
$body = json_decode($responseBody, true);
212+
$body['refresh_token'] = str_repeat('a', 209); // Podpro doesn't like refresh tokens longer than 209 characters; Sad.
213+
Server::respondPodPro($response, $body);
214+
} else {
215+
Server::respond($response);
216+
}
208217
}
209218
}

lib/Server.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,4 +163,21 @@ public static function respond($response) {
163163
}
164164
echo json_encode($body, JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR);
165165
}
166+
167+
public static function respondPodPro($response, $body) {
168+
$statusCode = $response->getStatusCode();
169+
$response->getBody()->rewind();
170+
$headers = $response->getHeaders();
171+
172+
header("HTTP/1.1 $statusCode");
173+
foreach ($headers as $header => $values) {
174+
foreach ($values as $value) {
175+
if ($header == "Location") {
176+
$value = preg_replace("|%26%2334%3B|", "%22", $value); // odoo weird encoding
177+
}
178+
header($header . ":" . $value);
179+
}
180+
}
181+
echo json_encode($body, JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR);
182+
}
166183
}

tests/testsuite/config.php.testsuite

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
const FRONTENDDIR = __DIR__ . "/frontend/";
77
const DBPATH = __DIR__ . "/db/solid.db";
88
const CLEANUP_FILE = __DIR__ . "/db/lastcleanup";
9-
9+
const PODPRO_COMPATIBILITY = false;
10+
1011
const MAILER = [
1112
"host" => "mailpit",
1213
"port" => 1025,

0 commit comments

Comments
 (0)