Skip to content

Commit 9211062

Browse files
authored
Merge pull request #5919 from BookStackApp/v25-11
Merge v25-11 changes into dev
2 parents 1ee5711 + 313326b commit 9211062

File tree

15 files changed

+838
-602
lines changed

15 files changed

+838
-602
lines changed

app/Access/Controllers/OidcController.php

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@
99

1010
class OidcController extends Controller
1111
{
12-
protected OidcService $oidcService;
13-
14-
public function __construct(OidcService $oidcService)
15-
{
16-
$this->oidcService = $oidcService;
12+
public function __construct(
13+
protected OidcService $oidcService
14+
) {
1715
$this->middleware('guard:oidc');
1816
}
1917

@@ -30,7 +28,7 @@ public function login()
3028
return redirect('/login');
3129
}
3230

33-
session()->flash('oidc_state', $loginDetails['state']);
31+
session()->put('oidc_state', time() . ':' . $loginDetails['state']);
3432

3533
return redirect($loginDetails['url']);
3634
}
@@ -41,10 +39,16 @@ public function login()
4139
*/
4240
public function callback(Request $request)
4341
{
44-
$storedState = session()->pull('oidc_state');
4542
$responseState = $request->query('state');
43+
$splitState = explode(':', session()->pull('oidc_state', ':'), 2);
44+
if (count($splitState) !== 2) {
45+
$splitState = [null, null];
46+
}
47+
48+
[$storedStateTime, $storedState] = $splitState;
49+
$threeMinutesAgo = time() - 3 * 60;
4650

47-
if ($storedState !== $responseState) {
51+
if (!$storedState || $storedState !== $responseState || intval($storedStateTime) < $threeMinutesAgo) {
4852
$this->showErrorNotification(trans('errors.oidc_fail_authed', ['system' => config('oidc.name')]));
4953

5054
return redirect('/login');
@@ -62,7 +66,7 @@ public function callback(Request $request)
6266
}
6367

6468
/**
65-
* Log the user out then start the OIDC RP-initiated logout process.
69+
* Log the user out, then start the OIDC RP-initiated logout process.
6670
*/
6771
public function logout()
6872
{

app/Activity/Models/Comment.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,19 @@ class Comment extends Model implements Loggable, OwnableInterface
4141
*/
4242
public function entity(): MorphTo
4343
{
44-
return $this->morphTo('commentable');
44+
// We specifically define null here to avoid the different name (commentable)
45+
// being used by Laravel eager loading instead of the method name, which it was doing
46+
// in some scenarios like when deserialized when going through the queue system.
47+
// So we instead specify the type and id column names to use.
48+
// Related to:
49+
// https://github.com/laravel/framework/pull/24815
50+
// https://github.com/laravel/framework/issues/27342
51+
// https://github.com/laravel/framework/issues/47953
52+
// (and probably more)
53+
54+
// Ultimately, we could just align the method name to 'commentable' but that would be a potential
55+
// breaking change and not really worthwhile in a patch due to the risk of creating extra problems.
56+
return $this->morphTo(null, 'commentable_type', 'commentable_id');
4557
}
4658

4759
/**

app/Activity/Notifications/Handlers/BaseNotificationHandler.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ protected function sendNotificationToUserIds(string $notification, array $userId
2020
{
2121
$users = User::query()->whereIn('id', array_unique($userIds))->get();
2222

23+
/** @var User $user */
2324
foreach ($users as $user) {
2425
// Prevent sending to the user that initiated the activity
2526
if ($user->id === $initiator->id) {

app/Http/Middleware/StartSessionExtended.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@
1414
class StartSessionExtended extends Middleware
1515
{
1616
protected static array $pathPrefixesExcludedFromHistory = [
17-
'uploads/images/'
17+
'uploads/images/',
18+
'dist/',
19+
'manifest.json',
20+
'opensearch.xml',
1821
];
1922

2023
/**

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"league/flysystem-aws-s3-v3": "^3.0",
3030
"league/html-to-markdown": "^5.0.0",
3131
"league/oauth2-client": "^2.6",
32-
"onelogin/php-saml": "^4.0",
32+
"onelogin/php-saml": "^4.3.1",
3333
"phpseclib/phpseclib": "^3.0",
3434
"pragmarx/google2fa": "^8.0",
3535
"predis/predis": "^3.2",

0 commit comments

Comments
 (0)