Skip to content

Commit b62dab3

Browse files
committed
Merge branch 'development' into release
2 parents 262f863 + 9d15688 commit b62dab3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+342
-105
lines changed

.env.example.complete

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,11 @@ RECYCLE_BIN_LIFETIME=30
297297
# Maximum file size, in megabytes, that can be uploaded to the system.
298298
FILE_UPLOAD_SIZE_LIMIT=50
299299

300+
# Export Page Size
301+
# Primarily used to determine page size of PDF exports.
302+
# Can be 'a4' or 'letter'.
303+
EXPORT_PAGE_SIZE=a4
304+
300305
# Allow <script> tags in page content
301306
# Note, if set to 'true' the page editor may still escape scripts.
302307
ALLOW_CONTENT_SCRIPTS=false

.github/workflows/phpstan.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ name: phpstan
33
on:
44
push:
55
branches-ignore:
6-
- l10n_master
6+
- l10n_development
77
pull_request:
88
branches-ignore:
9-
- l10n_master
9+
- l10n_development
1010

1111
jobs:
1212
build:

.github/workflows/phpunit.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ name: phpunit
33
on:
44
push:
55
branches-ignore:
6-
- l10n_master
6+
- l10n_development
77
pull_request:
88
branches-ignore:
9-
- l10n_master
9+
- l10n_development
1010

1111
jobs:
1212
build:

.github/workflows/test-migrations.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ name: test-migrations
33
on:
44
push:
55
branches-ignore:
6-
- l10n_master
6+
- l10n_development
77
pull_request:
88
branches-ignore:
9-
- l10n_master
9+
- l10n_development
1010

1111
jobs:
1212
build:

