Skip to content

Commit e86a909

Browse files
committed
Merge branch 'development' into release
2 parents 5d08f7c + b191d8f commit e86a909

File tree

459 files changed

+7335
-4492
lines changed

Some content is hidden

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

459 files changed

+7335
-4492
lines changed

.env.example.complete

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ OIDC_USER_TO_GROUPS=false
273273
OIDC_GROUPS_CLAIM=groups
274274
OIDC_REMOVE_FROM_GROUPS=false
275275
OIDC_EXTERNAL_ID_CLAIM=sub
276+
OIDC_END_SESSION_ENDPOINT=false
276277

277278
# Disable default third-party services such as Gravatar and Draw.IO
278279
# Service-specific options will override this option

.github/translators.txt

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ Alexander Predl (Harveyhase68) :: German
177177
Rem (Rem9000) :: Dutch
178178
Michał Stelmach (stelmach-web) :: Polish
179179
arniom :: French
180-
REMOVED_USER :: French; Dutch; Turkish;
180+
REMOVED_USER :: French; Dutch; Portuguese, Brazilian; Portuguese; Turkish;
181181
林祖年 (contagion) :: Chinese Traditional
182182
Siamak Guodarzi (siamakgoudarzi88) :: Persian
183183
Lis Maestrelo (lismtrl) :: Portuguese, Brazilian
@@ -371,3 +371,18 @@ LameeQS :: Latvian
371371
Sorin T. (trimbitassorin) :: Romanian
372372
poesty :: Chinese Simplified
373373
balmag :: Hungarian
374+
Antti-Jussi Nygård (ajnyga) :: Finnish
375+
Eduard Ereza Martínez (Ereza) :: Catalan
376+
Jabir Lang (amar.almrad) :: Arabic
377+
Jaroslav Koblizek (foretix) :: Czech; French
378+
Wiktor Adamczyk (adamczyk.wiktor) :: Polish
379+
Abdulmajeed Alshuaibi (4Majeed) :: Arabic
380+
NotSmartZakk :: Czech
381+
HyoungMin Lee (ddokkaebi) :: Korean
382+
Dasferco :: Chinese Simplified
383+
Marcus Teräs (mteras) :: Finnish
384+
Serkan Yardim (serkanzz) :: Turkish
385+
Y (cnsr) :: Ukrainian
386+
ZY ZV (vy0b0x) :: Chinese Simplified
387+
diegobenitez :: Spanish
388+
Marc Hagen (MarcHagen) :: Dutch

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,5 @@ webpack-stats.json
2929
.phpunit.result.cache
3030
.DS_Store
3131
phpstan.neon
32-
esbuild-meta.json
32+
esbuild-meta.json
33+
.phpactor.json

app/Access/Controllers/ForgotPasswordController.php

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@
99

