Skip to content

Commit 0f89566

Browse files
committed
Merge branch 'development' into release
2 parents 6c577ac + 57bdd83 commit 0f89566

File tree

325 files changed

+8255
-5884
lines changed

Some content is hidden

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

325 files changed

+8255
-5884
lines changed

.env.example.complete

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
# Each option is shown with it's default value.
44
# Do not copy this whole file to use as your '.env' file.
55

6+
# The details here only serve as a quick reference.
7+
# Please refer to the BookStack documentation for full details:
8+
# https://www.bookstackapp.com/docs/
9+
610
# Application environment
711
# Can be 'production', 'development', 'testing' or 'demo'
812
APP_ENV=production
@@ -79,6 +83,7 @@ MAIL_PORT=1025
7983
MAIL_USERNAME=null
8084
MAIL_PASSWORD=null
8185
MAIL_ENCRYPTION=null
86+
MAIL_VERIFY_SSL=true
8287

8388
# Command to use when email is sent via sendmail
8489
MAIL_SENDMAIL_COMMAND="/usr/sbin/sendmail -bs"
@@ -322,6 +327,13 @@ FILE_UPLOAD_SIZE_LIMIT=50
322327
# Can be 'a4' or 'letter'.
323328
EXPORT_PAGE_SIZE=a4
324329

330+
# Set path to wkhtmltopdf binary for PDF generation.
331+
# Can be 'false' or a path path like: '/home/bins/wkhtmltopdf'
332+
# When false, BookStack will attempt to find a wkhtmltopdf in the application
333+
# root folder then fall back to the default dompdf renderer if no binary exists.
334+
# Only used if 'ALLOW_UNTRUSTED_SERVER_FETCHING=true' which disables security protections.
335+
WKHTMLTOPDF=false
336+
325337
# Allow <script> tags in page content
326338
# Note, if set to 'true' the page editor may still escape scripts.
327339
ALLOW_CONTENT_SCRIPTS=false
@@ -372,4 +384,4 @@ LOG_FAILED_LOGIN_CHANNEL=errorlog_plain_webserver
372384
# IP address '146.191.42.4' would result in '146.191.x.x' being logged.
373385
# For the IPv6 address '2001:db8:85a3:8d3:1319:8a2e:370:7348' this would result as:
374386
# '2001:db8:85a3:8d3:x:x:x:x'
375-
IP_ADDRESS_PRECISION=4
387+
IP_ADDRESS_PRECISION=4

.github/translators.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,3 +320,10 @@ kostasdizas :: Greek
320320
Ricardo Schroeder (brownstone666) :: Portuguese, Brazilian
321321
Eitan MG (EitanMG) :: Hebrew
322322
Robin Flikkema (RobinFlikkema) :: Dutch
323+
Michal Gurcik (mgurcik) :: Slovak
324+
Pooyan Arab (pooyanarab) :: Persian
325+
Ochi Darma Putra (troke12) :: Indonesian
326+
H.-H. Peng (Hsins) :: Chinese Traditional
327+
Mosi Wang (mosiwang) :: Chinese Traditional
328+
骆言 (LawssssCat) :: Chinese Simplified
329+
Stickers Gaming Shøw (StickerSGSHOW) :: French

.github/workflows/lint-js.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: lint-js
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build:
7+
if: ${{ github.ref != 'refs/heads/l10n_development' }}
8+
runs-on: ubuntu-22.04
9+
steps:
10+
- uses: actions/checkout@v1
11+
12+
- name: Install NPM deps
13+
run: npm ci
14+
15+
- name: Run formatting check
16+
run: npm run lint

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
/vendor
22
/node_modules
3+
/.vscode
4+
/composer
35
Homestead.yaml
46
.env
57
.idea
@@ -21,8 +23,10 @@ yarn.lock
2123
nbproject
2224
.buildpath
2325
.project
26+
.nvmrc
2427
.settings/
2528
webpack-stats.json
2629
.phpunit.result.cache
2730
.DS_Store
28-
phpstan.neon
31+
phpstan.neon
32+
esbuild-meta.json

