Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
22 changes: 13 additions & 9 deletions app/Access/Controllers/OidcController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@

class OidcController extends Controller
{
protected OidcService $oidcService;

public function __construct(OidcService $oidcService)
{
$this->oidcService = $oidcService;
public function __construct(
protected OidcService $oidcService
) {
$this->middleware('guard:oidc');
}

Expand All @@ -30,7 +28,7 @@ public function login()
return redirect('/login');
}

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

return redirect($loginDetails['url']);
}
Expand All @@ -41,10 +39,16 @@ public function login()
*/
public function callback(Request $request)
{
$storedState = session()->pull('oidc_state');
$responseState = $request->query('state');
$splitState = explode(':', session()->pull('oidc_state', ':'), 2);
if (count($splitState) !== 2) {
$splitState = [null, null];
}

[$storedStateTime, $storedState] = $splitState;
$threeMinutesAgo = time() - 3 * 60;

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

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

/**
* Log the user out then start the OIDC RP-initiated logout process.
* Log the user out, then start the OIDC RP-initiated logout process.
*/
public function logout()
{
Expand Down
14 changes: 13 additions & 1 deletion app/Activity/Models/Comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,19 @@ class Comment extends Model implements Loggable, OwnableInterface
*/
public function entity(): MorphTo
{
return $this->morphTo('commentable');
// We specifically define null here to avoid the different name (commentable)
// being used by Laravel eager loading instead of the method name, which it was doing
// in some scenarios like when deserialized when going through the queue system.
// So we instead specify the type and id column names to use.
// Related to:
// https://github.com/laravel/framework/pull/24815
// https://github.com/laravel/framework/issues/27342
// https://github.com/laravel/framework/issues/47953
// (and probably more)

// Ultimately, we could just align the method name to 'commentable' but that would be a potential
// breaking change and not really worthwhile in a patch due to the risk of creating extra problems.
return $this->morphTo(null, 'commentable_type', 'commentable_id');
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ protected function sendNotificationToUserIds(string $notification, array $userId
{
$users = User::query()->whereIn('id', array_unique($userIds))->get();

/** @var User $user */
foreach ($users as $user) {
// Prevent sending to the user that initiated the activity
if ($user->id === $initiator->id) {
Expand Down
5 changes: 4 additions & 1 deletion app/Http/Middleware/StartSessionExtended.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
class StartSessionExtended extends Middleware
{
protected static array $pathPrefixesExcludedFromHistory = [
'uploads/images/'
'uploads/images/',
'dist/',
'manifest.json',
'opensearch.xml',
];

/**
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"league/flysystem-aws-s3-v3": "^3.0",
"league/html-to-markdown": "^5.0.0",
"league/oauth2-client": "^2.6",
"onelogin/php-saml": "^4.0",
"onelogin/php-saml": "^4.3.1",
"phpseclib/phpseclib": "^3.0",
"pragmarx/google2fa": "^8.0",
"predis/predis": "^3.2",
Expand Down
Loading