From: Dan Brown Date: Sun, 23 Feb 2025 11:23:35 +0000 (+0000) Subject: Merge pull request #5491 from BookStackApp/deprecations X-Git-Tag: v25.02~1^2~7 X-Git-Url: http://source.bookstackapp.com/bookstack/commitdiff_plain/d2542d6265ea7379affcfd0ef6097b29dd536c04?hp=5050719ea3933efcaaf3f69e51b25fcca0383f5b Merge pull request #5491 from BookStackApp/deprecations Addressing PHP 8.4 Deprecations --- diff --git a/app/Access/LdapService.php b/app/Access/LdapService.php index e5037ad2f..0f456efc2 100644 --- a/app/Access/LdapService.php +++ b/app/Access/LdapService.php @@ -112,10 +112,14 @@ class LdapService return null; } - $userCn = $this->getUserResponseProperty($user, 'cn', null); + $nameDefault = $this->getUserResponseProperty($user, 'cn', null); + if (is_null($nameDefault)) { + $nameDefault = ldap_explode_dn($user['dn'], 1)[0] ?? $user['dn']; + } + $formatted = [ 'uid' => $this->getUserResponseProperty($user, $idAttr, $user['dn']), - 'name' => $this->getUserDisplayName($user, $displayNameAttrs, $userCn), + 'name' => $this->getUserDisplayName($user, $displayNameAttrs, $nameDefault), 'dn' => $user['dn'], 'email' => $this->getUserResponseProperty($user, $emailAttr, null), 'avatar' => $thumbnailAttr ? $this->getUserResponseProperty($user, $thumbnailAttr, null) : null, diff --git a/app/Uploads/ImageResizer.php b/app/Uploads/ImageResizer.php index fa6b1cac2..5f095658f 100644 --- a/app/Uploads/ImageResizer.php +++ b/app/Uploads/ImageResizer.php @@ -158,7 +158,10 @@ class ImageResizer */ protected function interventionFromImageData(string $imageData, ?string $fileType): InterventionImage { - $manager = new ImageManager(new Driver()); + $manager = new ImageManager( + new Driver(), + autoOrientation: false, + ); // Ensure gif images are decoded natively instead of deferring to intervention GIF // handling since we don't need the added animation support. diff --git a/resources/js/components/tri-layout.js b/resources/js/components/tri-layout.js index 8ccefb06c..be9388e8d 100644 --- a/resources/js/components/tri-layout.js +++ b/resources/js/components/tri-layout.js @@ -27,7 +27,7 @@ export class TriLayout extends Component { updateLayout() { let newLayout = 'tablet'; if (window.innerWidth <= 1000) newLayout = 'mobile'; - if (window.innerWidth >= 1400) newLayout = 'desktop'; + if (window.innerWidth > 1400) newLayout = 'desktop'; if (newLayout === this.lastLayoutType) return; if (this.onDestroy) { diff --git a/resources/sass/_mixins.scss b/resources/sass/_mixins.scss index 0a419c08a..fc5086008 100644 --- a/resources/sass/_mixins.scss +++ b/resources/sass/_mixins.scss @@ -3,10 +3,10 @@ @media screen and (max-width: $size) { @content; } } @mixin larger-than($size) { - @media screen and (min-width: $size) { @content; } + @media screen and (min-width: ($size + 1)) { @content; } } @mixin between($min, $max) { - @media screen and (min-width: $min) and (max-width: $max) { @content; } + @media screen and (min-width: ($min + 1)) and (max-width: $max) { @content; } } // Padding shorthand using logical operators to better support RTL. diff --git a/tests/Auth/LdapTest.php b/tests/Auth/LdapTest.php index 9a00c983a..d1f128a50 100644 --- a/tests/Auth/LdapTest.php +++ b/tests/Auth/LdapTest.php @@ -166,6 +166,26 @@ class LdapTest extends TestCase $this->assertDatabaseHas('users', ['email' => $this->mockUser->email, 'email_confirmed' => false, 'external_auth_id' => $ldapDn]); } + public function test_login_works_when_ldap_server_does_not_provide_a_cn_value() + { + $ldapDn = 'cn=test-user,dc=test' . config('services.ldap.base_dn'); + + $this->commonLdapMocks(1, 1, 1, 2, 1); + $this->mockLdap->shouldReceive('searchAndGetEntries')->times(1) + ->with($this->resourceId, config('services.ldap.base_dn'), \Mockery::type('string'), \Mockery::type('array')) + ->andReturn(['count' => 1, 0 => [ + 'dn' => $ldapDn, + 'mail' => [$this->mockUser->email], + ]]); + + $resp = $this->mockUserLogin(); + $resp->assertRedirect('/'); + $this->assertDatabaseHas('users', [ + 'name' => 'test-user', + 'email' => $this->mockUser->email, + ]); + } + public function test_a_custom_uid_attribute_can_be_specified_and_is_used_properly() { config()->set(['services.ldap.id_attribute' => 'my_custom_id']);