app/Auth/Access/EmailConfirmationService.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
class EmailConfirmationService extends UserTokenService
1010
{
11-
protected $tokenTable = 'email_confirmations';
12-
protected $expiryTime = 24;
11+
protected string $tokenTable = 'email_confirmations';
12+
protected int $expiryTime = 24;
1313

1414
/**
1515
* Create new confirmation for a user,

app/Auth/Access/Oidc/OidcIdToken.php

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,16 @@
44

55
class OidcIdToken
66
{
7-
/**
8-
* @var array
9-
*/
10-
protected $header;
11-
12-
/**
13-
* @var array
14-
*/
15-
protected $payload;
16-
17-
/**
18-
* @var string
19-
*/
20-
protected $signature;
7+
protected array $header;
8+
protected array $payload;
9+
protected string $signature;
10+
protected string $issuer;
11+
protected array $tokenParts = [];
2112

2213
/**
2314
* @var array[]|string[]
2415
*/
25-
protected $keys;
26-
27-
/**
28-
* @var string
29-
*/
30-
protected $issuer;
31-
32-
/**
33-
* @var array
34-
*/
35-
protected $tokenParts = [];
16+
protected array $keys;
3617

3718
public function __construct(string $token, string $issuer, array $keys)
3819
{
@@ -106,6 +87,14 @@ public function getAllClaims(): array
10687
return $this->payload;
10788
}
10889

90+
/**
91+
* Replace the existing claim data of this token with that provided.
92+
*/
93+
public function replaceClaims(array $claims): void
94+
{
95+
$this->payload = $claims;
96+
}
97+
10998
/**
11099
* Validate the structure of the given token and ensure we have the required pieces.
111100
* As per https://datatracker.ietf.org/doc/html/rfc7519#section-7.2.

app/Auth/Access/Oidc/OidcService.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
use BookStack\Exceptions\JsonDebugException;
1010
use BookStack\Exceptions\StoppedAuthenticationException;
1111
use BookStack\Exceptions\UserRegistrationException;
12+
use BookStack\Facades\Theme;
13+
use BookStack\Theming\ThemeEvents;
1214
use Illuminate\Support\Arr;
1315
use Illuminate\Support\Facades\Cache;
1416
use League\OAuth2\Client\OptionProvider\HttpBasicAuthOptionProvider;
@@ -21,24 +23,12 @@
2123
*/
2224
class OidcService
2325
{
24-
protected RegistrationService $registrationService;
25-
protected LoginService $loginService;
26-
protected HttpClient $httpClient;
27-
protected GroupSyncService $groupService;
28-
29-
/**
30-
* OpenIdService constructor.
31-
*/
3226
public function __construct(
33-
RegistrationService $registrationService,
34-
LoginService $loginService,
35-
HttpClient $httpClient,
36-
GroupSyncService $groupService
27+
protected RegistrationService $registrationService,
28+
protected LoginService $loginService,
29+
protected HttpClient $httpClient,
30+
protected GroupSyncService $groupService
3731
) {
38-
$this->registrationService = $registrationService;
39-
$this->loginService = $loginService;
40-
$this->httpClient = $httpClient;
41-
$this->groupService = $groupService;
4232
}
4333

4434
/**
@@ -226,6 +216,16 @@ protected function processAccessTokenCallback(OidcAccessToken $accessToken, Oidc
226216
$settings->keys,
227217
);
228218

219+
$returnClaims = Theme::dispatch(ThemeEvents::OIDC_ID_TOKEN_PRE_VALIDATE, $idToken->getAllClaims(), [
220+
'access_token' => $accessToken->getToken(),
221+
'expires_in' => $accessToken->getExpires(),
222+
'refresh_token' => $accessToken->getRefreshToken(),
223+
]);
224+
225+
if (!is_null($returnClaims)) {
226+
$idToken->replaceClaims($returnClaims);
227+
}
228+
229229
if ($this->config()['dump_user_details']) {
230230
throw new JsonDebugException($idToken->getAllClaims());
231231
}

app/Auth/Access/Saml2Service.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function logout(User $user): array
6767
$returnRoute,
6868
[],
6969
$user->email,
70-
null,
70+
session()->get('saml2_session_index'),
7171
true,
7272
Constants::NAMEID_EMAIL_ADDRESS
7373
);
@@ -118,6 +118,7 @@ public function processAcsResponse(?string $requestId, string $samlResponse): ?U
118118

119119
$attrs = $toolkit->getAttributes();
120120
$id = $toolkit->getNameId();
121+
session()->put('saml2_session_index', $toolkit->getSessionIndex());
121122

122123
return $this->processLoginCallback($id, $attrs);
123124
}

app/Auth/Access/UserInviteService.php

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

88
class UserInviteService extends UserTokenService
99
{
10-
protected $tokenTable = 'user_invites';
11-
protected $expiryTime = 336; // Two weeks
10+
protected string $tokenTable = 'user_invites';
11+
protected int $expiryTime = 336; // Two weeks
1212

1313
/**
1414
* Send an invitation to a user to sign into BookStack
1515
* Removes existing invitation tokens.
16-
*
17-
* @param User $user
1816
*/
1917
public function sendInvitation(User $user)
2018
{

app/Auth/Access/UserTokenService.php

Lines changed: 7 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -14,41 +14,29 @@ class UserTokenService
1414
{
1515
/**
1616
* Name of table where user tokens are stored.
17-
*
18-
* @var string
1917
*/
20-
protected $tokenTable = 'user_tokens';
18+
protected string $tokenTable = 'user_tokens';
2119

2220
/**
2321
* Token expiry time in hours.
24-
*
25-
* @var int
2622
*/
27-
protected $expiryTime = 24;
23+
protected int $expiryTime = 24;
2824

2925
/**
30-
* Delete all email confirmations that belong to a user.
31-
*
32-
* @param User $user
33-
*
34-
* @return mixed
26+
* Delete all tokens that belong to a user.
3527
*/
36-
public function deleteByUser(User $user)
28+
public function deleteByUser(User $user): void
3729
{
38-
return DB::table($this->tokenTable)
30+
DB::table($this->tokenTable)
3931
->where('user_id', '=', $user->id)
4032
->delete();
4133
}
4234

4335
/**
44-
* Get the user id from a token, while check the token exists and has not expired.
45-
*
46-
* @param string $token
36+
* Get the user id from a token, while checking the token exists and has not expired.
4737
*
4838
* @throws UserTokenNotFoundException
4939
* @throws UserTokenExpiredException
50-
*
51-
* @return int
5240
*/
5341
public function checkTokenAndGetUserId(string $token): int
5442
{
@@ -67,8 +55,6 @@ public function checkTokenAndGetUserId(string $token): int
6755

6856
/**
6957
* Creates a unique token within the email confirmation database.
70-
*
71-
* @return string
7258
*/
7359
protected function generateToken(): string
7460
{
@@ -82,10 +68,6 @@ protected function generateToken(): string
8268

8369
/**
8470
* Generate and store a token for the given user.
85-
*
86-
* @param User $user
87-
*
88-
* @return string
8971
*/
9072
protected function createTokenForUser(User $user): string
9173
{
@@ -102,10 +84,6 @@ protected function createTokenForUser(User $user): string
10284

10385
/**
10486
* Check if the given token exists.
105-
*
106-
* @param string $token
107-
*
108-
* @return bool
10987
*/
11088
protected function tokenExists(string $token): bool
11189
{
@@ -115,12 +93,8 @@ protected function tokenExists(string $token): bool
11593

11694
/**
11795
* Get a token entry for the given token.
118-
*
119-
* @param string $token
120-
*
121-
* @return object|null
12296
*/
123-
protected function getEntryByToken(string $token)
97+
protected function getEntryByToken(string $token): ?stdClass
12498
{
12599
return DB::table($this->tokenTable)
126100
->where('token', '=', $token)
@@ -129,10 +103,6 @@ protected function getEntryByToken(string $token)
129103

130104
/**
131105
* Check if the given token entry has expired.
132-
*
133-
* @param stdClass $tokenEntry
134-
*
135-
* @return bool
136106
*/
137107
protected function entryExpired(stdClass $tokenEntry): bool
138108
{

0 commit comments

Comments
 (0)