Commit Graph

672 Commits (main)

Author SHA1 Message Date
John Niang 0c4be85467
Set Java 21 as minimal version (#7451)
#### What type of PR is this?

/kind improvement
/area core
/milestone 2.21.x

#### What this PR does / why we need it:

This PR sets Java 21 as minimal version. After doing that, Halo can only run on Java 21 or newer version.

Fortunately, all plugins and themes won't be affected by the restriction.

> https://docs.gradle.org/current/userguide/toolchains.html#sec:release-flag-toolchain

#### Which issue(s) this PR fixes:

Fixes https://github.com/halo-dev/halo/issues/6867

#### Does this PR introduce a user-facing change?

```release-note
[Action Required] 更新最低运行环境为 Java 21
```
2025-05-20 02:05:25 +00:00
John Niang 1520188aac
Merge pull request #7441 from liuyiwuqing/added-search-for-users-by-email
Add support for querying users by email
2025-05-20 00:24:17 +08:00
John Niang d64f01d0d5
Fix unit test due to dependency update 2025-05-19 18:04:02 +08:00
John Niang 0dd1e13e82
Fix the problem of not resolving git properties
See https://github.com/n0mer/gradle-git-properties/issues/242 for more
2025-05-19 17:42:40 +08:00
John Niang e6f753bb5d
Refactor dependencies and plugins with version catelog 2025-05-19 16:05:56 +08:00
John Niang 7eadf7a889
Refactor processResources with creating a new copy task (#7446)
#### What type of PR is this?

/kind improvement
/area core
/milestone 2.21.x

#### What this PR does / why we need it:

Defining `into` property in `processResources` task is not working, so I create a new copy task to process UI dist.

#### Does this PR introduce a user-facing change?

```release-note
None
```
2025-05-19 04:35:41 +00:00
liuyiwuqing b4a00f457a feat(user): 增加通过邮箱搜索用户功能 2025-05-16 19:50:34 +08:00
John Niang 3148fc3e31
Merge pull request #7429 from JohnNiang/refactor/improve-failure-message-of-plugin
Show stack trace while failing to start plugin
2025-05-15 12:03:49 +08:00
John Niang b4ac91df20
Remove wrong cache of pattern matchers 2025-05-14 16:49:11 +08:00
John Niang b2848a683a
Show stack trace while failing to start plugin 2025-05-14 14:26:43 +08:00
John Niang 747ca05d90
Rearrange system initialization by phase (#7417)
#### What type of PR is this?

/kind improvement
/area core
/milestone 2.20.x

#### What this PR does / why we need it:

This PR refactors system initialization process using [SmartLifecycle](https://docs.spring.io/spring-framework/docs/6.2.x/javadoc-api/org/springframework/context/SmartLifecycle.html). All the initializations will run in the same thread sequentially and  complete before web server startup.

#### Which issue(s) this PR fixes:

Potentially fix https://github.com/halo-dev/halo/issues/6264

#### Does this PR introduce a user-facing change?

```release-note
None
```
2025-05-09 07:25:48 +00:00
John Niang c95d7b141b
Add support for redirection on logout (#7418)
#### What type of PR is this?

/kind improvement
/area core
/milestone 2.20.x

#### What this PR does / why we need it:

This PR adds support for redirection on logout. We can request <http://localhost:8090/logout?redirect_uri=/archives> with GET method, then click the logout to see the redirection.

#### Which issue(s) this PR fixes:

Fixes https://github.com/halo-dev/halo/issues/7401

#### Does this PR introduce a user-facing change?

```release-note
登出页面支持自定义重定向
```
2025-05-09 07:15:49 +00:00
John Niang 8a68a59ea5
Fix potential twice theme route handler invocations (#7419)
#### What type of PR is this?

/kind bug
/area core
/milestone 2.20.x

#### What this PR does / why we need it:

1. This PR removes duplicate invocations while resolving handler functions of theme.
2. Throw NotFoundException while post was not found.

#### Which issue(s) this PR fixes:

Fixes https://github.com/halo-dev/halo/issues/7409

#### Does this PR introduce a user-facing change?

```release-note
修复访问不存在的分类或者文章页面时始终抛出异常的问题
```
2025-05-09 07:11:48 +00:00
困困鱼 5c8f86e917
feat:support sorting tags by post count (#7414)
#### What type of PR is this?

/kind feature

#### What this PR does / why we need it:

标签支持根据文章量排序

#### Does this PR introduce a user-facing change?

```release-note
标签支持根据文章量排序
```
2025-05-09 03:11:47 +00:00
John Niang 9c6ff9184e
Enable configuration properties by scanning (#7413)
#### What type of PR is this?

/kind improvement
/area core
/milestone 2.20.x

#### What this PR does / why we need it:

This PR change the enable method of configuration properties from `EnableConfigurationProperties` to `ConfigurationPropertiesScan`. This way can decouple the add of configuration properties.

See https://docs.spring.io/spring-boot/reference/features/external-config.html#features.external-config.typesafe-configuration-properties.enabling-annotated-types for more.

#### Does this PR introduce a user-facing change?

```release-note
None
```
2025-05-08 06:07:42 +00:00
John Niang caf172786c
Fix SwitchUserGrantedAuthority deserialization error (#7408)
#### What type of PR is this?

/kind bug
/area core
/milestone 2.20.x

#### What this PR does / why we need it:

This PR adds SwitchUserGrantedAuthorityMixin into HaloSecurityJackson2Module to fix the deserialization error.

See https://github.com/halo-dev/halo/issues/7406 for more.

#### Which issue(s) this PR fixes:

Fixes https://github.com/halo-dev/halo/issues/7406

#### Does this PR introduce a user-facing change?

```release-note
修复个人中心处可能出现登录设备查询异常的问题
```
2025-05-06 09:21:37 +00:00
John Niang 5a6f1ef641
Use Argon2 password encoder as default to remove password limit (#7407)
#### What type of PR is this?

/kind bug
/area core
/milestone 2.20.x

#### What this PR does / why we need it:

This PR makes Argon2 password encoder as default to remove password limit of 72.

Please note that there is no compatibility issue for old passwords.

#### Which issue(s) this PR fixes:

Fixes #7405 

#### Special notes for your reviewer:

1. Try to login as admin
2. Create a password having the length of 73 or more for a new user
3. See the result

#### Does this PR introduce a user-facing change?

```release-note
修复无法设置长度超过72个字符的密码的问题
```
2025-05-06 09:19:36 +00:00
guqing 0676551c77
feat: support configuring default locale in system setting (#7365)
#### What type of PR is this?
/kind feature
/area core
/milestone 2.20.x

#### What this PR does / why we need it:
系统设置新增首选语言设置

#### Which issue(s) this PR fixes:

Fixes #7047
Fixes https://github.com/halo-dev/halo/issues/7172
Fixes https://github.com/halo-dev/halo/issues/4086
Fixes https://github.com/halo-dev/halo/issues/7336

#### Does this PR introduce a user-facing change?

```release-note
系统设置新增首选语言设置
```
2025-04-27 04:04:50 +00:00
John Niang 23951de314
Support resolving javadoc for SpringDoc (#7390)
#### What type of PR is this?

/kind improvement
/area core
/milestone 2.20.x

#### What this PR does / why we need it:

This PR adds therapi-runtime-javadoc dependency and annotationProcessor for api and application projects. After doing that, SpringDoc will introspect Javadoc annotations and comments. See https://springdoc.org/#javadoc-support for more.

For support in plugin, just add an annotationProcessor like below:

```gradle
dependencies {
    implementation platform('run.halo.tools.platform:plugin:2.20.8-SNAPSHOT')
    compileOnly 'run.halo.app:api'

    annotationProcessor 'com.github.therapi:therapi-runtime-javadoc-scribe:0.13.0'
}
```

#### Does this PR introduce a user-facing change?

```release-note
None
```
2025-04-25 15:17:54 +00:00
John Niang ef7e197d98
Revert "Remove unused application startup steps buffer" (#7388)
Reverts halo-dev/halo#7364

Fixes https://github.com/halo-dev/halo/issues/7385

```release-note
None
```
2025-04-25 04:41:52 +00:00
FoxInField c2819f1f5a
Fix the problem of not being able to setup in OS without UTF-8 as default encoding (#7379)
#### What type of PR is this?

/kind bug

#### What this PR does / why we need it:

This PR manually set UTF-8 charset while loading YAML file to fix the problem "java.nio.charset.MalformedInputException: Input length = 1".

#### Which issue(s) this PR fixes:

Fixes https://github.com/halo-dev/halo/issues/6937
Fixes https://github.com/orgs/halo-dev/discussions/7375

#### Does this PR introduce a user-facing change?

```release-note
修复 Windows 下可能无法正常初始化的问题
```
2025-04-23 09:23:10 +00:00
John Niang ed50a0224d
Use secure random to generate metadat name instead of strong secure random (#7376)
### What type of PR is this?

/kind bug
/area core
/milestone 2.20.x

#### What this PR does / why we need it:

In PR <https://github.com/halo-dev/halo/pull/7371>, I used strong secure random to generate metadata name, but the random may cause system block in some specific environments. See https://github.com/orgs/lxware-dev/discussions/13#discussioncomment-12907298 for more.

So this PR revert the use of strong secure random.

#### Does this PR introduce a user-facing change?

```release-note
None
```
2025-04-22 13:11:07 +00:00
John Niang 05177544bd
Prevent data conflicts caused by database case sensitivity as possible (#7371)
#### What type of PR is this?

/kind improvement
/area core
/milestone 2.20.x

#### What this PR does / why we need it:

This PR use secure-strong SecureRandom to generate unpredictable metadata name. Meanwhile, the length of generate name suffix is increased to `8` and lower-case is to prevent data conflicts caused by database case sensitivity as possible.

Another improvement is using bounded-elastic thread to run the method `secureString()#nextAlphanumeric` because the method contains blocking operation, which might cause system block.

#### Does this PR introduce a user-facing change?

```release-note
None
```
2025-04-22 02:09:05 +00:00
John Niang a94b74cb38
Remove unused application startup steps buffer (#7364)
#### What type of PR is this?

/kind improvement
/area core
/milestone 2.20.x

#### What this PR does / why we need it:

This PR removes application startup steps buffer to reduce memory usage.

#### Does this PR introduce a user-facing change?

```release-note
None
```
2025-04-21 04:56:48 +00:00
John Niang 222e955a66
Disable CSRF check for PAT authentication (#7353)
#### What type of PR is this?

/kind improvement
/area core
/milestone 2.20.x

#### What this PR does / why we need it:

This PR disables CSRF check for PAT authentication because the authentication won't pass any cookies to server.

#### Does this PR introduce a user-facing change?

```release-note
None
```
2025-04-20 08:18:45 +00:00
John Niang e0b9c50d71
Support impersonating other users for super admin (#7351)
#### What type of PR is this?

/kind feature
/area core
/milestone 2.20.x

#### What this PR does / why we need it:

This PR adds support for impersonating other users for super admin.

1. Login as super admin
2. Request `POST /login/impersonate?username=xxx` and the current user should be xxx
3. Request `POST /logout/impersonate` and the current user should be super admin

#### Does this PR introduce a user-facing change?

```release-note
None
```
2025-04-20 08:04:46 +00:00
guqing 482436b2d0
feat: support route pattern /categories/{categorySlug}/{postSlug} for post access (#7331)
#### What type of PR is this?
/kind feature
/milestone 2.20.x

#### What this PR does / why we need it:
文章访问路径支持设置 `/categories/{categorySlug}/{postSlug}` 的形式

#### Which issue(s) this PR fixes:

Fixes #7330

#### Does this PR introduce a user-facing change?

```release-note
文章访问路径支持设置 `/categories/{categorySlug}/{postSlug}` 的形式
```
2025-04-20 07:56:45 +00:00
困困鱼 9225668f73
fix: resolve issue with categoryName parameter not working in postFinder.list() (#7350)
#### What type of PR is this?
/kind bug

#### What this PR does / why we need it:

修复 postFinder.list() 传参 categoryName 查询不到子类文章

#### Which issue(s) this PR fixes:

Fixes #7296 

#### Does this PR introduce a user-facing change?

```release-note
修复 postFinder.list() 的 categoryName 参数无效的问题
```
2025-04-18 10:38:27 +00:00
John Niang 3a5e4f82b4
Extract PAT operation with service (#7341)
#### What type of PR is this?

/kind improvement
/area core
/milestone 2.20.x

#### What this PR does / why we need it:

This PR refactors UserScopedPatHandlerImpl with PAT service to make PAT operations flexible.

#### Does this PR introduce a user-facing change?

```release-note
None
```
2025-04-14 10:22:12 +00:00
John Niang 067e3d58e1
Add support for sec:authorize attribute of Thymeleaf (#7322)
#### What type of PR is this?

/kind improvement
/area core
/area theme
/milestone 2.20.x

#### What this PR does / why we need it:

This PR adds support for sec:authorize attribute of Thymeleaf which is not supported yet. See https://github.com/halo-dev/halo/issues/7316 for more.

#### Which issue(s) this PR fixes:

Fixes https://github.com/halo-dev/halo/issues/7316

#### Does this PR introduce a user-facing change?

```release-note
完善主题模板判断用户角色等功能
```
2025-04-11 02:48:00 +00:00
John Niang fb7a09738a
Fix the repeat registration with the email already verified (#7323)
#### What type of PR is this?

/kind bug
/area core
/milestone 2.20.x

#### What this PR does / why we need it:

This PR fixes the repeat registration with the email already verified.

![Screenshot From 2025-04-02 16-33-22](https://github.com/user-attachments/assets/1caf0550-f80f-42e4-8db6-747ff1035f63)

#### Which issue(s) this PR fixes:

Fixes https://github.com/halo-dev/halo/issues/7308

#### Does this PR introduce a user-facing change?

```release-note
修复注册时未验证邮箱是否已被占用的问题
```
2025-04-02 10:25:54 +00:00
John Niang 2a6bedc73d
Fix the NPE while post content is null (#7321)
#### What type of PR is this?

/kind bug
/area core
/milestone 2.20.x

#### What this PR does / why we need it:

This PR fixes the NPE while post content is null. See https://github.com/halo-dev/halo/issues/7320 for more.

#### Which issue(s) this PR fixes:

Fixes https://github.com/halo-dev/halo/issues/7320

#### Does this PR introduce a user-facing change?

```release-note
修复通过接口创建文章可能导致无法发布和删除的问题
```
2025-04-02 08:07:54 +00:00
John Niang e2fd9ba60b
Support randomizing local attachment filename (#7301)
#### What type of PR is this?

/kind feature
/area core
/milestone 2.20.x

#### What this PR does / why we need it:

This PR allows users to upload local attachment always with a random filename to simply prevent resource leak.

Please see the configuration and the uploaded result below:

![image](https://github.com/user-attachments/assets/a479842a-9c8f-41d0-aab7-17ed35ba772a)

```json
{
  "spec": {
    "displayName": "halo.run-ykfswxmokpjopvkqwybghazloxeovgae.cer",
    "policyName": "attachment-policy-XVdDK",
    "ownerName": "admin",
    "mediaType": "application/pkix-cert",
    "size": 1803
  },
  "status": {
    "permalink": "/upload/random/halo.run-ykfswxmokpjopvkqwybghazloxeovgae.cer"
  },
  "apiVersion": "storage.halo.run/v1alpha1",
  "kind": "Attachment",
  "metadata": {
    "finalizers": [
      "attachment-manager"
    ],
    "name": "44b4c8de-0d3b-4bbb-acc2-4af50175a2b5",
    "annotations": {
      "storage.halo.run/local-relative-path": "upload/random/halo.run-ykfswxmokpjopvkqwybghazloxeovgae.cer",
      "storage.halo.run/uri": "/upload/random/halo.run-ykfswxmokpjopvkqwybghazloxeovgae.cer"
    },
    "version": 2,
    "creationTimestamp": "2025-03-18T15:53:11.817541483Z"
  }
}
```

#### Does this PR introduce a user-facing change?

```release-note
支持上传附件至本地时总是随机命名文件名
```
2025-03-22 15:37:27 +00:00
John Niang e142b90349
Add timeout for blocking Extension client (#7303)
#### What type of PR is this?

/kind bug
/area core
/milestone 2.20.x

#### What this PR does / why we need it:

This PR adds timeout for blocking Extension client to prevent system from blocking without any error.

#### Which issue(s) this PR fixes:

Recently, we have received several issues about getting stuck in creating menu items. Please refer to the key threaddump detail:

![image](https://github.com/user-attachments/assets/84892449-5f15-4981-a805-df30eeafcdba)

#### Does this PR introduce a user-facing change?

```release-note
None
```
2025-03-21 06:19:25 +00:00
guqing 60c20090ac fix: code style 2025-03-13 18:06:10 +08:00
guqing e64edc3610 chore: add exception information to log output when the plugin fails to start 2025-03-13 16:17:30 +08:00
guqing 5743cee598
Revert "refactor: modify plugin class loading order to follow parent delegation mechanism (#7258)" (#7290)
#### What type of PR is this?
/kind cleanup

#### What this PR does / why we need it:
撤回对插件类加载顺序的改动这可能导致破坏性更新

同时,不在考虑修改加载顺序问题,由于社区版和专业版引入的依赖不同插件无法以社区版为依赖基准保证功能在专业版也可用,举个例子:
1. 插件引入了 okhttp4 作为依赖,这可能是插件引入的依赖所附带的
2. 在社区版没有问题,插件开发者也是这么测试的
3. 但是在专业版中引入了 okhttp3 作为依赖,此时插件在专业版就不可用了因为插件依赖了 okhttp4 的功能

通过上述问题就导致了不可预知的问题

#### Does this PR introduce a user-facing change?

```release-note
撤回对插件类加载顺序的改动这可能导致破坏性更新
```
2025-03-13 04:33:07 +00:00
Ryan Wang 30c97d8ea6
feat: add favicon to login page (#7288)
#### What type of PR is this?

/area core
/kind improvement
/milestone 2.20.x

#### What this PR does / why we need it:

Add favicon to login page

#### Which issue(s) this PR fixes:

Fixes #7287 

#### Special notes for your reviewer:

#### Does this PR introduce a user-facing change?

```release-note
为登录相关的页面添加 Favicon
```
2025-03-13 02:57:05 +00:00
guqing 6e6bb42778
feat: allow theme preview for theme admins when preview is disabled (#7277)
#### What type of PR is this?
/kind feature
/area core
/milestone 2.20.x

#### What this PR does / why we need it:
支持禁用主题预览功能,但拥有主题管理权限的用户不受此功能影响

#### Which issue(s) this PR fixes:

Fixes #7204

#### Does this PR introduce a user-facing change?

```release-note
支持禁用主题预览功能,但拥有主题管理权限的用户不受此功能影响
```
2025-03-12 08:39:04 +00:00
John Niang fed80f26f2
Turn off logging of TemplateEngine (#7284)
#### What type of PR is this?

/kind bug
/area core
/milestone 2.20.x

#### What this PR does / why we need it:

This PR turns off the logging of TemplateEngine to prevent too many annoying and useless logs.

Please note that the TemplateExceptions won't be eat up because we have a global error handler to log them.

#### Which issue(s) this PR fixes:

Fixes https://github.com/halo-dev/halo/issues/4468

#### Special notes for your reviewer:

Steps to verify:
- Start Halo instance
- Execute command `ab -c 100 -n 10000 -H 'Accept: text/html' -H 'Cache-Control: no-cache' http://localhost:8090/` and then press `Ctrl + C` to stop the ab process.
- See the logs of Halo instance.

#### Does this PR introduce a user-facing change?

```release-note
解决日志中出现大量 InterruptedException 异常的问题
```
2025-03-11 06:35:02 +00:00
Ryan Wang 4ad97cd58e
feat: add support for disabling/enabling user accounts (#7273)
#### What type of PR is this?

/kind feature
/area ui
/milestone 2.20.x

#### What this PR does / why we need it:

Add support for disabling/enabling user accounts

<img width="1207" alt="image" src="https://github.com/user-attachments/assets/a298e6f7-21a1-4b1c-86c3-1064a136e28c" />

#### Which issue(s) this PR fixes:

Fixes https://github.com/halo-dev/halo/issues/7250

#### Special notes for your reviewer:

#### Does this PR introduce a user-facing change?

```release-note
支持在管理控制台禁用指定用户
```
2025-03-10 15:15:02 +00:00
John Niang ddbbe09c2d
Fix the pending problem of requesting console and uc pages in dev mode (#7281)
#### What type of PR is this?

/kind bug
/area core
/milestone 2.20.x

#### What this PR does / why we need it:

This PR fixes the pending problem of requesting console and ui pages in dev mode.

#### Which issue(s) this PR fixes:

Fixes https://github.com/halo-dev/halo/issues/7191

#### Special notes for your reviewer:

Steps to reproduce:

- Start ui projects with dev mode by executing command `make -C ui dev`.
- Run Halo instance in dev mode by executing command `./gradlew bootRun --args="--spring.profiles.active=dev"`.
- Try to request <http://localhost:8090/uc> and <http://localhost:8090/console>.
- Try to refresh page by hand and see the result

#### Does this PR introduce a user-facing change?

```release-note
修复开发模式下无法正常进入管理和个人中心页面的问题
```
2025-03-10 08:19:01 +00:00
guqing 2c4c876ef2
refactor: restrict author page access to users with post permission (#7279)
#### What type of PR is this?
/kind improvement
/area core
/milestone 2.20.x

#### What this PR does / why we need it:
仅对包含文章权限的用户生成作者页面

#### Which issue(s) this PR fixes:

Fixes #7202

#### Does this PR introduce a user-facing change?

```release-note
仅对包含文章权限的用户生成作者页面
```
2025-03-10 04:37:01 +00:00
guqing daec9ff7bb
feat: add image thumbnail support for single pages (#7276)
#### What type of PR is this?
/kind improvment
/area core
/milestone 2.20.x

#### What this PR does / why we need it:
为自定义页面的图片增加缩略图支持

<img width="1594" alt="image" src="https://github.com/user-attachments/assets/f317d73b-e515-4c3c-83e7-06ef55873a37" />

#### Which issue(s) this PR fixes:

Fixes #7232

#### Does this PR introduce a user-facing change?

```release-note
为自定义页面的图片增加缩略图支持
```
2025-03-08 14:13:00 +00:00
Takagi eeb707bd9f
fix: resolve file extension validation failure issue in editor uploads (#7275)
#### What type of PR is this?

/kind bug
/area core
/milestone 2.20.x

#### What this PR does / why we need it:

将获取文件名的代码由 `Part.name()` 改为 `FilePart.filename()`。`Part.name()` 在没有覆写 form 时可能无法正确获取到文件的客户端路径。

#### How to test it?

1. 在文章设置 - 附件存储策略 中,设置一个其他的附件存储策略。
2. 测试在富文本编辑器中上传文件是否报错文件类型与后缀不匹配的问题。

#### Which issue(s) this PR fixes:

Fixes #7274 

#### Does this PR introduce a user-facing change?
```release-note
解决在默认编辑器中上传文件失败的问题
```
2025-03-07 07:54:59 +00:00
guqing 1d8a25cd69
refactor: modify plugin class loading order to follow parent delegation mechanism (#7258)
#### What type of PR is this?
/kind improvement
/area core
/milestone 2.20.x

#### What this PR does / why we need it:
修改插件类加载顺序遵循双亲委派机制,以避免插件需要手动排除冲突类的问题

此 PR 的动力是:
1. 插件排除依赖复杂而麻烦
2. 尝试多次无法很好的通过工具实现这一点
3. 对于一些依赖如 kotlin 何 spring security oauth 等同一 JVM 只能加载一次(即不能再次从插件加载)且插件可能无法排除依赖或排除依赖后功能不正确如遇到链接错误等
4. 签名文件冲突等问题

resources 下的资源文件加载顺序还是插件优先,避免与 halo 同名文件不加载的问题

进过测试,插件依赖功能以及其他插件的功能不受影响,建议 Reviewer 再测试一遍

#### Does this PR introduce a user-facing change?

```release-note
调整插件类的加载顺序使其遵循双亲委派机制,替代原先的 Plugin -> Dependent Plugin -> Halo 加载顺序
```
2025-03-06 01:48:57 +00:00
John Niang 00c8cbb7bb
Enable Virtual Thread when running on JVM 21 (#7261)
#### What type of PR is this?

/kind improvement
/area core
/milestone 2.20.x

#### What this PR does / why we need it:

This PR enables Virtual Thread for instances running on JVM 21. This won't affect instances running on JVM 17.

References:
- https://spring.io/blog/2023/10/31/what-new-is-coming-in-reactor-core-3-6-0
- https://spring.io/blog/2022/10/11/embracing-virtual-threads
- https://docs.spring.io/spring-boot/3.4/reference/features/task-execution-and-scheduling.html

#### Does this PR introduce a user-facing change?

```release-note
None
```
2025-03-05 02:32:57 +00:00
guqing 8d9b2e6ee7
fix: move cache after doFinally to ensure effective concurrency control (#7257)
### What this PR does?
将 cache 移动到 doFinally 之后以确保并发控制有效,在这之前可能无法完全有效的控制并发


```release-note
None
```
2025-03-03 16:22:56 +00:00
edops973 8305822c09
Update deprecated default string function (#7239)
#### What type of PR is this?
/kind cleanup

#### What this PR does / why we need it:
Replaces deprecated functions (`String defaultString(final String str, final String nullDefault)`) with its recommended alternatives

See 29ccc7665f/src/main/java/org/apache/commons/lang3/StringUtils.java (L1635) for more.

#### Does this PR introduce a user-facing change?

```release-note
None
```
2025-02-26 10:12:54 +00:00
guqing 1491c5bb07
refactor: generate summaries only for content changes (#7200)
#### What type of PR is this?
/kind improvement
/area core
/milestone 2.20.x

#### What this PR does / why we need it:
自动生成摘要仅对内容变更时生效

see https://github.com/halo-dev/halo/issues/7193#issuecomment-2581699190 for more details

避免对资源造成浪费如 AI 摘要生成

#### Which issue(s) this PR fixes:

Fixes #7193

#### Does this PR introduce a user-facing change?

```release-note
自动生成摘要仅对内容发生变更时生效
```
2025-01-20 03:23:27 +00:00
guqing 3e3572e8a8
fix: failure to create notification templates in themes (#7199)
#### What type of PR is this?
/kind bug
/area core
/milestone 2.20.x

#### What this PR does / why we need it:
修复主题中声明的通知模板无法被创建的问题

#### Which issue(s) this PR fixes:

Fixes #7195

#### Does this PR introduce a user-facing change?

```release-note
修复主题中声明的通知模板无法被创建的问题
```
2025-01-20 03:21:40 +00:00
guqing be6f044a29
refactor: clear the template cache after uninstalling the theme (#7174)
#### What type of PR is this?
/kind improvement
/area core
/milestone 2.20.x

#### What this PR does / why we need it:
卸载主题之后清理模板缓存

此问题是 https://github.com/halo-dev/halo/pull/2970 的遗留问题

#### Does this PR introduce a user-facing change?

```release-note
None
```
2025-01-03 09:34:10 +00:00
guqing 24f8d7b571
fix: XSS vulnerability due to polyglot file type upload (#7149)
#### What type of PR is this?
/kind bug
/area core
/milestone 2.20.x

#### What this PR does / why we need it:
修复文件类型限制能通过混合文件类型绕过检测的问题

参考:https://github.com/halo-dev/halo/security/advisories/GHSA-99mc-ch53-pqh9

#### Does this PR introduce a user-facing change?

```release-note
修复文件类型限制能通过混合文件类型绕过检测的问题
```
2025-01-03 09:32:13 +00:00
cryptochecktool 0748ae4334
refactor: replace md5 with sha256 for commenter email hash (#7092)
#### What type of PR is this?

/kind feature
/kind improvement

#### What this PR does / why we need it:

本次PR对系统中用于电子邮件哈希的算法进行了升级。原先使用的是MD5算法,现在替换为了更安全的SHA-256算法。这一变更提高了数据的安全性,降低了电子邮件被破解的风险。

#### Which issue(s) this PR fixes:

未指定具体问题编号,但解决了潜在的安全隐患。

#### Special notes for your reviewer:

在替换哈希算法的过程中,我已经确保了代码的兼容性和性能。建议审查者在合并前进行全面的测试,以确保新算法的正确性和系统的稳定性。

#### Does this PR introduce a user-facing change?

```release-note
增强评论邮箱哈希算法(SHA256)
```
2024-12-09 01:23:32 +00:00
guqing ead667683c
feat: add system info getter for plugin (#7103)
#### What type of PR is this?
/kind improvement
/area core
/milestone 2.20.x

#### What this PR does / why we need it:
为插件提供 SystemInfoGetter 用于获取站点基本信息

站点标题描述和系统版本这些信息对于插件来说是很有必要的避免插件要直接查询 system ConfigMap 来获取,如 RSS 和 通知器扩展等插件都会需要用到

```json
{
  "title" : "guqing's blog",
  "subtitle" : "副标题",
  "logo" : "/upload/myavatar.png",
  "favicon" : "/upload/myavatar.png",
  "url" : "http://localhost:8090",
  "version" : {
    "majorVersion" : 2,
    "minorVersion" : 20,
    "normalVersion" : "2.20.10",
    "preRelease" : true,
    "publicApiStable" : true,
    "patchVersion" : 10,
    "preReleaseVersion" : "SNAPSHOT",
    "buildMetadata" : "",
    "stable" : false
  },
  "seo" : {
    "blockSpiders" : false,
    "keywords" : "keyword1,keyword2",
    "description" : "站点描述"
  },
  "locale" : "zh_CN_#Hans",
  "timeZone" : "Asia/Shanghai",
  "activatedThemeName" : "theme-earth"
}
```

#### Does this PR introduce a user-facing change?

```release-note
开发者相关:为插件提供 SystemInfoGetter 用于获取站点基本信息
```
2024-12-04 07:53:10 +00:00
guqing fef06edcd8
fix: optional plugin dependencies not working correctly (#7094)
#### What type of PR is this?
/kind bug
/area core
/milestone 2.20.x

#### What this PR does / why we need it:
修复可选插件依赖功能无法正常工作的问题

#### Special notes for your reviewer:

使用以下两个插件测试可选依赖:

[测试插件集合.zip](https://github.com/user-attachments/files/17989250/default.zip)

使用以下测试用例进行测试:

测试用例1:plugin-feed 插件提供 RSS 扩展功能

- **前置条件:**  
    安装并启用 `plugin-feed` 插件。
- **操作步骤:**  
    访问 `http://localhost:8090/feed/rss.xml`。
- **期望结果:**  
    返回 `plugin-feed` 提供的 RSS 内容。

---

测试用例 2: plugin-moments 扩展了 plugin-feed 的 RSS 功能(依赖于 plugin-feed)

- **前置条件:**  
    安装并启用 `plugin-feed` 和 `plugin-moments` 插件。
- **操作步骤:**  
    访问 `http://localhost:8090/feed/moments/rss.xml`。
- **期望结果:**  
    返回 `plugin-moments` 提供的 RSS 内容。

---

测试用例 3: plugin-feed 启用时安装 plugin-moments

- **前置条件:**  
    启用 `plugin-feed` 插件。
- **操作步骤:**
    1. 安装 `plugin-moments` 插件。
    2. 访问 `http://localhost:8090/feed/moments/rss.xml`。
- **期望结果:**  
    `plugin-moments` 提供的 RSS 路由可访问,并返回正确内容。

---

测试用例 4: plugin-feed 未启用时安装 plugin-moments

- **前置条件:**  
    未安装或未启用 `plugin-feed` 插件。
- **操作步骤:**
    1. 安装并启用 `plugin-moments` 插件。
    2. 访问 `http://localhost:8090/feed/moments/rss.xml`。
- **期望结果:**
    - `plugin-moments` 的 RSS 路由不可访问,返回 404。
    - `plugin-moments` 的其他功能正常运行。

---

测试用例 5: plugin-moments 启用后安装 plugin-feed

- **前置条件:**  
    已安装并启用 `plugin-moments` 插件。
- **操作步骤:**
    1. 安装并启用 `plugin-feed` 插件。
    2. 访问 `http://localhost:8090/feed/moments/rss.xml`。
- **期望结果:**  
    `plugin-moments` 提供的 RSS 路由可访问,并返回正确内容。

---

测试用例 6: 停止 plugin-feed 后验证 RSS 路由

- **前置条件:**  
    已启用 `plugin-feed` 和 `plugin-moments` 插件。
- **操作步骤:**
    1. 停止 `plugin-feed` 插件。
    2. 访问 `http://localhost:8090/feed/moments/rss.xml`。
- **期望结果:**
    - `plugin-feed` 停止成功。
    - `plugin-moments` 提供的 RSS 路由不可访问,返回 404。

---

测试用例 7: 重启 Halo 后验证可选依赖插件的启动顺序

- **前置条件:**  
    已启用 `plugin-feed` 和 `plugin-moments` 插件。
- **操作步骤:**
    1. 重启 Halo 服务。
    2. 访问 `http://localhost:8090/feed/moments/rss.xml`。
- **期望结果:**
    - `plugin-moments` 提供的 RSS 路由**始终可访问**。

---

测试用例 8: 必选依赖插件验证

- **场景 1: 安装 seo 插件时未安装应用市场**
    
    - **前置条件:**  
        未安装 `app-store-integration` 插件。
    - **操作步骤:**  
        安装 `plugin-seo` 插件。
    - **期望结果:**  
        提示需要先安装 `app-store-integration` 插件。
- **场景 2: 停止应用市场插件时 seo 插件仍启用**
    
    - **前置条件:**  
        已启用 `app-store-integration` 和 `plugin-seo` 插件。
    - **操作步骤:**  
        停止 `app-store-integration` 插件。
    - **期望结果:**  
        提示需要先停止 `plugin-seo` 插件。

#### Does this PR introduce a user-facing change?

```release-note
修复可选插件依赖功能无法正常工作的问题
```
2024-12-04 07:13:10 +00:00
guqing eb969122ff
perf: add caching for extension getter to enhance performance (#7102)
#### What type of PR is this?
/kind improvement
/area core
/milestone 2.20.x

#### What this PR does / why we need it:
为扩展获取增加缓存以提高网站整体性能

在此之前,每个请求都要经过很多过滤器,而一些过滤器会获取扩展因此导致频繁查询扩展和扩展点定义拖慢了速度

**测试情况**

初始化一个全新环境,安装并启用以下插件和主题
- 已激活主题: [Earth 1.11.0](https://github.com/halo-dev/theme-earth)
- 已启动插件:
  - [SEO 工具集 1.0.1](https://github.com/f2ccloud/plugin-seo-tools)
  - [OAuth2 认证 1.5.0](https://github.com/halo-sigs/plugin-oauth2)
  - [Trailing Slash 1.0.0](https://github.com/halo-sigs/plugin-trailing-slash)
  - [评论组件 2.5.1](https://github.com/halo-dev/plugin-comment-widget)
  - [KaTeX 2.1.0](https://github.com/halo-sigs/plugin-katex)
  - [应用市场 1.9.0](https://www.halo.run/store/apps/app-VYJbF)

通过 Apache Benchmark (ab) 进行 1w 次请求并发 100 个,测试访问首页,得到以下测试结果:

核心指标对比

|指标|改进前|改进后|提升情况|
|---|---|---|---|
|**总耗时 (Time taken)**|27.030 秒|25.718 秒|减少约 **4.9%**|
|**每秒请求数 (RPS)**|369.96 req/sec|388.83 req/sec|提升约 **5.1%**|
|**单请求平均耗时**|270.298 ms|257.181 ms|减少约 **4.9%**|
|**传输速率 (Transfer Rate)**|6346.44 KB/s|6670.12 KB/s|提升约 **5.1%**|

综合分析
- 性能提升主要体现在:请求处理时间(Processing)、等待时间(Waiting)以及每秒请求数(RPS)均有 约5% 左右的提升。
- 传输效率更高:通过更快的处理时间,传输速率提高了 5.1%。
- 长尾请求优化显著:最大响应时间减少了约 14.9%,意味着极端情况下的性能更优。

#### Does this PR introduce a user-facing change?

```release-note
为扩展获取增加缓存使网站整体性能提升 5% 以上
```
2024-12-04 02:41:09 +00:00
guqing 2b4d1ab8d8
perf: add caching for system configuration fetcher to enhance performance (#7100)
#### What type of PR is this?
/kind improvement
/area core
/milestone 2.20.x

#### What this PR does / why we need it:
为系统配置获取增加缓存以提高路由和主题模板渲染的速度

#### Special notes for your reviewer:
1. 系统能正确初始化
2. 测试修改系统配置后 http://localhost:8090/actuator/globalinfo 和主题端 `${site}` 是否都是新的
3. 更改了文章路由规则后能正确调整到新的规则

#### Does this PR introduce a user-facing change?

```release-note
为系统配置的获取增加缓存以提高路由和主题模板渲染的速度
```
2024-12-04 02:31:08 +00:00
guqing 7bd9408519
chore: standardize request parsing to use a single path handler (#7106)
#### What type of PR is this?
/kind improvement
/area core
/milestone 2.20.x

#### What this PR does / why we need it:
统一使用同一个 RequestPath 来解析请求信息

#### Does this PR introduce a user-facing change?

```release-note
None
```
2024-12-03 11:39:06 +00:00
zly199 568c7d27e5
feat: show sending status of verification emails in signup form. (#7065)
What type of PR is this?
/kind feature

What this PR does / why we need it:
This PR modifies the behavior of the "Send" button for sending verification codes. Now, when the button is clicked, it immediately shows a "Sending..." state, improving user experience by providing instant feedback. After a successful request, a countdown is displayed. This makes the process clearer for users and reduces confusion during waiting time.

Which issue(s) this PR fixes:
Fixes #7064 

Special notes for your reviewer:
Please review the implementation for consistent UI behavior and ensure no race conditions occur if the button is clicked multiple times quickly.

Does this PR introduce a user-facing change?
Improved user experience for sending verification codes: the button now immediately shows "
2024-12-02 13:19:00 +00:00
guqing 5cefefe130
fix: restrict thumbnail generation to images in the attachment library (#7079)
#### What type of PR is this?
/kind improvement
/area core
/milestone 2.20.x

#### What this PR does / why we need it:
限制缩略图生成仅针对附件库中的图片,防止任意 URI 的生成行为带来的潜在攻击风险

先 merge #7077 后才能合并此 PR

#### Does this PR introduce a user-facing change?

```release-note
限制缩略图生成仅针对附件库中的图片,防止任意 URI 的生成行为带来的潜在攻击风险
```
2024-11-26 03:28:29 +00:00
guqing ec5c70f951
fix: resolve concurrency issue causing duplicate thumbnail generation (#7077)
#### What type of PR is this?
/kind improvement
/area core
/milestone 2.20.x

#### What this PR does / why we need it:
修复可能为因为并发调用缩略图生成导致多次创建缩略图的问题

此 PR 为 #7031 的补充,并且会清理以前重复生成的缩略图记录和文件

#### Does this PR introduce a user-facing change?

```release-note
修复可能为因为并发调用缩略图生成导致多次重复缩略图记录的问题
```
2024-11-26 03:26:28 +00:00
John Niang d985b7a768
Upgrade to SpringDoc 2.7.0 (#7072)
* Upgrade to SpringDoc 2.7.0

Signed-off-by: John Niang <johnniang@foxmail.com>
2024-11-25 10:45:05 +08:00
guqing 0b505a9050
refactor: add uniqueness check for local thumbnail original links and dimensions to avoid duplication (#7031)
#### What type of PR is this?
/kind improvement
/area core
/milestone 2.20.x

#### What this PR does / why we need it:
对本地缩略图的原图链接和尺寸增加唯一性检查避免重复

#### Does this PR introduce a user-facing change?

```release-note
对本地缩略图的原图链接和尺寸增加唯一性检查避免重复
```
2024-11-24 15:50:22 +00:00
John Niang d75bb09267
Remove template engine after upgrading theme (#7057)
#### What type of PR is this?

/kind bug
/area core
/milestone 2.20.x

#### What this PR does / why we need it:

This PR removes template engine instead of clearing cache of template engine after upgrading theme to resolve incomplete cache clear.

#### Which issue(s) this PR fixes:

Fixes https://github.com/halo-dev/halo/issues/7056

#### Special notes for your reviewer:

1. Try to install the theme `theme-earth 1.12.0`
2. Request index page and you will see the `上一页` which should be `下一页`
3. Try to upgrade to the theme `theme-earth 1.12.1`
4. Request index page and you should see the `下一页` directly. 

#### Does this PR introduce a user-facing change?

```release-note
修复升级主题后语言包未更新的问题
```
2024-11-21 09:52:10 +00:00
guqing 7cef55b51f
fix: new tags showing null post count on theme (#7049)
#### What type of PR is this?
/kind improvement
/area core
/milestone 2.20.x

#### What this PR does / why we need it:
修复新创建的标签在主题端展示关联文章数量为 null 的问题

#### Which issue(s) this PR fixes:

Fixes #7042

#### Does this PR introduce a user-facing change?

```release-note
修复新创建的标签在主题端展示关联文章数量为 null 的问题
```
2024-11-19 06:32:05 +00:00
Anye 2c8f6f5009
feat: add support for OpenHarmony in device OS detection (#7045)
#### What type of PR is this?
/kind feature 

#### What this PR does / why we need it:
This PR adds support for detecting OpenHarmony as a device operating system.

#### Which issue(s) this PR fixes:
Fixes #7039

#### Special notes for your reviewer:
This PR introduces minor changes in the device OS detection logic.

#### Does this PR introduce a user-facing change?
```release-note
新设备登录通知的操作系统名支持展示鸿蒙替代 Unknown
```
2024-11-18 14:52:04 +00:00
Ryan Wang 06f3c289e8
chore: bump preset plugins version (#7024)
Signed-off-by: Ryan Wang <i@ryanc.cc>
2024-11-12 06:35:20 +08:00
John Niang 4dbfb930bf
Support customizing CORS configuration (#6981)
#### What type of PR is this?

/kind improvement
/area core
/milestone 2.20.x

#### What this PR does / why we need it:

This PR adds CorsOptions into SecurityProperties to let users customize their own CORS configuration. e.g.:

```yaml
halo:
  security:
    cors-options:
      disabled: false
      configs:
        - pathPattern: /apis/first.api.halo.run/v1alpha1/**
          config:
            allowedOrigins: [ "*" ]
            allowedHeaders: [ "*" ]
            allowedMethods: [ "*" ]
            exposedHeaders: [ "*" ]
            allowCredentials: true
            maxAge: 30m
        - pathPattern: /apis/second.api.halo.run/v1alpha1/**
          config:
            allowedOrigins: [ "www.halo.run", "www.lxware.cn" ]
            allowedHeaders: [ "Content-Type", "Authorization" ]
            allowedMethods: [ "GET, POST, PUT, DELETE" ]
            allowedCredentials: false
            maxAge: 1h
```

#### Does this PR introduce a user-facing change?

```release-note
支持自定义跨域配置
```
2024-10-31 08:53:07 +00:00
guqing 0d1a099223
refactor: hide essential notifications to prevent accidental disabling (#6972)
#### What type of PR is this?
/kind improvement
/area core
/milestone 2.20.x

#### What this PR does / why we need it:
隐藏关键通知项设置以避免用户意外禁用而无法收到通知

#### Which issue(s) this PR fixes:
Fixes #6967

#### Does this PR introduce a user-facing change?
```release-note
隐藏关键通知项设置以避免用户意外禁用而无法收到通知

```
2024-10-30 06:14:39 +00:00
John Niang 25086ee3e6
Rearrange order of security configurers (#6939)
#### What type of PR is this?

/kind improvement
/area core
/milestone 2.20.x

#### What this PR does / why we need it:

This PR rearranges order of security configurers. Especially, SecurityWebFiltersConfigurer has lower priority to configure than other security configurers.

So we can catch internal authentication in plugins.

#### Does this PR introduce a user-facing change?

```release-note
None
```
2024-10-27 10:02:01 +00:00
John Niang a0b352ac2d
Support hooking user creation (#6945)
#### What type of PR is this?

/kind feature
/area core
/milestone 2.20.x

#### What this PR does / why we need it:

This PR adds support for hooking user creating. Plugin developers can define extension points of `UserPreCreatingHandler` and `UserPostCreatingHandler` to do something else.

#### Does this PR introduce a user-facing change?

```release-note
支持在插件中定义用户创建的前置和后置处理器
```
2024-10-25 07:55:54 +00:00
guqing 2c234ab3eb
fix: prioritize login page route to prevent single page override (#6926)
#### What type of PR is this?
/kind bug
/area core
/milestone 2.20.x

#### What this PR does / why we need it:
修复登录页面路由会被自定义页面覆盖导致无法登录的问题

#### Which issue(s) this PR fixes:
Fixes #6893

#### Does this PR introduce a user-facing change?
```release-note
修复登录页面路由会被自定义页面路由覆盖导致无法登录的问题
```
2024-10-23 08:42:20 +00:00
guqing 17ec34c75e
fix: ignore conversion exceptions for plugin configuration to prevent program errors (#6924)
#### What type of PR is this?
/kind bug
/area plugin
/milestone 2.20.x

#### What this PR does / why we need it:
修复插件配置可能因为缺少校验导致使用时类型转换失败从而影响 Halo 使用的问题

#### Which issue(s) this PR fixes:
Fixes #6899

#### Does this PR introduce a user-facing change?
```release-note
修复插件配置可能因为缺少校验导致使用时类型转换失败从而影响 Halo 使用的问题
```
2024-10-23 08:40:20 +00:00
guqing fae03d4a5b
fix: missing deleted index in list method of single page finder (#6922)
#### What type of PR is this?
/kind bug
/area core
/milestone 2.20.x

#### What this PR does / why we need it:
修复使用 `singlePageFinder.list()` 时会提示缺少 spec.deleted 索引的问题

#### Which issue(s) this PR fixes:
Fixes #6919

#### Does this PR introduce a user-facing change?
```release-note
修复使用 `singlePageFinder.list()` 时会提示缺少 spec.deleted 索引的问题
```
2024-10-23 08:38:20 +00:00
guqing 7cc3dfa0a0
fix: remove httpOnly from language cookie to allow JS to access current language (#6933)
#### What type of PR is this?
/kind bug
/area core
/milestone 2.20.x

#### What this PR does / why we need it:
修复登录时切换了其他语言但是登录成功后始终显示中文的问题

此问题为 https://github.com/halo-dev/halo/pull/6891 导致

#### Does this PR introduce a user-facing change?
```release-note
修复登录时切换了其他语言但是登录成功后始终显示中文的问题
```
2024-10-23 03:34:17 +00:00
John Niang 61718cce98
Support nested configuration properties (#6920)
#### What type of PR is this?

/kind improvement
/area core
/milestone 2.20.x

#### What this PR does / why we need it:

This PR adds the annotations `@NestedConfigurationProperties` to let Spring Configuration Processor generate fully metadata.

We can execute command `./gradlew :application:compileJava` to generate `application/build/classes/java/main/META-INF/spring-configuration-metadata.json`. If you are using IDEA Ultimate, configuration hints related to Halo will be available.

#### Does this PR introduce a user-facing change?

```release-note
None
```
2024-10-22 09:20:29 +00:00
guqing d2799c59be
fix: path match rules for grouped OpenAPI (#6898)
#### What type of PR is this?
/kind improvement
/area core
/milestone 2.20.x

#### What this PR does / why we need it:
修正 OpenAPI 的分组匹配规则 之前有很多 PublicAPIs 没有出现在对应的组

#### Does this PR introduce a user-facing change?
```release-note
None
```
2024-10-22 07:52:28 +00:00
John Niang 329bcc5748
Exclude console and uc assets in security configuration (#6915)
#### What type of PR is this?

/kind improvement
/area core
/milestone 2.20.x

#### What this PR does / why we need it:

This PR excludes console and uc assets in security configuration to make them access by anonymous users.

#### Which issue(s) this PR fixes:

Fixes https://github.com/halo-dev/halo/issues/6908

#### Special notes for your reviewer:

```bash
http http://localhost:8090/uc/assets/index-E-uvwInx.css -ph

HTTP/1.1 200 OK
Accept-Ranges: bytes
Cache-Control: no-cache
Content-Encoding: gzip
Content-Length: 26213
Content-Type: text/css
Vary: Accept-Encoding
```

#### Does this PR introduce a user-facing change?

```release-note
None
```
2024-10-22 03:40:27 +00:00
Ryan Wang 53b291b54e
fix: resolve button height overflow in signup form on older Safari (#6912)
#### What type of PR is this?

/area core
/kind bug
/milestone 2.20.x

#### What this PR does / why we need it:

修复在低版本 Safari 浏览器中,注册表单中的按钮高度溢出的问题。

#### Which issue(s) this PR fixes:

Fixes #6910 

#### Does this PR introduce a user-facing change?

```release-note
修复在低版本 Safari 浏览器中,注册表单中的按钮高度溢出的问题。
```

<!-- Fuck Safari -->
2024-10-21 09:24:21 +00:00
guqing 833b884bdb
fix: modify name column charset to make it case-sensitive for MySQL (#6897)
#### What type of PR is this?
/kind improvement
/area core
/milestone 2.20.x

#### What this PR does / why we need it:
将 MySQL 的表创建脚本 name 列字符集改为 utf8mb4_bin 以使其对大小写敏感

Fixes https://github.com/halo-dev/halo/issues/4372

**how to test it?**
使用 docker 运行 MySQL
```shell
# mariadb 同样将镜像改为 mariadb 后执行相同步骤
docker run --name mysql-test -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=halo -p 3306:3306 --rm -d mysql:latest
```
然后执行表创建脚本并手动执行以下两条 SQL 能成功插入
```sql
insert into extensions(name,data,version) values('a', 'a', 0)
insert into extensions(name,data,version) values('A', 'A', 0)
```

#### Does this PR introduce a user-facing change?
```release-note
修改 MySQL 表创建脚本 name 列的字符集使其大小写敏感以解决可能会遇到切换数据库时因为数据冲突而无法导入备份的问题(这只对此版本及之后的新用户有效)
```
2024-10-18 09:49:38 +00:00
guqing 13644d21eb
fix: language preference is not remembered under non-HTTPS connections (#6891)
#### What type of PR is this?
/kind bug
/area core
/milestone 2.20.x

#### What this PR does / why we need it:
修复非 HTTPS 连接下无法记住用户语言偏好的问题

#### Which issue(s) this PR fixes:
Fixes #6888

#### Does this PR introduce a user-facing change?
```release-note
修复非 HTTPS 连接下无法记住用户语言偏好的问题
```
2024-10-18 09:47:37 +00:00
John Niang 3570353ce2
Bind sign up data instead of building by hand (#6895)
#### What type of PR is this?

/kind improvement
/area core
/milestone 2.20.x

#### What this PR does / why we need it:

This PR refactors sign up data binding using internal `bind` method in `ServerRequest` instead of binding my hand. It's more convenient and simpler.

#### Does this PR introduce a user-facing change?

```release-note
None
```
2024-10-18 07:55:39 +00:00
John Niang 697a5e5a4c
Fix the problem of not redirecting to corresponding login page after authentication failure (#6896)
#### What type of PR is this?

/kind bug
/area core
/milestone 2.20.x

#### What this PR does / why we need it:

This PR appends query `method=local` after redirection location in authentication failure handler to redirect to login page with local method.

#### Which issue(s) this PR fixes:

Fixes https://github.com/halo-dev/halo/issues/6894

#### Does this PR introduce a user-facing change?

```release-note
修复非默认登录方式登录失败之后跳转至默认登录方式的问题
```
2024-10-18 07:29:37 +00:00
guqing c465bf8c75
fix: prevent initialization failure when theme directory already exists (#6889)
#### What type of PR is this?
/kind bug
/area core
/milestone 2.20.x

#### What this PR does / why we need it:
修复从旧版本升级到 2.20 会因为默认主题目录已经存在而无法初始化的问题

#### Which issue(s) this PR fixes:
Fixes #6887

#### Does this PR introduce a user-facing change?
```release-note
修复从旧版本升级到 2.20 会因为默认主题目录已经存在而无法初始化的问题
```
2024-10-17 08:45:30 +00:00
John Niang 02def4e20a
Expose ReactiveUserDetailsService to authentication plugins (#6885)
#### What type of PR is this?

/kind improvement
/area core
/milestone 2.20.x

#### What this PR does / why we need it:

This PR exposes ReactiveUserDetailsService to authentication plugins.

#### Does this PR introduce a user-facing change?

```release-note
支持在插件中使用 ReactiveUserDetailsService
```
2024-10-17 02:43:30 +00:00
Ryan Wang 8df91e80b3
chore: bump app store plugin version (#6881)
#### What type of PR is this?

/area core
/kind improvement
/milestone 2.20.x

#### What this PR does / why we need it:

Bump app store plugin to 1.6.0

#### Does this PR introduce a user-facing change?

```release-note
None
```
2024-10-16 13:59:27 +00:00
John Niang 514a05552f
Refactor PAT authentication by making it standalone (#6878)
#### What type of PR is this?

/kind improvement
/area core
/milestone 2.20.x

#### What this PR does / why we need it:

This PR makes PAT configuration standalone and removes unused configuration related with `JWT`.

After this, we can define additional authentications in plugins with correct configuration order.

#### Does this PR introduce a user-facing change?

```release-note
None
```
2024-10-16 10:07:27 +00:00
John Niang db4e68b732
Expose user and role services into plugins (#6880)
#### What type of PR is this?

/kind feature
/area plugin
/milestone 2.20.x

#### What this PR does / why we need it:

This PR exposes user and role services into plugins. Some authentication plugins may interact with users and users' roles.

#### Does this PR introduce a user-facing change?

```release-note
允许在插件中使用 UserService 和 RoleService
```
2024-10-16 09:29:27 +00:00
guqing c577deb6ee
fix: missing ServerWebExchange in plugin template processor extension (#6877)
#### What type of PR is this?
/kind bug
/area core
/milestone 2.20.x

#### What this PR does / why we need it:
修复由 #6680 导致的插件模板处理扩展中无法获取到请求上下文的问题

#6680 修复了插件可以在模板处理扩展中通过请求上下文获取到 Halo 的 ApplicationContext 的问题
但这也引入了新的问题就是导致模板处理扩展无法获取到请求上下文,此 PR 通过判断传递给插件的 ITemplateContext 是否为 IWebContext,如果是则包装为 SecureTemplateWebContext 传递给插件,以解决此问题

#### Which issue(s) this PR fixes:
Fixes #6875

#### Does this PR introduce a user-facing change?
```release-note
修复插件模板处理扩展中无法获取到请求上下文的问题
```
2024-10-16 08:21:28 +00:00
John Niang b95a83a242
Fix the problem of not being able to create PAT for OAuth2 user (#6870)
#### What type of PR is this?

/kind bug
/area core
/milestone 2.20.x

#### What this PR does / why we need it:

This PR refactors check of whether the current user is a real user to fix the problem of not being able to create PAT for OAuth2 user.

#### Does this PR introduce a user-facing change?

```release-note
修复通过 OAuth2 登录之后无法正常创建和恢复个人令牌的问题
```
2024-10-15 08:51:22 +00:00
John Niang c3020d6a85
Fix the problem of not being able to disconnect OAuth2 user (#6869)
#### What type of PR is this?

/kind bug
/area core
/milestone 2.20.x

#### What this PR does / why we need it:

This PR corrects typo of `apisGroups` to `apiGroups` to fix the problem of not being able to disconnect OAuth2 user.

#### Special notes for your reviewer:

0. Install OAuth2 plugin
1. Log in as a normal user
2. Bind a OAuth2 user
3. Try to unbind it

#### Does this PR introduce a user-facing change?

```release-note
修复无法正常解绑 OAuth2 用户
```
2024-10-15 07:57:21 +00:00
guqing 45aae9c1a8
fix: preventing access to login page after Halo setup (#6865)
#### What type of PR is this?
/kind bug
/area core
/milestone 2.20.x

#### What this PR does / why we need it:
修复初始化 Halo 之后无法进入登录页面的问题

此问题原因是更改了 AuthProvider 的逻辑,当系统启动之后缺少默认的登录方式导致登录页面无法正确渲染
此 PR 将确保默认的登录方式始终存在来解决此问题

how to test it?
重新初始化 Halo 之后能正确渲染登录页面并登录即为符合预期

#### Does this PR introduce a user-facing change?
```release-note
修复初始化 Halo 之后无法进入登录页面的问题
```
2024-10-14 12:43:18 +00:00
John Niang dd5f02e505
Fix the problem of redirecting to previous URI with fragment after authenticated (#6862)
#### What type of PR is this?

/kind bug
/area core
/milestone 2.20.x

#### What this PR does / why we need it:

This PR ignores URI fragment while removing redirect URI. Before that, users may be redirected to previous redirect URI that contains fragment.

#### Does this PR introduce a user-facing change?

```release-note
修复二次登录后重定向跳转至旧地址的问题
```
2024-10-14 07:09:16 +00:00
guqing 17eea823a5
fix: retain legacy enabled field for auth provider setting (#6861)
#### What type of PR is this?
/kind bug
/area core
/milestone 2.20.x

#### What this PR does / why we need it:
恢复 https://github.com/halo-dev/halo/pull/6846 中删除的 SystemSetting.AuthProvider#enabled 字段避免插件应用到了它可能会发生错误,将其标记为过时

#### Does this PR introduce a user-facing change?
```release-note
None
```
2024-10-14 06:17:16 +00:00
Ryan Wang f7b2dcf9fc
chore: bump preset theme version (#6860)
Signed-off-by: Ryan Wang <i@ryanc.cc>
2024-10-14 12:25:35 +08:00
guqing 82498dcedf
refactor: auth provider sorting logic for better maintainability and clarity (#6846)
* refactor: auth provider sorting logic for better maintainability and clarity

* Refine UI

* chore: remove other auth type

* Remove other auth providers

---------

Co-authored-by: Ryan Wang <i@ryanc.cc>
2024-10-14 10:53:24 +08:00
Ryan Wang eff73dca12 feat: add H2 database usage warning for setup page 2024-10-14 10:18:24 +08:00
johnniang 55f133396c Set usingH2database variable into setup template model 2024-10-14 10:18:03 +08:00
Ryan Wang b0d36b784e
feat: support toast a message for backend exceptions when sending emails (#6856)
#### What type of PR is this?

/area core
/kind improvement
/milestone 2.20.x

#### What this PR does / why we need it:

注册表单发送邮箱验证码时,支持显示来自后端的异常。

<img width="693" alt="image" src="https://github.com/user-attachments/assets/78d1d793-7673-4442-9b0b-1eb7c4d91ebd">


#### Does this PR introduce a user-facing change?

```release-note
None
```
2024-10-13 15:33:14 +00:00