Skip to content

Commit ba9cb59

Browse files
committed
Merge branch 'master' into release
2 parents d00ac2f + 632cb71 commit ba9cb59

30 files changed

+934
-707
lines changed

.env.example.complete

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ STORAGE_S3_ENDPOINT=https://my-custom-s3-compatible.service.com:8001
134134
STORAGE_URL=false
135135

136136
# Authentication method to use
137-
# Can be 'standard', 'ldap' or 'saml2'
137+
# Can be 'standard', 'ldap', 'saml2' or 'oidc'
138138
AUTH_METHOD=standard
139139

140140
# Social authentication configuration
@@ -242,6 +242,7 @@ SAML2_GROUP_ATTRIBUTE=group
242242
SAML2_REMOVE_FROM_GROUPS=false
243243

244244
# OpenID Connect authentication configuration
245+
# Refer to https://www.bookstackapp.com/docs/admin/oidc-auth/
245246
OIDC_NAME=SSO
246247
OIDC_DISPLAY_NAME_CLAIMS=name
247248
OIDC_CLIENT_ID=null

.github/translators.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,3 +200,9 @@ sulfo :: Danish
200200
Raukze :: German
201201
zygimantus :: Lithuanian
202202
marinkaberg :: Russian
203+
Vitaliy (gviabcua) :: Ukrainian
204+
mannycarreiro :: Portuguese
205+
Thiago Rafael Pereira de Carvalho (thiago.rafael) :: Portuguese, Brazilian
206+
Ken Roger Bolgnes (kenbo124) :: Norwegian Bokmal
207+
Nguyen Hung Phuong (hnwolf) :: Vietnamese
208+
Umut ERGENE (umutergene67) :: Turkish

.github/workflows/phpunit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636

3737
- name: Start Database
3838
run: |
39-
sudo /etc/init.d/mysql start
39+
sudo systemctl start mysql
4040
4141
- name: Setup Database
4242
run: |

.github/workflows/test-migrations.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636

3737
- name: Start MySQL
3838
run: |
39-
sudo /etc/init.d/mysql start
39+
sudo systemctl start mysql
4040
4141
- name: Create database & user
4242
run: |

app/Auth/UserRepo.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,16 @@ public function getAllUsers(): Collection
6363

6464
/**
6565
* Get all the users with their permissions in a paginated format.
66+
* Note: Due to the use of email search this should only be used when
67+
* user is assumed to be trusted. (Admin users).
68+
* Email search can be abused to extract email addresses.
6669
*/
6770
public function getAllUsersPaginatedAndSorted(int $count, array $sortData): LengthAwarePaginator
6871
{
6972
$sort = $sortData['sort'];
7073

7174
$query = User::query()->select(['*'])
72-
->withLastActivityAt()
75+
->scopes(['withLastActivityAt'])
7376
->with(['roles', 'avatar'])
7477
->withCount('mfaValues')
7578
->orderBy($sort, $sortData['order']);

app/Http/Controllers/Api/SearchApiController.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44

55
use BookStack\Entities\Models\Entity;
66
use BookStack\Entities\Tools\SearchOptions;
7+
use BookStack\Entities\Tools\SearchResultsFormatter;
78
use BookStack\Entities\Tools\SearchRunner;
89
use Illuminate\Http\Request;
910

1011
class SearchApiController extends ApiController
1112
{
1213
protected $searchRunner;
14+
protected $resultsFormatter;
1315

1416
protected $rules = [
1517
'all' => [
@@ -19,9 +21,10 @@ class SearchApiController extends ApiController
1921
],
2022
];
2123

22-
public function __construct(SearchRunner $searchRunner)
24+
public function __construct(SearchRunner $searchRunner, SearchResultsFormatter $resultsFormatter)
2325
{
2426
$this->searchRunner = $searchRunner;
27+
$this->resultsFormatter = $resultsFormatter;
2528
}
2629

2730
/**
@@ -45,16 +48,22 @@ public function all(Request $request)
4548
$count = min(intval($request->get('count', '0')) ?: 20, 100);
4649

4750
$results = $this->searchRunner->searchEntities($options, 'all', $page, $count);
51+
$this->resultsFormatter->format($results['results']->all(), $options);
4852

4953
/** @var Entity $result */
5054
foreach ($results['results'] as $result) {
5155
$result->setVisible([
5256
'id', 'name', 'slug', 'book_id',
5357
'chapter_id', 'draft', 'template',
5458
'created_at', 'updated_at',
55-
'tags', 'type',
59+
'tags', 'type', 'preview_html', 'url',
5660
]);
5761
$result->setAttribute('type', $result->getType());
62+
$result->setAttribute('url', $result->getUrl());
63+
$result->setAttribute('preview_html', [
64+
'name' => (string) $result->getAttribute('preview_name'),
65+
'content' => (string) $result->getAttribute('preview_content'),
66+
]);
5867
}
5968

6069
return response()->json([

app/Http/Controllers/UserSearchController.php

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace BookStack\Http\Controllers;
44

55
use BookStack\Auth\User;
6-
use Illuminate\Database\Eloquent\Builder;
76
use Illuminate\Http\Request;
87

98
class UserSearchController extends Controller
@@ -14,19 +13,27 @@ class UserSearchController extends Controller
1413
*/
1514
public function forSelect(Request $request)
1615
{
16+
$hasPermission = signedInUser() && (
17+
userCan('users-manage')
18+
|| userCan('restrictions-manage-own')
19+
|| userCan('restrictions-manage-all')
20+
);
21+
22+
if (!$hasPermission) {
23+
$this->showPermissionError();
24+
}
25+
1726
$search = $request->get('search', '');
18-
$query = User::query()->orderBy('name', 'desc')
27+
$query = User::query()
28+
->orderBy('name', 'asc')
1929
->take(20);
2030

2131
if (!empty($search)) {
22-
$query->where(function (Builder $query) use ($search) {
23-
$query->where('email', 'like', '%' . $search . '%')
24-
->orWhere('name', 'like', '%' . $search . '%');
25-
});
32+
$query->where('name', 'like', '%' . $search . '%');
2633
}
2734

28-
$users = $query->get();
29-
30-
return view('form.user-select-list', compact('users'));
35+
return view('form.user-select-list', [
36+
'users' => $query->get(),
37+
]);
3138
}
3239
}

0 commit comments

Comments
 (0)