app/Auth/Access/Oidc/OidcJwtSigningKey.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,11 @@ protected function loadFromPath(string $path)
6060
*/
6161
protected function loadFromJwkArray(array $jwk)
6262
{
63-
if ($jwk['alg'] !== 'RS256') {
64-
throw new OidcInvalidKeyException("Only RS256 keys are currently supported. Found key using {$jwk['alg']}");
63+
// 'alg' is optional for a JWK, but we will still attempt to validate if
64+
// it exists otherwise presume it will be compatible.
65+
$alg = $jwk['alg'] ?? null;
66+
if ($jwk['kty'] !== 'RSA' || !(is_null($alg) || $alg === 'RS256')) {
67+
throw new OidcInvalidKeyException("Only RS256 keys are currently supported. Found key using {$alg}");
6568
}
6669

6770
if (empty($jwk['use'])) {

app/Auth/Access/Oidc/OidcProviderSettings.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,9 @@ protected function loadSettingsFromIssuerDiscovery(ClientInterface $httpClient):
164164
protected function filterKeys(array $keys): array
165165
{
166166
return array_filter($keys, function (array $key) {
167-
return $key['kty'] === 'RSA' && $key['use'] === 'sig' && $key['alg'] === 'RS256';
167+
$alg = $key['alg'] ?? null;
168+
169+
return $key['kty'] === 'RSA' && $key['use'] === 'sig' && (is_null($alg) || $alg === 'RS256');
168170
});
169171
}
170172

app/Auth/User.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public function hasSystemRole(string $roleSystemName): bool
146146
*/
147147
public function attachDefaultRole(): void
148148
{
149-
$roleId = setting('registration-role');
149+
$roleId = intval(setting('registration-role'));
150150
if ($roleId && $this->roles()->where('id', '=', $roleId)->count() === 0) {
151151
$this->roles()->attach($roleId);
152152
}

app/Config/dompdf.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
* Configuration should be altered via the `.env` file or environment variables.
88
* Do not edit this file unless you're happy to maintain any changes yourself.
99
*/
10+
$dompdfPaperSizeMap = [
11+
'a4' => 'a4',
12+
'letter' => 'letter',
13+
];
1014

1115
return [
1216

@@ -150,7 +154,7 @@
150154
*
151155
* @see CPDF_Adapter::PAPER_SIZES for valid sizes ('letter', 'legal', 'A4', etc.)
152156
*/
153-
'default_paper_size' => 'a4',
157+
'default_paper_size' => $dompdfPaperSizeMap[env('EXPORT_PAGE_SIZE', 'a4')] ?? 'a4',
154158

155159
/**
156160
* The default font family.

app/Config/snappy.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,19 @@
77
* Configuration should be altered via the `.env` file or environment variables.
88
* Do not edit this file unless you're happy to maintain any changes yourself.
99
*/
10+
$snappyPaperSizeMap = [
11+
'a4' => 'A4',
12+
'letter' => 'Letter',
13+
];
1014

1115
return [
1216
'pdf' => [
1317
'enabled' => true,
1418
'binary' => file_exists(base_path('wkhtmltopdf')) ? base_path('wkhtmltopdf') : env('WKHTMLTOPDF', false),
1519
'timeout' => false,
1620
'options' => [
17-
'outline' => true,
21+
'outline' => true,
22+
'page-size' => $snappyPaperSizeMap[env('EXPORT_PAGE_SIZE', 'a4')] ?? 'A4',
1823
],
1924
'env' => [],
2025
],

app/Console/Commands/CreateAdmin.php

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
namespace BookStack\Console\Commands;
44

55
use BookStack\Auth\UserRepo;
6+
use BookStack\Exceptions\NotFoundException;
67
use Illuminate\Console\Command;
78
use Illuminate\Support\Facades\Validator;
9+
use Illuminate\Support\Str;
810
use Illuminate\Validation\Rules\Password;
911
use Illuminate\Validation\Rules\Unique;
1012
use Symfony\Component\Console\Command\Command as SymfonyCommand;
@@ -19,7 +21,8 @@ class CreateAdmin extends Command
1921
protected $signature = 'bookstack:create-admin
2022
{--email= : The email address for the new admin user}
2123
{--name= : The name of the new admin user}
22-
{--password= : The password to assign to the new admin user}';
24+
{--password= : The password to assign to the new admin user}
25+
{--external-auth-id= : The external authentication system id for the new admin user (SAML2/LDAP/OIDC)}';
2326

2427
/**
2528
* The console command description.
@@ -42,28 +45,35 @@ public function __construct(UserRepo $userRepo)
4245
/**
4346
* Execute the console command.
4447
*
45-
* @throws \BookStack\Exceptions\NotFoundException
48+
* @throws NotFoundException
4649
*
4750
* @return mixed
4851
*/
4952
public function handle()
5053
{
51-
$details = $this->options();
54+
$details = $this->snakeCaseOptions();
5255

5356
if (empty($details['email'])) {
5457
$details['email'] = $this->ask('Please specify an email address for the new admin user');
5558
}
59+
5660
if (empty($details['name'])) {
5761
$details['name'] = $this->ask('Please specify a name for the new admin user');
5862
}
63+
5964
if (empty($details['password'])) {
60-
$details['password'] = $this->ask('Please specify a password for the new admin user (8 characters min)');
65+
if (empty($details['external_auth_id'])) {
66+
$details['password'] = $this->ask('Please specify a password for the new admin user (8 characters min)');
67+
} else {
68+
$details['password'] = Str::random(32);
69+
}
6170
}
6271

6372
$validator = Validator::make($details, [
64-
'email' => ['required', 'email', 'min:5', new Unique('users', 'email')],
65-
'name' => ['required', 'min:2'],
66-
'password' => ['required', Password::default()],
73+
'email' => ['required', 'email', 'min:5', new Unique('users', 'email')],
74+
'name' => ['required', 'min:2'],
75+
'password' => ['required_without:external_auth_id', Password::default()],
76+
'external_auth_id' => ['required_without:password'],
6777
]);
6878

6979
if ($validator->fails()) {
@@ -84,4 +94,14 @@ public function handle()
8494

8595
return SymfonyCommand::SUCCESS;
8696
}
97+
98+
protected function snakeCaseOptions(): array
99+
{
100+
$returnOpts = [];
101+
foreach ($this->options() as $key => $value) {
102+
$returnOpts[str_replace('-', '_', $key)] = $value;
103+
}
104+
105+
return $returnOpts;
106+
}
87107
}

0 commit comments

Comments
 (0)