This is an automated email from the ASF dual-hosted git repository. github-merge-queue[bot] pushed a commit to branch gh-readonly-queue/main/pr-9127-98c63374b7f3645aa6b103e01baff90b30ff1360 in repository https://gitbox.apache.org/repos/asf/texera.git
commit d108cc19fda36c7b8aa1b68dfc934c1c3563b99b Author: Meng Wang <[email protected]> AuthorDate: Sun Oct 25 02:37:21 2026 +0000 fix: strip the development forum's accounts and sessions from the Flarum seed (#9127) ### What changes were proposed in this PR? `bin/forum/flarum.sql` was dumped from a development forum and still held its member accounts, login sessions, visit logs with IP addresses, and an API key that the dashboard's forum sign-up sent. - `flarum.sql`: the three seeded accounts get placeholder emails (`@example.com`) and no password, so their posts stay but nobody can sign in as them. The sessions, the API key and the visit log are dropped, and the posts' IP addresses are cleared. - Sign-up without the key: the seed already allows open sign-up (`allow_sign_up = 1`), so the key only let `FlarumService.register` skip Flarum's CSRF check. The new `bin/extend.php` exempts the sign-up route instead (by default Flarum exempts only login), and both install scripts copy it into the forum. ### Any related issues, documentation, discussions? Closes #9126. Independent of #9005, which is under discussion in #9006. ### How was this PR tested? - `flarum.service.spec.ts` now checks that sign-up sends no `Authorization` header. It passes, and fails against the old service. - On Flarum 1.8.5 (the seed's version) with the cleaned seed: the seed imports, sign-up then login works with `extend.php`, sign-up is rejected by the CSRF check without it, and the seeded accounts cannot sign in. ### Was this PR authored or co-authored using generative AI tooling? Generated-by: Claude Code (claude-opus-5-5) --- bin/README.md | 2 +- bin/extend.php | 27 ++++++++++++++++++++++ bin/forum/flarum.sql | 7 ++---- bin/forum/macos-install.sh | 1 + bin/forum/ubuntu-install.sh | 1 + .../service/user/flarum/flarum.service.spec.ts | 2 +- .../service/user/flarum/flarum.service.ts | 12 ++++------ 7 files changed, 37 insertions(+), 15 deletions(-) diff --git a/bin/README.md b/bin/README.md index 7dd25dc35a..4bbe7c5cc4 100644 --- a/bin/README.md +++ b/bin/README.md @@ -85,5 +85,5 @@ binary `NOTICE`/`LICENSE` files (`audit_jar_licenses.py`, | `pylsp/` | Dockerized Python language server used by the UDF editor. | | `y-websocket-server/` | Dockerized Yjs websocket server backing collaborative editing. | | `forum/` | Flarum-based community forum setup (install scripts and seed SQL). | -| `config.php`, `.htaccess` | Flarum runtime config and Apache rewrite rules for the forum. | +| `config.php`, `extend.php`, `.htaccess` | Flarum runtime config, extenders, and Apache rewrite rules for the forum. | | `litellm-config.yaml` | LiteLLM proxy configuration for AI features. | diff --git a/bin/extend.php b/bin/extend.php new file mode 100644 index 0000000000..11328a914b --- /dev/null +++ b/bin/extend.php @@ -0,0 +1,27 @@ +<?php +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +use Flarum\Extend; + +// The Texera dashboard signs users up to the forum through Flarum's API +// (FlarumService.register). Flarum exempts only its login route from CSRF +// checks, so exempt the sign-up route too. Whether anyone may sign up is still +// decided by the forum's allow_sign_up setting. +return [ + (new Extend\Csrf())->exemptRoute('users.create'), +]; diff --git a/bin/forum/flarum.sql b/bin/forum/flarum.sql index 743b730eac..857ce2211a 100644 --- a/bin/forum/flarum.sql +++ b/bin/forum/flarum.sql @@ -66,7 +66,6 @@ CREATE TABLE `access_tokens` ( LOCK TABLES `access_tokens` WRITE; /*!40000 ALTER TABLE `access_tokens` DISABLE KEYS */; -INSERT INTO `access_tokens` VALUES (1,'IgO67IH27IxOvvtgXvET4KHleDvf5TjEmGxSp14r',1,'2023-09-30 20:58:55','2023-09-30 20:58:55','session_remember',NULL,NULL,NULL),(3,'4r7sjWlKaN9uEH45Fh2AyDXtrMjficVfUUqJ8dhe',1,'2023-09-30 21:27:35','2023-09-30 21:27:35','session_remember',NULL,'::1','PostmanRuntime/7.32.3'),(4,'YCA69PvpLrUj8EKaRewSRPxzl16TjBPWOoO43EyG',1,'2023-09-30 21:27:57','2023-09-30 21:27:57','session_remember',NULL,'::1','Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/ [...] /*!40000 ALTER TABLE `access_tokens` ENABLE KEYS */; UNLOCK TABLES; @@ -98,7 +97,6 @@ CREATE TABLE `api_keys` ( LOCK TABLES `api_keys` WRITE; /*!40000 ALTER TABLE `api_keys` DISABLE KEYS */; -INSERT INTO `api_keys` VALUES ('hdebsyxiigyklxgsqivyswwiisohzlnezzzzzzzz',1,NULL,NULL,NULL,'2023-09-30 21:19:35','2023-10-01 04:14:27'); /*!40000 ALTER TABLE `api_keys` ENABLE KEYS */; UNLOCK TABLES; @@ -187,7 +185,6 @@ CREATE TABLE `discussion_views` ( LOCK TABLES `discussion_views` WRITE; /*!40000 ALTER TABLE `discussion_views` DISABLE KEYS */; -INSERT INTO `discussion_views` VALUES (1,4,5,'128.195.14.114','2024-01-09 00:41:35'),(6,NULL,5,'128.195.14.114','2024-01-09 03:15:01'); /*!40000 ALTER TABLE `discussion_views` ENABLE KEYS */; UNLOCK TABLES; @@ -720,7 +717,7 @@ CREATE TABLE `posts` ( LOCK TABLES `posts` WRITE; /*!40000 ALTER TABLE `posts` DISABLE KEYS */; -INSERT INTO `posts` VALUES (2,2,1,'2023-10-09 19:31:56',1,'comment','<t><p>idk</p></t>',NULL,NULL,NULL,NULL,'::1',0,1,0,0),(3,3,1,'2023-10-09 19:46:22',1,'comment','<r><p><STRONG><s>**</s>sxxbnsb nxsbxsxnsx<e>**</e></STRONG></p></r>',NULL,NULL,NULL,NULL,'::1',0,1,0,1),(4,3,2,'2023-10-09 19:46:54',1,'comment','<t><p>fjyfj</p></t>',NULL,NULL,NULL,NULL,'::1',0,1,0,1),(5,3,3,'2023-10-09 19:47:12',1,'comment','<r> <p><USERMENTION displayname=\"myAdmin\" id=\"1\">@myAdmin</USERMENTION></p> \n< [...] +INSERT INTO `posts` VALUES (2,2,1,'2023-10-09 19:31:56',1,'comment','<t><p>idk</p></t>',NULL,NULL,NULL,NULL,NULL,0,1,0,0),(3,3,1,'2023-10-09 19:46:22',1,'comment','<r><p><STRONG><s>**</s>sxxbnsb nxsbxsxnsx<e>**</e></STRONG></p></r>',NULL,NULL,NULL,NULL,NULL,0,1,0,1),(4,3,2,'2023-10-09 19:46:54',1,'comment','<t><p>fjyfj</p></t>',NULL,NULL,NULL,NULL,NULL,0,1,0,1),(5,3,3,'2023-10-09 19:47:12',1,'comment','<r> <p><USERMENTION displayname=\"myAdmin\" id=\"1\">@myAdmin</USERMENTION></p> \n</r> [...] /*!40000 ALTER TABLE `posts` ENABLE KEYS */; UNLOCK TABLES; @@ -932,7 +929,7 @@ CREATE TABLE `users` ( LOCK TABLES `users` WRITE; /*!40000 ALTER TABLE `users` DISABLE KEYS */; -INSERT INTO `users` VALUES (1,'myAdmin',NULL,'[email protected]',1,'$2a$10$0raoWm.MtGloDa95/CDgne54rX9uoa4RlmeoCA.ce9V1axfIHECSK',NULL,NULL,'2023-09-30 20:58:55','2024-01-09 03:24:06',NULL,'2023-10-17 03:07:23',3,49,'2023-10-16 06:52:14',NULL,NULL,NULL,0),(4,'[email protected]',NULL,'[email protected]',1,'$2a$10$63ISJ9VtBtA7R33QqNWLxeqb9Qqg97nq6D8E4sSAfIiquLcSO9XHC',NULL,NULL,NULL,'2024-01-09 00:51:18',NULL,NULL,1,1,NULL,NULL,NULL,NULL,0),(6,'[email protected]',NULL,'[email protected]', [...] +INSERT INTO `users` VALUES (1,'myAdmin',NULL,'[email protected]',1,'',NULL,NULL,'2023-09-30 20:58:55','2024-01-09 03:24:06',NULL,'2023-10-17 03:07:23',3,49,'2023-10-16 06:52:14',NULL,NULL,NULL,0),(4,'user4',NULL,'[email protected]',1,'',NULL,NULL,NULL,'2024-01-09 00:51:18',NULL,NULL,1,1,NULL,NULL,NULL,NULL,0),(6,'user6',NULL,'[email protected]',1,'',NULL,NULL,NULL,'2024-01-09 02:54:23',NULL,'2024-01-09 02:55:22',0,0,NULL,NULL,NULL,NULL,0); /*!40000 ALTER TABLE `users` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; diff --git a/bin/forum/macos-install.sh b/bin/forum/macos-install.sh index f38b0b972d..a33002228c 100755 --- a/bin/forum/macos-install.sh +++ b/bin/forum/macos-install.sh @@ -29,6 +29,7 @@ composer create-project flarum/flarum /opt/homebrew/var/www/flarum composer require --working-dir=/opt/homebrew/var/www/flarum michaelbelgium/flarum-discussion-views composer require --working-dir=/opt/homebrew/var/www/flarum fof/byobu:"*" cp config.php /opt/homebrew/var/www/flarum/config.php +cp extend.php /opt/homebrew/var/www/flarum/extend.php cp .htaccess /opt/homebrew/var/www/flarum/public/.htaccess # Database Configuration diff --git a/bin/forum/ubuntu-install.sh b/bin/forum/ubuntu-install.sh index e4d7c11952..bd96434507 100755 --- a/bin/forum/ubuntu-install.sh +++ b/bin/forum/ubuntu-install.sh @@ -32,6 +32,7 @@ composer create-project flarum/flarum /opt/flarum composer require --working-dir=/opt/flarum michaelbelgium/flarum-discussion-views composer require --working-dir=/opt/flarum fof/byobu:"*" sudo cp bin/config.php /opt/flarum/config.php +sudo cp bin/extend.php /opt/flarum/extend.php sudo cp bin/.htaccess /opt/flarum/public/.htaccess sudo chown -R www-data:www-data /opt/flarum sudo mysql -u root -p < sql/flarum.sql diff --git a/frontend/src/app/dashboard/service/user/flarum/flarum.service.spec.ts b/frontend/src/app/dashboard/service/user/flarum/flarum.service.spec.ts index 76ac6a0f0e..b8754dee8b 100644 --- a/frontend/src/app/dashboard/service/user/flarum/flarum.service.spec.ts +++ b/frontend/src/app/dashboard/service/user/flarum/flarum.service.spec.ts @@ -58,7 +58,7 @@ describe("FlarumService", () => { email: "[email protected]", password: "secret-token", }); - expect(req.request.headers.get("Authorization")).toContain("Token "); + expect(req.request.headers.has("Authorization")).toBe(false); req.flush({}); }); diff --git a/frontend/src/app/dashboard/service/user/flarum/flarum.service.ts b/frontend/src/app/dashboard/service/user/flarum/flarum.service.ts index 3e2722621b..98da83eaca 100644 --- a/frontend/src/app/dashboard/service/user/flarum/flarum.service.ts +++ b/frontend/src/app/dashboard/service/user/flarum/flarum.service.ts @@ -32,15 +32,11 @@ export class FlarumService { register() { const user = this.userService.getCurrentUser(); - return this.http.post( - "forum/api/users", - { - data: { - attributes: { username: user!.email.split("@")[0] + user!.uid, email: user!.email, password: user!.googleId }, - }, + return this.http.post("forum/api/users", { + data: { + attributes: { username: user!.email.split("@")[0] + user!.uid, email: user!.email, password: user!.googleId }, }, - { headers: { Authorization: "Token hdebsyxiigyklxgsqivyswwiisohzlnezzzzzzzz;userId=1" } } - ); + }); } auth() {
