diff --git a/nginx.conf b/nginx.conf
index 12fcf68360..85b176b01b 100644
--- a/nginx.conf
+++ b/nginx.conf
@@ -129,7 +129,7 @@ server {
rewrite admin/api/(.*) /admin/api/index.php last;
# Administration pages
- rewrite admin/(attachments|backup|category|comments|configuration|elasticsearch|export|faq|faqs|forms|glossary|group|import|instance|instances|media-browser|news|password|questions|session-keep-alive|statistics|sticky-faqs|stopwords|system|tags|update|user) /admin/front.php last;
+ rewrite admin/(attachments|backup|category|comments|configuration|elasticsearch|export|faq|faqs|forms|glossary|group|import|instance|instances|logout|media-browser|news|password|questions|session-keep-alive|statistics|sticky-faqs|stopwords|system|tags|update|user) /admin/front.php last;
# REST API v3.0 and v3.1
rewrite ^api/v3\.[01]/(.*) /api/index.php last;
diff --git a/phpmyfaq/.htaccess b/phpmyfaq/.htaccess
index b25a8716fc..4e4d1c7e4f 100644
--- a/phpmyfaq/.htaccess
+++ b/phpmyfaq/.htaccess
@@ -143,7 +143,8 @@ Header set Access-Control-Allow-Headers "Content-Type, Authorization"
# Administration API
RewriteRule ^admin/api/(.*) admin/api/index.php [L,QSA]
# Administration pages
- RewriteRule ^admin/(attachments|backup|category|comments|configuration|elasticsearch|export|faq|faqs|forms|glossary|group|import|instance|instances|media-browser|news|password|questions|session-keep-alive|statistics|sticky-faqs|stopwords|system|tags|update|user) admin/front.php [L,QSA]
+ RewriteRule ^admin/(attachments|backup|category|comments|configuration|elasticsearch|export|faq|faqs|forms|glossary|group|import|instance|instances|logout|media-browser|news|password|questions|session-keep-alive|statistics|sticky-faqs|stopwords|system|tags|update|user) admin/front.php [L,QSA]
+ #RewriteRule ^admin/(.*) admin/front.php [L,QSA]
# Private APIs
RewriteRule ^api/(autocomplete|bookmark/delete|bookmark/create|user/data/update|user/password/update|user/request-removal|user/remove-twofactor|contact|voting|register|captcha|share|comment/create|faq/create|question/create|webauthn/prepare|webauthn/register|webauthn/prepare-login|webauthn/login) api/index.php [L,QSA]
# Setup APIs
diff --git a/phpmyfaq/assets/templates/admin/header.twig b/phpmyfaq/assets/templates/admin/header.twig
index 5724c27f28..be5d3e92b6 100644
--- a/phpmyfaq/assets/templates/admin/header.twig
+++ b/phpmyfaq/assets/templates/admin/header.twig
@@ -80,7 +80,7 @@
- {{ msgLogout }}
+ {{ msgLogout }}
@@ -99,7 +99,7 @@
-
+
Dashboard
diff --git a/phpmyfaq/assets/templates/admin/index.twig b/phpmyfaq/assets/templates/admin/index.twig
index 337554af05..f57641dafd 100644
--- a/phpmyfaq/assets/templates/admin/index.twig
+++ b/phpmyfaq/assets/templates/admin/index.twig
@@ -80,7 +80,7 @@
- {{ msgLogout }}
+ {{ msgLogout }}
diff --git a/phpmyfaq/assets/templates/admin/session-keepalive.twig b/phpmyfaq/assets/templates/admin/session-keepalive.twig
index 11d1a53b6e..1f50d24890 100644
--- a/phpmyfaq/assets/templates/admin/session-keepalive.twig
+++ b/phpmyfaq/assets/templates/admin/session-keepalive.twig
@@ -23,7 +23,7 @@
const duration = expire - sessionStart;
if (duration <= 0) {
- parent.location.href = './index.php?action=logout&csrf={{ csrfToken }}';
+ parent.location.href = './logout?csrf={{ csrfToken }}';
return;
}
diff --git a/phpmyfaq/src/admin-routes.php b/phpmyfaq/src/admin-routes.php
index e9a544adc2..9675d4cfd7 100644
--- a/phpmyfaq/src/admin-routes.php
+++ b/phpmyfaq/src/admin-routes.php
@@ -17,6 +17,7 @@
use phpMyFAQ\Controller\Administration\AdminLogController;
use phpMyFAQ\Controller\Administration\AttachmentsController;
+use phpMyFAQ\Controller\Administration\AuthenticationController;
use phpMyFAQ\Controller\Administration\BackupController;
use phpMyFAQ\Controller\Administration\CategoryController;
use phpMyFAQ\Controller\Administration\CommentsController;
@@ -55,6 +56,11 @@
'controller' => [AttachmentsController::class, 'index'],
'methods' => 'GET'
],
+ 'admin.auth.logout' => [
+ 'path' => '/logout',
+ 'controller' => [AuthenticationController::class, 'logout'],
+ 'methods' => 'GET'
+ ],
'admin.backup' => [
'path' => '/backup',
'controller' => [BackupController::class, 'index'],
diff --git a/phpmyfaq/src/phpMyFAQ/Controller/Administration/AuthenticationController.php b/phpmyfaq/src/phpMyFAQ/Controller/Administration/AuthenticationController.php
new file mode 100644
index 0000000000..67038f2151
--- /dev/null
+++ b/phpmyfaq/src/phpMyFAQ/Controller/Administration/AuthenticationController.php
@@ -0,0 +1,40 @@
+userIsAuthenticated();
+
+ $redirect = new RedirectResponse('./');
+
+ $csrfToken = Filter::filterVar($request->get('csrf'), FILTER_SANITIZE_SPECIAL_CHARS);
+ if (!Token::getInstance($this->container->get('session'))->verifyToken('admin-logout', $csrfToken)) {
+ return $redirect->send();
+ }
+
+ $this->currentUser->deleteFromSession(true);
+ $ssoLogout = $this->configuration->get('security.ssoLogoutRedirect');
+ if ($this->configuration->get('security.ssoSupport') && !empty($ssoLogout)) {
+ $redirect->isRedirect($ssoLogout);
+ $redirect->send();
+ }
+
+ return $redirect->send();
+ }
+}