1010
class ForgotPasswordController extends Controller
1111
{
12-
/**
13-
* Create a new controller instance.
14-
*
15-
* @return void
16-
*/
1712
public function __construct()
1813
{
1914
$this->middleware('guest');
@@ -30,10 +25,6 @@ public function showLinkRequestForm()
3025

3126
/**
3227
* Send a reset link to the given user.
33-
*
34-
* @param \Illuminate\Http\Request $request
35-
*
36-
* @return \Illuminate\Http\RedirectResponse
3728
*/
3829
public function sendResetLinkEmail(Request $request)
3930
{
@@ -56,13 +47,13 @@ public function sendResetLinkEmail(Request $request)
5647
$message = trans('auth.reset_password_sent', ['email' => $request->get('email')]);
5748
$this->showSuccessNotification($message);
5849

59-
return back()->with('status', trans($response));
50+
return redirect('/password/email')->with('status', trans($response));
6051
}
6152

6253
// If an error was returned by the password broker, we will get this message
6354
// translated so we can notify a user of the problem. We'll redirect back
6455
// to where the users came from so they can attempt this process again.
65-
return back()->withErrors(
56+
return redirect('/password/email')->withErrors(
6657
['email' => trans($response)]
6758
);
6859
}

app/Access/Controllers/LoginController.php

Lines changed: 11 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3,42 +3,34 @@
33
namespace BookStack\Access\Controllers;
44

55
use BookStack\Access\LoginService;
6-
use BookStack\Access\SocialAuthService;
6+
use BookStack\Access\SocialDriverManager;
77
use BookStack\Exceptions\LoginAttemptEmailNeededException;
88
use BookStack\Exceptions\LoginAttemptException;
99
use BookStack\Facades\Activity;
1010
use BookStack\Http\Controller;
1111
use Illuminate\Http\RedirectResponse;
1212
use Illuminate\Http\Request;
13-
use Illuminate\Support\Facades\Auth;
1413
use Illuminate\Validation\ValidationException;
1514

1615
class LoginController extends Controller
1716
{
1817
use ThrottlesLogins;
1918

20-
protected SocialAuthService $socialAuthService;
21-
protected LoginService $loginService;
22-
23-
/**
24-
* Create a new controller instance.
25-
*/
26-
public function __construct(SocialAuthService $socialAuthService, LoginService $loginService)
27-
{
19+
public function __construct(
20+
protected SocialDriverManager $socialDriverManager,
21+
protected LoginService $loginService,
22+
) {
2823
$this->middleware('guest', ['only' => ['getLogin', 'login']]);
2924
$this->middleware('guard:standard,ldap', ['only' => ['login']]);
3025
$this->middleware('guard:standard,ldap,oidc', ['only' => ['logout']]);
31-
32-
$this->socialAuthService = $socialAuthService;
33-
$this->loginService = $loginService;
3426
}
3527

3628
/**
3729
* Show the application login form.
3830
*/
3931
public function getLogin(Request $request)
4032
{
41-
$socialDrivers = $this->socialAuthService->getActiveDrivers();
33+
$socialDrivers = $this->socialDriverManager->getActive();
4234
$authMethod = config('auth.method');
4335
$preventInitiation = $request->get('prevent_auto_init') === 'true';
4436

@@ -52,7 +44,7 @@ public function getLogin(Request $request)
5244
// Store the previous location for redirect after login
5345
$this->updateIntendedFromPrevious();
5446

55-
if (!$preventInitiation && $this->shouldAutoInitiate()) {
47+
if (!$preventInitiation && $this->loginService->shouldAutoInitiate()) {
5648
return view('auth.login-initiate', [
5749
'authMethod' => $authMethod,
5850
]);
@@ -101,15 +93,9 @@ public function login(Request $request)
10193
/**
10294
* Logout user and perform subsequent redirect.
10395
*/
104-
public function logout(Request $request)
96+
public function logout()
10597
{
106-
Auth::guard()->logout();
107-
$request->session()->invalidate();
108-
$request->session()->regenerateToken();
109-
110-
$redirectUri = $this->shouldAutoInitiate() ? '/login?prevent_auto_init=true' : '/';
111-
112-
return redirect($redirectUri);
98+
return redirect($this->loginService->logout());
11399
}
114100

115101
/**
@@ -200,7 +186,7 @@ protected function updateIntendedFromPrevious(): void
200186
{
201187
// Store the previous location for redirect after login
202188
$previous = url()->previous('');
203-
$isPreviousFromInstance = (strpos($previous, url('/')) === 0);
189+
$isPreviousFromInstance = str_starts_with($previous, url('/'));
204190
if (!$previous || !setting('app-public') || !$isPreviousFromInstance) {
205191
return;
206192
}
@@ -211,23 +197,11 @@ protected function updateIntendedFromPrevious(): void
211197
];
212198

213199
foreach ($ignorePrefixList as $ignorePrefix) {
214-
if (strpos($previous, url($ignorePrefix)) === 0) {
200+
if (str_starts_with($previous, url($ignorePrefix))) {
215201
return;
216202
}
217203
}
218204

219205
redirect()->setIntendedUrl($previous);
220206
}
221-
222-
/**
223-
* Check if login auto-initiate should be valid based upon authentication config.
224-
*/
225-
protected function shouldAutoInitiate(): bool
226-
{
227-
$socialDrivers = $this->socialAuthService->getActiveDrivers();
228-
$authMethod = config('auth.method');
229-
$autoRedirect = config('auth.auto_initiate');
230-
231-
return $autoRedirect && count($socialDrivers) === 0 && in_array($authMethod, ['oidc', 'saml2']);
232-
}
233207
}

app/Access/Controllers/OidcController.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ class OidcController extends Controller
1111
{
1212
protected OidcService $oidcService;
1313

14-
/**
15-
* OpenIdController constructor.
16-
*/
1714
public function __construct(OidcService $oidcService)
1815
{
1916
$this->oidcService = $oidcService;
@@ -63,4 +60,12 @@ public function callback(Request $request)
6360

6461
return redirect()->intended();
6562
}
63+
64+
/**
65+
* Log the user out then start the OIDC RP-initiated logout process.
66+
*/
67+
public function logout()
68+
{
69+
return redirect($this->oidcService->logout());
70+
}
6671
}

app/Access/Controllers/RegisterController.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use BookStack\Access\LoginService;
66
use BookStack\Access\RegistrationService;
7-
use BookStack\Access\SocialAuthService;
7+
use BookStack\Access\SocialDriverManager;
88
use BookStack\Exceptions\StoppedAuthenticationException;
99
use BookStack\Exceptions\UserRegistrationException;
1010
use BookStack\Http\Controller;
@@ -15,22 +15,22 @@
1515

1616
class RegisterController extends Controller
1717
{
18-
protected SocialAuthService $socialAuthService;
18+
protected SocialDriverManager $socialDriverManager;
1919
protected RegistrationService $registrationService;
2020
protected LoginService $loginService;
2121

2222
/**
2323
* Create a new controller instance.
2424
*/
2525
public function __construct(
26-
SocialAuthService $socialAuthService,
26+
SocialDriverManager $socialDriverManager,
2727
RegistrationService $registrationService,
2828
LoginService $loginService
2929
) {
3030
$this->middleware('guest');
3131
$this->middleware('guard:standard');
3232

33-
$this->socialAuthService = $socialAuthService;
33+
$this->socialDriverManager = $socialDriverManager;
3434
$this->registrationService = $registrationService;
3535
$this->loginService = $loginService;
3636
}
@@ -43,7 +43,7 @@ public function __construct(
4343
public function getRegister()
4444
{
4545
$this->registrationService->ensureRegistrationAllowed();
46-
$socialDrivers = $this->socialAuthService->getActiveDrivers();
46+
$socialDrivers = $this->socialDriverManager->getActive();
4747

4848
return view('auth.register', [
4949
'socialDrivers' => $socialDrivers,

app/Access/Controllers/ResetPasswordController.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function reset(Request $request)
6666
// redirect them back to where they came from with their error message.
6767
return $response === Password::PASSWORD_RESET
6868
? $this->sendResetResponse()
69-
: $this->sendResetFailedResponse($request, $response);
69+
: $this->sendResetFailedResponse($request, $response, $request->get('token'));
7070
}
7171

7272
/**
@@ -83,15 +83,15 @@ protected function sendResetResponse(): RedirectResponse
8383
/**
8484
* Get the response for a failed password reset.
8585
*/
86-
protected function sendResetFailedResponse(Request $request, string $response): RedirectResponse
86+
protected function sendResetFailedResponse(Request $request, string $response, string $token): RedirectResponse
8787
{
8888
// We show invalid users as invalid tokens as to not leak what
8989
// users may exist in the system.
9090
if ($response === Password::INVALID_USER) {
9191
$response = Password::INVALID_TOKEN;
9292
}
9393

94-
return redirect()->back()
94+
return redirect("/password/reset/{$token}")
9595
->withInput($request->only('email'))
9696
->withErrors(['email' => trans($response)]);
9797
}

app/Access/Controllers/Saml2Controller.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,9 @@
99

1010
class Saml2Controller extends Controller
1111
{
12-
protected Saml2Service $samlService;
13-
14-
/**
15-
* Saml2Controller constructor.
16-
*/
17-
public function __construct(Saml2Service $samlService)
18-
{
19-
$this->samlService = $samlService;
12+
public function __construct(
13+
protected Saml2Service $samlService
14+
) {
2015
$this->middleware('guard:saml2');
2116
}
2217

@@ -36,7 +31,12 @@ public function login()
3631
*/
3732
public function logout()
3833
{
39-
$logoutDetails = $this->samlService->logout(auth()->user());
34+
$user = user();
35+
if ($user->isGuest()) {
36+
return redirect('/login');
37+
}
38+
39+
$logoutDetails = $this->samlService->logout($user);
4040

4141
if ($logoutDetails['id']) {
4242
session()->flash('saml2_logout_request_id', $logoutDetails['id']);
@@ -64,7 +64,7 @@ public function metadata()
6464
public function sls()
6565
{
6666
$requestId = session()->pull('saml2_logout_request_id', null);
67-
$redirect = $this->samlService->processSlsResponse($requestId) ?? '/';
67+
$redirect = $this->samlService->processSlsResponse($requestId);
6868

6969
return redirect($redirect);
7070
}

app/Access/Controllers/SocialController.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function callback(Request $request, string $socialDriver)
7979
try {
8080
return $this->socialAuthService->handleLoginCallback($socialDriver, $socialUser);
8181
} catch (SocialSignInAccountNotUsed $exception) {
82-
if ($this->socialAuthService->driverAutoRegisterEnabled($socialDriver)) {
82+
if ($this->socialAuthService->drivers()->isAutoRegisterEnabled($socialDriver)) {
8383
return $this->socialRegisterCallback($socialDriver, $socialUser);
8484
}
8585

@@ -91,7 +91,7 @@ public function callback(Request $request, string $socialDriver)
9191
return $this->socialRegisterCallback($socialDriver, $socialUser);
9292
}
9393

94-
return redirect()->back();
94+
return redirect('/');
9595
}
9696

9797
/**
@@ -114,7 +114,7 @@ protected function socialRegisterCallback(string $socialDriver, SocialUser $soci
114114
{
115115
$socialUser = $this->socialAuthService->handleRegistrationCallback($socialDriver, $socialUser);
116116
$socialAccount = $this->socialAuthService->newSocialAccount($socialDriver, $socialUser);
117-
$emailVerified = $this->socialAuthService->driverAutoConfirmEmailEnabled($socialDriver);
117+
$emailVerified = $this->socialAuthService->drivers()->isAutoConfirmEmailEnabled($socialDriver);
118118

119119
// Create an array of the user data to create a new user instance
120120
$userData = [

0 commit comments

Comments
 (0)