Commit Graph

573 Commits (v2.20.14)

Author SHA1 Message Date
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
Ryan Wang 0d8c4bb126
fix: set default value for attachment storage policy in user center (#6853)
#### What type of PR is this?

/area core
/kind bug
/milestone 2.20.x

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

修复首次初始化之后,个人中心使用的附件存储策略没有默认值的问题。

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

Fixes #6834 

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

```release-note
None
```
2024-10-13 15:11:14 +00:00
Ryan Wang a21413e080
fix: not redirect to /console after setup (#6852)
#### What type of PR is this?

/area core
/kind bug
/milestone 2.20.x

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

修复初始化登录之后,没有正确重定向到 /console 的问题。

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

Fixes #6850 

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

```release-note
None
```
2024-10-13 14:55:14 +00:00
John Niang 7c6a8e9ce7
Fill operation ID while building setup route (#6857)
#### What type of PR is this?

/kind bug
/area core
/milestone 2.20.x

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

This PR fills operation ID while building setup route to prevent errors when generating OpenAPI docs.

```java
2024-10-13T22:09:46.997+08:00 ERROR 68966 --- [     parallel-4] a.w.r.e.AbstractErrorWebExceptionHandler : [88654f05-3]  500 Server Error for HTTP GET "/v3/api-docs/apis_aggregated.api_v1alpha1"

java.lang.IllegalStateException: You should either fill, the Operation or at least the bean class and the bean method
	at org.springdoc.core.fn.builders.operation.Builder.build(Builder.java:467) ~[springdoc-openapi-starter-common-2.6.0.jar:2.6.0]
	Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException: 
```

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

```release-note
None
```
2024-10-13 14:21:14 +00:00
guqing 58488686a7
chore: ignore preset plugin installation errors to avoid initialization failure (#6855)
#### What type of PR is this?
/milestone 2.20.x
/area core
/milestone 2.20.x

#### What this PR does / why we need it:
忽略预设插件安装时的错误避免无法初始化

可能因为没有预先 download 预设插件到项目目录而发生 IO 异常影响初始化流程

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

```release-note
None
```
2024-10-13 13:57:13 +00:00
guqing 3bdec9eacf
fix: vertical images are rotated to horizontal when generating thumbnails (#6842)
#### 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 #6802

#### Does this PR introduce a user-facing change?
```release-note
修复竖向图片生成缩略图后会丢失方向信息展示为横向图片的问题
```
2024-10-12 13:47:10 +00:00
John Niang b761fe2b79
Preserve remember-me option after authentication failure (#6844)
#### What type of PR is this?

/kind bug
/area core
/milestone 2.20.x

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

This PR preserves `remember-me` option after authentication failure.

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

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

#### Special notes for your reviewer:

1. Go to login page
2. Input invalid username or password and select `remember-me` option
3. Click `Login` button
4. See the result

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

```release-note
修复登录失败后记住我选项被重置的问题
```
2024-10-12 10:59:10 +00:00
Ryan Wang b9da9d05ea
refactor: improve login page ui (#6832)
#### What type of PR is this?

/area core
/kind improvement
/milestone 2.20.x

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

优化登录等页面的 UI,主要优化低分屏下的 UI 表现,防止元素过大。

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

```release-note
优化登录等页面的 UI,优化低分屏下的 UI 表现,防止元素过大。
```
2024-10-12 09:21:10 +00:00
John Niang 6d149ae3bb
Fix the problem of being able to configure invalid external URL (#6840)
#### 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 users not be able to configure a invalid external URL like `https:www/halo.run` even if it is an valid URL format.

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

Fixes #6837 

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

```release-note
修复可配置无效的外部访问地址的问题
```
2024-10-12 08:21:10 +00:00
Ryan Wang 91a69de849
refactor: improve accessibility for login page (#6839)
#### What type of PR is this?

/area core
/kind improvement
/milestone 2.20.x

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

提升登录页面的可访问性。

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

```release-note
None
```
2024-10-12 07:19:09 +00:00
John Niang 9468e8741f
Add globalInfo into logout page (#6831)
#### 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 globalInfo data into logout template model.

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

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

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

```release-note
None
```
2024-10-12 04:21:09 +00:00
John Niang cecbfcfa4a
Disable CSRF protection for actuator endpoints (#6830)
#### What type of PR is this?

/kind bug
/area core
/milestone 2.20.x

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

This PR disables CSRF protection for actuator endpoints because they are not state-changing operations.

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

Fixes #6827 

#### Special notes for your reviewer:

Try to restore Halo.

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

```release-note
修复恢复备份后无法自动重启的问题
```
2024-10-12 04:15:09 +00:00
John Niang 0ad565f35c
Do not cache template result for pre-auth pages (#6829)
#### What type of PR is this?

/kind bug
/area core
/milestone 2.20.x

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

This PR prevents caching from cache plugin for pre-auth pages and logout page.

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

Fixes #6826 

#### Special notes for your reviewer:

1. Install `Page Cache Plugin` from <https://www.halo.run/store/apps/app-BaamQ>.
2. Open a private browser window
3. Access login page twice
4. Try to login
5. See the result

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

```release-note
解决因缓存插件缓存登录页面导致无法登录的问题
```
2024-10-12 04:11:09 +00:00
John Niang 98a131309c
Add globalInfo into templates model (#6823)
#### 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 globalInfo into template models and refactors password reset to adapt data binding.

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

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

```release-note
None
```
2024-10-11 09:51:06 +00:00
Ryan Wang d63eaed10f
fix: correct display of email verification message toast (#6822)
#### What type of PR is this?

/area core
/kind bug
/milestone 2.20.x

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

修复不能正常显示邮箱验证提示的问题。

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

```release-note
None
```
2024-10-11 09:27:05 +00:00
Ryan Wang 59a59715a1
refactor: improve password hint text on reset password page (#6820)
#### What type of PR is this?

/area core
/kind improvement
/milestone 2.20.x

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

优化重置密码页面的密码提示文本,以 aab8806f0d/application/src/main/resources/config/i18n/messages_zh.properties (L66) 为准。

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

```release-note
None
```
2024-10-11 08:23:07 +00:00
Ryan Wang 687c760288
feat: add password reset success message in login page (#6818)
#### What type of PR is this?

/area core
/kind improvement
/milestone 2.20.x

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

重置密码跳转到登录页面之后,在顶部添加重置成功的提示。

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

```release-note
None 
```
2024-10-11 08:21:07 +00:00
Ryan Wang 2de02c9ad4
refactor: improve ui of login page (#6809)
#### What type of PR is this?

/area core
/kind improvement
/milestone 2.20.x

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

优化登录页面的 UI。

<img width="1910" alt="image" src="https://github.com/user-attachments/assets/736b1f72-e7c1-4c19-a0d9-dc935c738931">


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

```release-note
None
```
2024-10-11 08:03:05 +00:00
guqing aab8806f0d
refactor: support locale-based validation messages based on users language (#6819)
#### What type of PR is this?
/kind improvement
/area core
/milestone 2.20.x

#### What this PR does / why we need it:
优化校验提示信息根据用户选择的语言代替 `Locale#getDefault()#getLanguage()`

#### Does this PR introduce a user-facing change?
```release-note
None
```
2024-10-11 07:11:05 +00:00
John Niang 99db7a6101
Support redirecting to URI with fragment (#6817)
#### What type of PR is this?

/kind bug
/area core
/milestone 2.20.x

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

This PR supports redirecting to URI with fragment. e.g.: <http://localhost:8090/login?redirect_uri=%2F%23afragment>(redirect_uri is `/#afragment`).

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

Fixes #6767 

#### Special notes for your reviewer:

1. Request <http://localhost:8090/login?redirect_uri=%2F%23afragment>
2. Log in
3. See the redirection

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

```release-note
None
```
2024-10-11 02:45:05 +00:00
guqing 25c54d792e
perf: replace concatMap to flatMapSequential to improve parallelism and efficiency (#6706)
#### What type of PR is this?
/kind improvement
/area core
/milestone 2.20.x

#### What this PR does / why we need it:
将 concatMap 替换为 flatMapSequential 以提高并行度和执行效率

可以看一下这个场景示例来模拟像文章列表 API 的数据组装
假如每个步骤的执行时间是 1s 有 4 个步骤 同时 Flux 发出 4 条数据:

```java
@Test  
void test() {  
    var startMs = System.currentTimeMillis();  
  
    var monoA = Mono.fromSupplier(  
            () -> {  
                sleep();  
                return "A";  
            })        .subscribeOn(Schedulers.boundedElastic());  
  
    var monoB = Mono.fromSupplier(  
            () -> {  
                sleep();  
                return "B";  
            })        .subscribeOn(Schedulers.boundedElastic());  
  
    var monoC = Mono.fromSupplier(  
            () -> {  
                sleep();  
                return "C";  
            })        .subscribeOn(Schedulers.boundedElastic());  
  
    var monoD = Mono.fromSupplier(  
            () -> {  
                sleep();  
                return "D";  
            })        .subscribeOn(Schedulers.boundedElastic());  
  
    var convert = Mono.when(monoA, monoB, monoC, monoD);  

    Flux.just("1", "2", "3", "4")
        // concatMap(convert::thenReturn)
        .flatMapSequential(convert::thenReturn)  
        .collectList()  
        .block(); 

    System.out.println("Time: " + (System.currentTimeMillis() - startMs));  
}

private static void sleep() {  
    try {  
        Thread.sleep(1000);  
    } catch (InterruptedException e) {  
        throw new RuntimeException(e);  
    }
}
```
**结果:**
1. 如果每个步骤没有加  subscribeOn 且使用 concatMap 耗时: 16362 ms
2. 每个步骤使用 subscribeOn 且使用 concatMap 耗时: 4174 ms
3. 每个步骤使用 subscribeOn 且使用 flatMapSequential 耗时: 1185 ms

#### Does this PR introduce a user-facing change?
```release-note
提升页面访问速度
```
2024-10-10 09:49:01 +00:00
guqing 02c54846dc
refactor: head and footer tag injection to skip error pages (#6709)
#### What type of PR is this?
/kind improvement
/area core
/milestone 2.20.x

#### What this PR does / why we need it:
模板 head 和 footer 标签注入功能忽略错误页面避免当扩展发生错误时导致错误页面无法显示

#### Which issue(s) this PR fixes:
Fixes #6500 , #6750

#### Does this PR introduce a user-facing change?
```release-note
代码注入功能忽略对错误页面和登录注册等页面的注入
```
2024-10-10 09:45:01 +00:00
Ryan Wang d6c914f4c6
refactor: improve ui of logout page (#6810)
#### What type of PR is this?

/area core
/kind improvement
/milestone 2.20.x

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

优化退出登录页面的 UI。

<img width="568" alt="image" src="https://github.com/user-attachments/assets/dd3b405b-e200-478a-ba87-b0d474e6ee1f">


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

```release-note
None
```
2024-10-10 08:23:01 +00:00
guqing fbe40c28fc
chore: restrict username and password length during user registration (#6808)
#### 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
None
```
2024-10-10 07:57:00 +00:00
guqing 605d52a86e
refactor: optimize file type detection and support decision-making based on file name (#6675)
#### 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-10-10 07:45:00 +00:00
Ryan Wang 2b3badc8e1
refactor: update login-related page templates structure (#6813)
#### What type of PR is this?

/area core
/kind improvement
/milestone 2.20.x

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

重构登录、注册相关的模板结构,主要目的是为了解耦,修改页面时仅修改相关的模板和语言文件。

重构之后主题的引用方式如下:

login.html

```html
<div th:replace="~{gateway_fragments/login::form}"></div>
```

#### Special notes for your reviewer:

需要测试各个页面是否功能正常

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

```release-note
None
```
2024-10-10 07:33:00 +00:00
Ryan Wang 01a781c54a
feat: improve password confirmation validation for forms (#6807)
#### What type of PR is this?

/area core
/kind improvement
/milestone 2.20.x

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

完善部分表单的确定密码校验。

1. 封装单独的校验函数。
2. 完善 i18n。

<img width="676" alt="image" src="https://github.com/user-attachments/assets/af8a4edc-d6ba-419f-b7ba-baa9d488186d">

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

```release-note
None
```
2024-10-10 07:17:00 +00:00
John Niang cae871f9e6
Fix the problem of accessing logout page without authentication (#6812)
#### What type of PR is this?

/kind bug
/area core
/milestone 2.20.x

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

Currently, logout page is always visible for anyone whether the user is authenticated. This PR restricts the visibility of logout page to authenticated users but anonymous users.

#### Special notes for your reviewer:

```bash
> http http://localhost:8090/logout

HTTP/1.1 302 Found
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Expires: 0
Location: /login?authentication_required
Pragma: no-cache
Referrer-Policy: strict-origin-when-cross-origin
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 0
content-length: 0
```

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

```release-note
修复未登录情况下依然能够访问登出页面的问题
```
2024-10-10 05:43:00 +00:00
guqing 9e3f77baf3
fix: avoid NPE by skipping nonexistent notifiers in user preferences (#6811)
#### What type of PR is this?
/kind improvement
/area core
/milestone 2.20.x

#### What this PR does / why we need it:
修复当用户通知偏好设置中出现不存在的通知器名称时会导致 NPE 的问题

此问题可能发生在,通知器由插件或者专业版提供并且修改了偏好设置后禁用了插件或切换到开源版导致找不到该通知器的记录

#### Does this PR introduce a user-facing change?
```release-note
None
```
2024-10-10 05:27:00 +00:00
John Niang 158c3e8a9e
Merge pull request #6804 from guqing/refactor/user-validation
refactor: unified validation for username and password format
2024-10-10 10:45:38 +08:00
guqing d6df340fe4 refactor: unified validation for username and password format 2024-10-09 17:38:34 +08:00
John Niang ec75564f37
Refactor password reset for extensibility (#6803)
#### 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 password reset for extensibility. If we want to add another password reset method, first thing we need to do is adding a new password reset method into `halo.security.password-reset-methods[]` and then defining PasswordResetAvailabilityProvider bean.

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

```release-note
None
```
2024-10-09 09:04:57 +00:00
Ryan Wang 0e4a19d182
refactor: prevent password field from displaying encrypted text (#6801)
#### What type of PR is this?

/area core
/kind improvement
/milestone 2.20.x

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

在提交登录表单时,不在密码框中显示加密文本。

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

Fixes #6799 

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

```release-note
None
```
2024-10-09 09:02:58 +00:00
John Niang 5c50779693
Xor CSRF token (#6798)
#### 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 XOR operation for CSRF token and changes the CSRF cookie `HttpOnly` to `true` to forbid JavaScript from accessing the cookie.

See https://docs.spring.io/spring-security/reference/servlet/exploits/csrf.html#csrf-token-request-handler-breach for more details.

#### Special notes for your reviewer:

```bash
http http://localhost:8090/login -ph

HTTP/1.1 200 OK
set-cookie: XSRF-TOKEN=6d5dd83f-f0a7-4d94-a33e-73f213d679ff; Path=/; HTTPOnly
```

```bash
http http://localhost:8090/login -pb | grep _csrf

><input type="hidden" name="_csrf" value="ctubmrEC3dAbxC5H_k_-VnVUtih2BrfjcPfLmVAyaP0a1kAdEb-t_IcwuLM29B11yGLKNRQxm0lFZILOFZX-_GcHWJ974iR5"/>
```

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

```release-note
None
```
2024-10-09 09:00:57 +00:00
guqing bba242332d refactor: system initialization process to adapt to the new login method
Signed-off-by: guqing <i@guqing.email>
2024-10-09 12:20:27 +08:00
guqing 2585636c48
feat: allow users to manage their attachments in uc (#6731)
#### What type of PR is this?
/kind feature
/milestone 2.20.x
/area core

#### What this PR does / why we need it:
支持用户在个人中心管理自己的附件(需要具有对应权限)

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

#### Does this PR introduce a user-facing change?
```release-note
支持用户在个人中心管理自己的附件(需要具有对应权限)
```
2024-10-08 14:56:55 +00:00
Ryan Wang edb3f1c617
feat: add login link to signup page (#6780)
#### 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/dafc48bb-c16e-4d9b-95f7-b44e2f14ed6f">

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

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

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

```release-note
None
```
2024-10-08 14:54:56 +00:00
Ryan Wang 786cb1b260
fix: can not display error message for duplicate username during signup (#6789)
#### What type of PR is this?

/area core
/kind bug
/milestone 2.20.x

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

修复注册时,不能正常显示用户名重复的错误的问题。

<img width="666" alt="image" src="https://github.com/user-attachments/assets/bef83af1-ab9d-4c84-8c3e-0d4f8a6892f3">

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

```release-note
None
```
2024-10-08 14:52:56 +00:00
John Niang e667719dd7
Redirect to user center after authenticating successfully (#6797)
#### What type of PR is this?

/kind cleanup
/area core
/milestone 2.20.x

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

This PR changes the redirect URI to `/uc` instead of `/console` after authenticating successfully.

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

```release-note
None
```
2024-10-08 14:10:54 +00:00
Ryan Wang c82b65be99
chore: bump preset theme version (#6794)
#### What type of PR is this?

/area core
/kind improvement
/milestone 2.20.x

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

更新默认主题的版本。

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

```release-note
None
```
2024-10-08 10:32:54 +00:00
Ryan Wang 16641e3331
refactor: improve error message styling for reset password form (#6791)
#### What type of PR is this?

/area core
/kind improvement
/milestone 2.20.x

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

优化重置密码表单的错误提示样式。

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

```release-note
None
```
2024-10-08 10:30:55 +00:00
Ryan Wang 2555cbf6ff
fix: JavaScript error on signup page (#6788)
#### What type of PR is this?

/area core
/kind bug
/milestone 2.20.x

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

修复注册页面的 JS 错误。

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

```release-note
None 
```
2024-10-08 10:28:55 +00:00
Ryan Wang 479b439ce4
chore: bump preset plugins version (#6792)
#### What type of PR is this?

/area core
/kind improvement
/milestone 2.20.x

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

升级预设插件的版本。

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

```release-note
None
```
2024-10-08 09:14:54 +00:00
Ryan Wang 223eb88b10
refactor: update local login method icons (#6783)
#### What type of PR is this?

/area core
/kind improvement
/milestone 2.20.x

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

更新本地登录方式的图标。

<img width="514" alt="image" src="https://github.com/user-attachments/assets/d8624548-c1b1-4f26-bf2f-353f127af7e5">


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

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

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

```release-note
None
```
2024-10-08 08:58:53 +00:00
John Niang f1d5911bb3
Fix the problem of not being able to resolve headers correctly (#6786)
#### What type of PR is this?

/kind bug
/area core
/milestone 2.20.x

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

This PR changes server.forward-header-strategy to native instead of framework due to a bug of Spring Framework 6.20.0-RC.1.

See https://github.com/spring-projects/spring-framework/pull/32097#discussion_r1791264218 for more.

If Halo server is proxied by OpenResty which is using HTTP 2, all header names proxied into Halo server will be lowercase. This behavior makes Halo get a null header(e.g.:: `content-type: application/json`) while invoking `request.getHeaders().getContentType()`.

And I found that `ServerHttpRequest` is mutated by `org.springframework.web.server.adapter.ForwardedHeaderTransformer`, so I try to use native forward-header-strategy to resolve the problem and it works very well. See [reactor.netty.http.server.DefaultHttpForwardedHeaderHandler](446683826b/reactor-netty-http/src/main/java/reactor/netty/http/server/DefaultHttpForwardedHeaderHandler.java) for more.

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

```release-note
None
```
2024-10-08 08:24:54 +00:00
John Niang 9d01b627d0
Customize authorization exchange separately (#6779)
#### What type of PR is this?

/kind cleanup
/area core
/milestone 2.20.x

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

This PR separates authorization exchange customization into security configurers. I also define the annotations `@Order` on every security configurer in order to customize authorization exchange in separated source file instead of modifying existing.

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

```release-note
None
```
2024-10-07 15:50:53 +00:00
Ryan Wang c3ecd339a1
feat: refine i18n for login method selection button (#6771)
#### What type of PR is this?

/area core
/kind improvement
/milestone 2.20.x

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

完善登录方式选择按钮的 i18n。

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

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

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

```release-note
None
```
2024-10-07 15:22:52 +00:00
John Niang dfbab283ef
Merge pull request #6729 from guqing/feature/5851
feat: support deleting posts in user center
2024-10-07 17:48:26 +08:00
Ryan Wang 709884212a
refactor: login-related page templates structure (#6769)
#### What type of PR is this?

/area core
/kind improvement
/milestone 2.20.x

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

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

重构登录、注册、找回密码、两步验证等模板的结构,提供更好的复用性,现在主题可以这样复用模板:

login.html

```html
<form th:replace="~{gateway_modules/form_fragments::login}"></form>
```

signup.html

```html
<form th:replace="~{gateway_modules/form_fragments::signup}"></form>
```

challenges/two-factor/totp.html

```html
<form th:replace="~{gateway_modules/form_fragments::totp}"></form>
```

#### Special notes for your reviewer:

需要测试各个页面是否功能正常

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

```release-note
None
```
2024-10-07 09:28:51 +00:00
guqing 04e195f034
fix: unique index conflict issue after backup restoration preventing startup (#6701)
#### What type of PR is this?
/kind bug
/area core
/milestone 2.20.x
/sig docs

#### What this PR does / why we need it:
修复恢复备份后可能会因为与之前的数据冲突导致无法启动的问题

如果恢复时发生不可预知的错误,需要重启之后重新初始化再进行恢复

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

#### Does this PR introduce a user-facing change?
```release-note
修复恢复备份后可能会因为与恢复之前存在的数据冲突导致无法启动的问题
```
2024-10-07 09:20:50 +00:00
Ryan Wang 8896e16615
feat: disallow deletion of system-protected attachment policies (#6735)
#### What type of PR is this?

/area core
/kind improvement
/milestone 2.20.x

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

为系统默认的存储策略添加保护措施,不允许删除。

<img width="893" alt="image" src="https://github.com/user-attachments/assets/990f834f-3d97-4ee8-9c24-01cc188b7be6">


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

```release-note
为系统默认的存储策略添加保护措施,不允许删除。
```
2024-10-04 14:10:44 +00:00
Ryan Wang 4dd5b7e103
feat: add link prefetch for logo resource on login page (#6751)
#### What type of PR is this?

/area core
/kind improvement
/milestone 2.20.x

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

为登录页面的 Logo 资源添加 link prefetch 标签,以缓解页面抖动的问题。

before:

https://github.com/user-attachments/assets/ec718b62-6593-4deb-a028-bcb3d8504c4e

after:

https://github.com/user-attachments/assets/8d408408-37bd-4cdc-a22a-b39531fa505f

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

```release-note
None
```
2024-10-04 14:02:44 +00:00
Ryan Wang cf7746be6d
refactor: exclude indices directory during backup (#6753)
#### What type of PR is this?

/area core
/kind improvement
/milestone 2.20.x

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

备份时排除全文索引目录 indices,防止恢复之后因为索引文件问题无法启动。

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

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

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

```release-note
备份时排除全文索引目录 indices,防止恢复之后因为索引文件问题无法启动。
```
2024-10-04 12:48:43 +00:00
Ryan Wang c941e37435
refactor: enhance login page styling for improved UX (#6757)
#### What type of PR is this?

/area core
/kind improvement
/milestone 2.20.x

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

微调登录相关页面的样式。

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

```release-note
None
```
2024-10-04 12:44:43 +00:00
John Niang 9829371548
Add Gradle plugin to discover dependency updates (#6761)
#### 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 [a Gradle plugin ](https://github.com/ben-manes/gradle-versions-plugin)to discover dependency updates.

```bash
❯ ./gradlew dependencyUpdates -Drevision=release

> Task :api:dependencyUpdates

------------------------------------------------------------
:api Project Dependency Updates (report to plain text file)
------------------------------------------------------------

The following dependencies are using the latest release version:
 - com.github.ben-manes.caffeine:caffeine:3.1.8
 - com.github.java-json-tools:json-patch:1.13
 - com.j256.two-factor-auth:two-factor-auth:1.3
 - io.asyncer:r2dbc-mysql:1.3.0
 - io.github.java-diff-utils:java-diff-utils:4.12
 - io.github.resilience4j:resilience4j-reactor:2.2.0
 - io.github.resilience4j:resilience4j-spring-boot3:2.2.0
 - io.projectreactor:reactor-test:3.7.0-M6
 - io.r2dbc:r2dbc-h2:1.0.0.RELEASE
 - io.seruco.encoding:base62:0.1.3
 - org.apache.commons:commons-lang3:3.17.0
 - org.imgscalr:imgscalr-lib:4.2
 - org.jacoco:org.jacoco.agent:0.8.12
 - org.jacoco:org.jacoco.ant:0.8.12
 - org.mariadb:r2dbc-mariadb:1.2.2
 - org.openapi4j:openapi-schema-validator:1.0.7
 - org.pf4j:pf4j:3.12.0
 - org.postgresql:postgresql:42.7.4
 - org.postgresql:r2dbc-postgresql:1.0.5.RELEASE
 - org.projectlombok:lombok:1.18.30
 - org.springdoc:springdoc-openapi-starter-webflux-ui:2.6.0
 - org.springframework.boot:spring-boot-starter-actuator:3.4.0-M3
 - org.springframework.boot:spring-boot-starter-cache:3.4.0-M3
 - org.springframework.boot:spring-boot-starter-data-jpa:3.4.0-M3
 - org.springframework.boot:spring-boot-starter-data-r2dbc:3.4.0-M3
 - org.springframework.boot:spring-boot-starter-mail:3.4.0-M3
 - org.springframework.boot:spring-boot-starter-security:3.4.0-M3
 - org.springframework.boot:spring-boot-starter-test:3.4.0-M3
 - org.springframework.boot:spring-boot-starter-thymeleaf:3.4.0-M3
 - org.springframework.boot:spring-boot-starter-validation:3.4.0-M3
 - org.springframework.boot:spring-boot-starter-webflux:3.4.0-M3
 - org.springframework.integration:spring-integration-core:6.4.0-M3
 - org.springframework.security:spring-security-oauth2-client:6.4.0-M4
 - org.springframework.security:spring-security-oauth2-jose:6.4.0-M4
 - org.springframework.security:spring-security-oauth2-resource-server:6.4.0-M4
 - org.springframework.security:spring-security-test:6.4.0-M4
 - org.springframework.session:spring-session-core:3.4.0-M2
 - org.thymeleaf.extras:thymeleaf-extras-springsecurity6:3.1.2.RELEASE

The following dependencies have later release versions:
 - com.google.guava:guava [32.0.1-jre -> 33.3.1-jre]
     https://github.com/google/guava
 - net.bytebuddy:byte-buddy [1.15.1 -> 1.15.3]
     https://bytebuddy.net
 - org.apache.lucene:lucene-analysis-common [9.11.1 -> 9.12.0]
     https://lucene.apache.org/
 - org.apache.lucene:lucene-backward-codecs [9.11.1 -> 9.12.0]
     https://lucene.apache.org/
 - org.apache.lucene:lucene-core [9.11.1 -> 9.12.0]
     https://lucene.apache.org/
 - org.apache.lucene:lucene-highlighter [9.11.1 -> 9.12.0]
     https://lucene.apache.org/
 - org.apache.lucene:lucene-queryparser [9.11.1 -> 9.12.0]
     https://lucene.apache.org/
 - org.apache.tika:tika-core [2.9.2 -> 3.0.0-BETA2]
     https://tika.apache.org/
 - org.jsoup:jsoup [1.15.3 -> 1.18.1]
     https://jsoup.org/

Gradle release-candidate updates:
 - Gradle: [8.10.2: UP-TO-DATE]

Generated report file build/dependencyUpdates/report.txt

> Task :application:dependencyUpdates

------------------------------------------------------------
:application Project Dependency Updates (report to plain text file)
------------------------------------------------------------

The following dependencies are using the latest release version:
 - com.puppycrawl.tools:checkstyle:9.3
 - io.projectreactor:reactor-test:3.7.0-M6
 - org.jacoco:org.jacoco.agent:0.8.12
 - org.jacoco:org.jacoco.ant:0.8.12
 - org.springframework:spring-context-indexer:6.2.0-RC1
 - org.springframework.boot:spring-boot-configuration-processor:3.4.0-M3
 - org.springframework.boot:spring-boot-starter-test:3.4.0-M3
 - org.springframework.security:spring-security-test:6.4.0-M4
 - org.webjars.npm:jsencrypt:3.3.2
 - org.webjars.npm:normalize.css:8.0.1

The following dependencies have later release versions:
 - org.projectlombok:lombok [1.18.30 -> 1.18.34]
     https://projectlombok.org

Gradle release-candidate updates:
 - Gradle: [8.10.2: UP-TO-DATE]

Generated report file build/dependencyUpdates/report.txt

Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

For more on this, please refer to https://docs.gradle.org/8.10.2/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.

BUILD SUCCESSFUL in 1s
9 actionable tasks: 2 executed, 7 up-to-date
```

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

<!--
如果当前 Pull Request 的修改不会造成用户侧的任何变更,在 `release-note` 代码块儿中填写 `NONE`。
否则请填写用户侧能够理解的 Release Note。如果当前 Pull Request 包含破坏性更新(Break Change),
Release Note 需要以 `action required` 开头。
If no, just write "NONE" in the release-note block below.
If yes, a release note is required:
Enter your extended release note in the block below. If the PR requires additional action from users switching to the new release, include the string "action required".
-->

```release-note
None
```
2024-10-04 11:46:43 +00:00
John Niang 462fac0eb6
Redirect to user center if authenticated users access login and signup pages (#6740)
#### What type of PR is this?

/kind improvement
/area core
/milestone 2.20.x

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

This PR make authenticated users redirect to user center if they are trying to access login and signup pages.

#### Special notes for your reviewer:

1. Log in Halo
2. Try to request <http://localhost:8090/login> or <http://localhost:8090/signup>.

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

```release-note
None
```
2024-10-01 15:34:00 +00:00
John Niang db65dd3b3a
Support redirecting to page according to query after authenticated (#6736)
#### What type of PR is this?

/kind improvement
/area core
/milestone 2.20.0

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

This PR supports query `redirect_uri` to control where to redirect after authenticated.

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

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

#### Special notes for your reviewer:

Every step below needs you logging out.

1. Try to request <http://localhost:8090/console/login?redirect_uri=/xxx
2. Try to request <http://localhost:8090/login?redirect_uri=/xxx
3. Try to request <http://localhost:8090/console/posts

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

```release-note
None
```
2024-09-30 10:37:52 +00:00
John Niang 8a9b954969
Support unbinding OAuth2User from Halo side (#6734)
#### What type of PR is this?

/kind feature
/area core
/milestone 2.20.x

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

This PR provides an endpoint for disconnecting user connection. After the user connection is disconnected, an event `UserConnectionDisconnectedEvent` will be published for plugins.

Now, OAuth2 plugin can simplify the authentication, binding  and unbinding logic, please see the AuthProvider configuration snippet below:

```diff
spec:
  authenticationUrl: /oauth2/authorization/github
- bindingUrl: /apis/api.plugin.halo.run/v1alpha1/plugins/plugin-oauth2/connect/github
+ bindingUrl: /oauth2/authorization/github
- unbindUrl: /apis/api.plugin.halo.run/v1alpha1/plugins/plugin-oauth2/disconnect/github
+ unbindUrl: /apis/uc.api.auth.halo.run/v1alpha1/user-connections/github/disconnect
```

Please note that, OAuth2 plugin can also define binding and unbinding endpoints by self.

#### Special notes for your reviewer:

OAuth2 test plugin: 
[plugin-oauth2-1.0.4-SNAPSHOT.zip](https://github.com/user-attachments/files/17184215/plugin-oauth2-1.0.4-SNAPSHOT.zip)

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

```release-note
None
```
2024-09-30 10:31:53 +00:00
guqing 56804c9be1
feat: add config option to allow disabling Basic authentication (#6689)
#### What type of PR is this?
/milestone 2.20.x
/area core
/kind improvement

#### What this PR does / why we need it:
允许通过 `halo.security.basic-auth.disabled=true` 配置来禁用 Basic Auth 认证

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

#### Does this PR introduce a user-facing change?
```release-note
允许通过 `halo.security.basic-auth.disabled=true` 配置来禁用 Basic Auth 认证,在 2.20 版本生产环境下默认禁用了 Basic Auth
```
2024-09-30 03:59:51 +00:00
guqing 875a804a56
refactor: exclude thumbnail directories when backup (#6725)
#### 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 #6717

#### Does this PR introduce a user-facing change?
```release-note
备份时忽略缩略图目录以减少文件大小
```
2024-09-29 15:17:47 +00:00
John Niang e77954313d
Support binding OAuth2 user automatically (#6702)
#### What type of PR is this?

/kind improvement
/area core
/milestone 2.20.x

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

This PR add support for binding OAuth2 user automatically. So we can remove the user-binding page.

Please note that those changes may break the OAuth2 and SocialLogin plugins.

#### Special notes for your reviewer:

Build OAuth2 plugin from <https://github.com/halo-sigs/plugin-oauth2/pull/64> or use [plugin-oauth2-1.0.4-SNAPSHOT.zip](https://github.com/user-attachments/files/17177592/plugin-oauth2-1.0.4-SNAPSHOT.zip) I built.

- Bind after logging in

1. Log in Halo with username and password method
2. Try to unbind OAuth2 user
3. Bind OAuth2 user again

- Initially bind without logging in

1. Go to login page
2. Log in with OAuth2 method and you will be redirected to login page
3. Log in with username and password method
4. See the result of binding

- Log in with OAuth2 method after binding

1. Go  to login page
2. Log in with OAuth2 method and you will be redirected to uc page directly

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

```release-note
支持自动绑定 OAuth2 登录用户
```
2024-09-29 10:19:47 +00:00
John Niang 83109d0568
Fix the inaccessible problem of signup page (#6730)
#### 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 confirmPassword field into SignUpData for validation. So the signup page can be rendered correctly.

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

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

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

#### Special notes for your reviewer:

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

```release-note
None
```
2024-09-29 10:01:47 +00:00
guqing cd90771bb7 feat: add API for recycle users own posts 2024-09-29 16:22:44 +08:00
Ryan Wang 1947a544f2
feat: refine i18n resources for login-related page (#6726)
#### What type of PR is this?

/area core
/kind improvement
/milestone 2.20.x

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

完善新登录相关页面的多语言资源文件。

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

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

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

```release-note
None 
```
2024-09-29 08:15:46 +00:00
Ryan Wang f4e3c25035
feat: remove the button for viewing passwords in the Edge browser (#6727)
#### What type of PR is this?

/area core
/kind improvement
/milestone 2.20.x

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

移除在 Edge 浏览器中,为密码输入框添加显示密码明文按钮。

<img width="406" alt="image" src="https://github.com/user-attachments/assets/49801c25-d8dc-46db-9cba-302653af1951">

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

```release-note
None
```
2024-09-29 07:11:46 +00:00
guqing ca9adfc9d8
feat: add index build state as readiness check indicator (#6700)
#### 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 #6632

#### Does this PR introduce a user-facing change?
```release-note
将索引构建状态添加到就绪检测的指标中以优化就绪时访问出现索引不可用的问题
```
2024-09-28 11:05:41 +00:00
guqing a53aa786e1
chore: reorganize package structure for content stats updater (#6699)
#### What type of PR is this?
/milestone 2.20.x
/area core

#### What this PR does / why we need it:
将内容管理相关的数据更新类归档到 content 包下,如访问量和评论量统计

#### Does this PR introduce a user-facing change?
```release-note
None
```
2024-09-28 10:43:42 +00:00
guqing a1fcd51714
fix: thumbnail generation for URI string containing spaces (#6698)
#### What type of PR is this?
/kind improvement
/area core
/milestone 2.20.x

#### What this PR does / why we need it:
修复文章封面图链接包含空格时主题端会因为生成缩略图错误而无法访问的问题

这是由于 URI string 中包含空格无法创建 URI 对象,目前将忽略这种非法参数,如果生成失败则直接返回原始 URI string

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

#### Does this PR introduce a user-facing change?
```release-note
修复文章封面图链接包含空格时主题端会因为生成缩略图错误而无法访问的问题
```
2024-09-28 10:41:42 +00:00
John Niang 9305fd51d8
Merge pull request #6688 from guqing/refactor/6468
fix: resolve 403 error on menu page when system config access is missing
2024-09-28 18:30:50 +08:00
John Niang a4c906706f
Merge pull request #6661 from guqing/refactor/setting-config-update
feat: support JSON-based retrieval and update for theme and plugin configs
2024-09-28 18:17:32 +08:00
Ryan Wang 982a45bd32
Merge branch 'main' into refactor/setting-config-update 2024-09-28 17:52:12 +08:00
Ryan Wang 8547ffe613 Add frontend support for customizing login and logout pages
Signed-off-by: JohnNiang <johnniang@foxmail.com>
2024-09-28 17:38:32 +08:00
JohnNiang 1f9610686b Add backend support for customizing login and logout pages
Signed-off-by: JohnNiang <johnniang@foxmail.com>
2024-09-28 17:37:36 +08:00
John Niang 9710201aa4
Support obtaining ServerWebExchange in ContextView (#6705)
#### What type of PR is this?

/kind feature
/area core
/milestone 2.20.x

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

This PR registers a ServerWebExchangeContextFilter to make ServerWebExchange available under ContextView. The usage example is as follows:

```java
Mono.deferContextual(contextView -> {
    var exchange = ServerWebExchangeContextFilter.getExchange(contextView);
    assertTrue(exchange.isPresent());
    return mono;
})
```

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

```release-note
None
```
2024-09-26 08:43:30 +00:00
Ryan Wang e2e1d1da4e
Merge branch 'main' into refactor/setting-config-update 2024-09-25 15:30:55 +08:00
guqing f6409a0cb0
fix: correct file mime type validation parameter to restore functionality (#6673)
#### What type of PR is this?
/kind bug
/area core
/milestone 2.20.x

#### What this PR does / why we need it:
修复文件上传时类型校验失效的问题

此问题由 #6390 导致

#### Does this PR introduce a user-facing change?
```release-note
修复文件上传时类型校验失效的问题
```
2024-09-25 02:59:25 +00:00
John Niang 86b95ccfd0
Upgrade to Spring Boot 3.4.0-M3 (#6687)
#### What type of PR is this?

/kind cleanup
/area core
/milestone 2.20.x

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

This PR upgrades to [Spring Boot 3.4.0-M3](https://github.com/spring-projects/spring-boot/releases/tag/v3.4.0-M3).

1. Fix the compilation error of OptimalPropertyAccess because the class has been privated in [this commit](b431594021).
2. Fix exception `org.mockito.exceptions.misusing.UnnecessaryStubbingException` for some unit tests after upgrading.
3. Replace deprecated annotations `@MockBean` and `@SpyBean` with `@MockitoBean` and `@MockitoSpyBean` respectively.

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

```release-note
升级 Spring Boot 至 3.4.0-M3
```
2024-09-24 07:01:22 +00:00
guqing dd2080c3ae feat: add API to update system config by group 2024-09-24 12:10:30 +08:00
guqing 9de18d82c3 Merge remote-tracking branch 'upstream/main' into refactor/6468 2024-09-24 11:51:51 +08:00
guqing 9000ad3bb7 Merge remote-tracking branch 'upstream/main' into refactor/setting-config-update 2024-09-24 11:34:10 +08:00
guqing 03368281cc
chore: reorganize package structure in application project (#6691)
* chore: reorganize package structure in application project
2024-09-23 17:59:03 +08:00
John Niang 8b3bde050f
Refactor ReactivePropertyAccessor by wrapping existing PropertyAccessor (#6686)
#### What type of PR is this?

/kind improvement
/area core
/area theme

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

This PR removes ReactivePropertyAccessor because it use `AstUtils#getPropertyAccessorsToTry` which is already hidden  in [the commit](33fbd7141d (diff-deaf3517fbd66f40a8717877a8328dee0fb2581dfb6be487f327dc73ea33b5b5)). If we upgraded to Spring Boot 3.4.0-M3, the code in ReactivePropertyAccessor would be broken.

More importantly, I believe there is one issue with the current implementation although it can resolve the reactive issue.
- The PropertyAccessor modified the process flow of SPEL

This PR provides some wrappers to wrap existing PropertyAccessor and MethodResolver to evaluate reactive return value.

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

```release-note
None
```
2024-09-23 08:47:15 +00:00
guqing 0dcab32712 feat: add API to fetch system configs by group 2024-09-23 16:01:29 +08:00
John Niang df195b12f2
Make ApplicationContext inaccessible in ServerWebExchange (#6679)
#### What type of PR is this?

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

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

Plugins can implement their own RouterFunctions and ControllerMappings, but those might expose root ApplicationContext for plugins, which is not expected.

So this PR fixes the insecure access to root ApplicationContext.

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

```release-note
None
```
2024-09-20 03:16:59 +00:00
John Niang a87dedd916
Make ApplicationContext inaccessible in ITemplateContext (#6680)
#### What type of PR is this?

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

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

This PR disables access to ApplicationContext using ITemplateContext.

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

```release-note
None
```
2024-09-20 03:14:58 +00:00
John Niang fb9aff00ca
Add chunked transfer support for rendering templates (#6580)
#### 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 chunked transfer support for rendering templates, which means that the max memory used by rendering template will be max chunk size instead of size of rendering result.

Users can define the max chunk size like below:

```yaml
spring:
  thymeleaf:
    reactive:
      maxChunkSize: 8KB # Setting to 0 will disable the chunked response.
```

#### Special notes for your reviewer:

1. Try to start Halo instance
2. Execute the command like below and see if the response headers contain `transfer-encoding: chunked`:
		
    ```bash
	http http://localhost:8090/ -p h
	HTTP/1.1 200 OK
	Cache-Control: no-cache, no-store, max-age=0, must-revalidate
	Content-Language: en-CN
	Content-Type: text/html
	Expires: 0
	Pragma: no-cache
	Referrer-Policy: strict-origin-when-cross-origin
	Vary: Origin
	Vary: Access-Control-Request-Method
	Vary: Access-Control-Request-Headers
	X-Content-Type-Options: nosniff
	X-Frame-Options: SAMEORIGIN
	X-XSS-Protection: 0
	content-encoding: gzip
	set-cookie: XSRF-TOKEN=1e677724-ce82-4b63-911c-f78b22cd9169; Path=/
	transfer-encoding: chunked
	```

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

```release-note
优化模板渲染时所需的内存
```
2024-09-19 10:16:55 +00:00
guqing 1c31917778
chore: replace deprecated Version methods with updated API (#6678)
#### What type of PR is this?
/milestone 2.20.x
/area core

#### What this PR does / why we need it:
替换 Version 过时方法的引用为新 API

#### Does this PR introduce a user-facing change?
```release-note
None
```
2024-09-19 07:50:55 +00:00
guqing dcadd38843
feat: add Halo version variable to theme model (#6677)
#### What type of PR is this?
/kind feature
/milestone 2.20.x
/area theme

#### What this PR does / why we need it:
主题支持通过 `${site.version}` 得到 Halo 版本号

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

#### Does this PR introduce a user-facing change?
```release-note
主题支持通过 `${site.version}` 得到 Halo 版本号
```
2024-09-19 07:20:54 +00:00
John Niang 07077f7d0c
Provide ElementTagProcessor to handle element tag in plugin (#6670)
#### What type of PR is this?

/kind feature
/area plugin

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

This PR provides an interface ElementTagProcessor to make plugin handle element tag easily. e.g.:

```java
public class ImgTagProcessor implements ElementTagPostProcessor {

    @Override
    public Mono<Void> process(ITemplateContext context, IProcessableElementTag tag,
        IElementTagStructureHandler structureHandler) {
        var elementName = tag.getElementDefinition().getElementName();
        if (!Objects.equals("img", elementName.getElementName())) {
            return Mono.empty();
        }
        var srcAttr = tag.getAttribute("src");
        if (srcAttr == null) {
            return Mono.empty();
        }
        var newSrc = srcAttr.getValue();
        // TODO rewrite src
        structureHandler.setAttribute("src", newSrc);
        return Mono.empty();
    }
    
}
```

After PR merged, plugins https://github.com/webp-sh/halo-plugin-webp-cloud and https://github.com/guqing/plugin-cloudinary can be refined with new method.

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

```release-note
支持在插件中操作渲染结果
```
2024-09-19 02:56:53 +00:00
John Niang ded5b4135f
Generate JS and CSS bundle with fixed buffer size (#6573)
#### What type of PR is this?

/kind improvement
/area core
/milestone 2.20.x

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

If we are running Halo instance in machine with small memory available, the JS/CSS bundle might  not be accessible.

This RP refactors generation of JS and CSS bundle with fixed buffer size rather than length of original resources.

```java
2024-09-02T15:01:27.667+08:00  WARN 62039 --- [boundedElastic-3] reactor.core.Exceptions                  : throwIfFatal detected a jvm fatal exception, which is thrown and logged below:

java.lang.OutOfMemoryError: Java heap space
        at java.base/java.nio.HeapByteBuffer.<init>(HeapByteBuffer.java:64) ~[na:na]
        at java.base/java.nio.ByteBuffer.allocate(ByteBuffer.java:363) ~[na:na]
        at org.springframework.core.io.buffer.DefaultDataBuffer.allocate(DefaultDataBuffer.java:234) ~[spring-core-6.1.12.jar:6.1.12]
        at org.springframework.core.io.buffer.DefaultDataBuffer.setCapacity(DefaultDataBuffer.java:196) ~[spring-core-6.1.12.jar:6.1.12]
        at org.springframework.core.io.buffer.DefaultDataBuffer.ensureWritable(DefaultDataBuffer.java:228) ~[spring-core-6.1.12.jar:6.1.12]
        at org.springframework.core.io.buffer.DefaultDataBuffer.write(DefaultDataBuffer.java:296) ~[spring-core-6.1.12.jar:6.1.12]
        at org.springframework.core.io.buffer.DefaultDataBuffer.write(DefaultDataBuffer.java:289) ~[spring-core-6.1.12.jar:6.1.12]
        at org.springframework.core.io.buffer.DefaultDataBuffer.write(DefaultDataBuffer.java:43) ~[spring-core-6.1.12.jar:6.1.12]
        at run.halo.app.core.extension.service.impl.PluginServiceImpl.lambda$uglifyJsBundle$17(PluginServiceImpl.java:257) ~[classes/:na]
        at run.halo.app.core.extension.service.impl.PluginServiceImpl$$Lambda$4661/0x000000c80214e298.accept(Unknown Source) ~[na:na]
        at reactor.core.publisher.FluxPeekFuseable$PeekFuseableSubscriber.onNext(FluxPeekFuseable.java:196) ~[reactor-core-3.6.9.jar:3.6.9]
        at reactor.core.publisher.FluxUsing$UsingFuseableSubscriber.onNext(FluxUsing.java:353) ~[reactor-core-3.6.9.jar:3.6.9]
        at reactor.core.publisher.FluxGenerate$GenerateSubscription.next(FluxGenerate.java:178) ~[reactor-core-3.6.9.jar:3.6.9]
        at org.springframework.core.io.buffer.DataBufferUtils$ReadableByteChannelGenerator.accept(DataBufferUtils.java:1002) ~[spring-core-6.1.12.jar:6.1.12]
        at org.springframework.core.io.buffer.DataBufferUtils$ReadableByteChannelGenerator.accept(DataBufferUtils.java:974) ~[spring-core-6.1.12.jar:6.1.12]
        at reactor.core.publisher.FluxGenerate.lambda$new$1(FluxGenerate.java:58) ~[reactor-core-3.6.9.jar:3.6.9]
        at reactor.core.publisher.FluxGenerate$$Lambda$4155/0x000000c802069228.apply(Unknown Source) ~[na:na]
        at reactor.core.publisher.FluxGenerate$GenerateSubscription.slowPath(FluxGenerate.java:271) ~[reactor-core-3.6.9.jar:3.6.9]
        at reactor.core.publisher.FluxGenerate$GenerateSubscription.request(FluxGenerate.java:213) ~[reactor-core-3.6.9.jar:3.6.9]
        at reactor.core.publisher.FluxUsing$UsingFuseableSubscriber.request(FluxUsing.java:320) ~[reactor-core-3.6.9.jar:3.6.9]
        at reactor.core.publisher.FluxPeekFuseable$PeekFuseableSubscriber.request(FluxPeekFuseable.java:144) ~[reactor-core-3.6.9.jar:3.6.9]
        at reactor.core.publisher.FluxFlatMap$FlatMapInner.onSubscribe(FluxFlatMap.java:968) ~[reactor-core-3.6.9.jar:3.6.9]
        at reactor.core.publisher.FluxPeekFuseable$PeekFuseableSubscriber.onSubscribe(FluxPeekFuseable.java:178) ~[reactor-core-3.6.9.jar:3.6.9]
        at reactor.core.publisher.FluxUsing$UsingFuseableSubscriber.onSubscribe(FluxUsing.java:347) ~[reactor-core-3.6.9.jar:3.6.9]
        at reactor.core.publisher.FluxGenerate.subscribe(FluxGenerate.java:85) ~[reactor-core-3.6.9.jar:3.6.9]
        at reactor.core.publisher.FluxUsing.subscribe(FluxUsing.java:102) ~[reactor-core-3.6.9.jar:3.6.9]
        at reactor.core.publisher.Flux.subscribe(Flux.java:8848) ~[reactor-core-3.6.9.jar:3.6.9]
        at reactor.core.publisher.FluxFlatMap$FlatMapMain.onNext(FluxFlatMap.java:430) ~[reactor-core-3.6.9.jar:3.6.9]
        at reactor.core.publisher.FluxHandleFuseable$HandleFuseableSubscriber.tryOnNext(FluxHandleFuseable.java:135) ~[reactor-core-3.6.9.jar:3.6.9]
        at reactor.core.publisher.FluxIterable$IterableSubscriptionConditional.slowPath(FluxIterable.java:664) ~[reactor-core-3.6.9.jar:3.6.9]
        at reactor.core.publisher.FluxIterable$IterableSubscriptionConditional.request(FluxIterable.java:623) ~[reactor-core-3.6.9.jar:3.6.9]
        at reactor.core.publisher.FluxHandleFuseable$HandleFuseableSubscriber.request(FluxHandleFuseable.java:260) ~[reactor-core-3.6.9.jar:3.6.9]

2024-09-02T15:01:27.681+08:00 DEBUG 62039 --- [boundedElastic-3] a.w.r.e.AbstractErrorWebExceptionHandler : [131a559b-102] Resolved [OutOfMemoryError: Java heap space] for HTTP GET /apis/api.console.halo.run/v1alpha1/plugins/-/bundle.js
2024-09-02T15:01:27.681+08:00 ERROR 62039 --- [boundedElastic-3] a.w.r.e.AbstractErrorWebExceptionHandler : [131a559b-102]  500 Server Error for HTTP GET "/apis/api.console.halo.run/v1alpha1/plugins/-/bundle.js?v=1725260408176"

java.lang.OutOfMemoryError: Java heap space
        at java.base/java.nio.HeapByteBuffer.<init>(HeapByteBuffer.java:64) ~[na:na]
```

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

```release-note
优化在内存紧张时 Console 端无法加载插件资源的问题
```
2024-09-18 08:22:50 +00:00
guqing 749c80cb96
chore: cleanup subscription integration test (#6671)
#### What type of PR is this?
/kind cleanup
/area core
/milestone 2.20.x

#### What this PR does / why we need it:
删除 SubscriptionServiceIntegrationTest 类。因为当前测试类不经常性出错,暂时无法排查原因。

#### Does this PR introduce a user-facing change?
```release-note
None
```
2024-09-18 04:18:49 +00:00
guqing a634065d48 feat: support JSON-based retrieval and update for theme and plugin configs 2024-09-14 16:10:31 +08:00
guqing 3fda9e6db4
refactor: remove trailing slash in site url for notification (#6660)
#### What type of PR is this?
/kind improvement
/area core
/milestone 2.20.x

#### What this PR does / why we need it:
修复 external-url 配置带了尾部斜杠导致邮件通知的查看通知链接无法访问的问题

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

#### Does this PR introduce a user-facing change?
```release-note
修复 external-url 配置带了尾部斜杠导致邮件通知的查看通知链接无法访问的问题
```
2024-09-14 07:16:31 +00:00
John Niang a9c0ecebe3
Support resolving i18n message with standard way (#6648)
#### What type of PR is this?

/kind feature
/area theme
/sig docs
/milestone 2.20.x

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

After this PR, we can define i18n message files next to the template file.

```yaml
i18n:
    default.properties
templates:
    index.html
    index.properties # Higher properties than default.properties
    index_zh.properties # Higher properties than index.properties
    index_zh_CN.properties # Higher priority than index_zh.properties
```

It's convenient for plugins that define the template files.

See https://www.thymeleaf.org/doc/tutorials/3.1/usingthymeleaf.html#standard-message-resolver for more.

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

```release-note
支持在主题中通过 Thymeleaf 默认行为实现国际化
```
2024-09-14 02:52:30 +00:00
John Niang c5f9c766bb
Support changing locale using query language (#6658)
#### 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 changing locale using query `language`. After passing the query, we will automatically respond a cookie `language` back to browser.

Please see the result below:

```bash
http http://localhost:8090/\?language\=zh-CN Accept:text/html -p h

HTTP/1.1 200 OK
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Content-Language: zh-CN
Content-Type: text/html
Expires: 0
Pragma: no-cache
Referrer-Policy: strict-origin-when-cross-origin
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 0
content-encoding: gzip
content-length: 4765
set-cookie: language=zh-CN; Path=/; Secure
set-cookie: XSRF-TOKEN=f0f2c972-0024-4575-aef2-0609356b4757; Path=/
```

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

```release-note
支持利用参数 language 切换地域语言
```
2024-09-14 02:48:29 +00:00
John Niang 8ab8a440b6
Simplify ThemeLocaleContextResolver (#6651)
#### What type of PR is this?

/kind improvement
/area theme
/milestone 2.20.x

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

This PR simplifies ThemeLocaleContextResolver by removing unused attributes. 

In another PR <https://github.com/halo-dev/halo/pull/6647>, fixed locale resolution for query parameter `language`. This PR fixes locale resolution for cookie `language` as well.

Please see the results below:

```bash
http https://www.halo.run/ Cookie:language=zh-CN -p h

HTTP/1.1 200 OK
Content-Language: und
```

```bash
http http://localhost:8090 Cookie:language=zh-CN -p h

HTTP/1.1 200 OK
Content-Language: zh-CN
```

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

```release-note
None
```
2024-09-13 07:44:26 +00:00
guqing 7ed859cefb
refactor: prevent replies to comments that are pending approval (#6622)
#### 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-09-13 02:14:25 +00:00
guqing 07d200b45b
Trigger attachment status update on storage policy config change (#6639) 2024-09-12 17:13:19 +08:00
John Niang 6a5e9c4932
Fix the problem of resolving locale context by language parameter (#6647)
#### What type of PR is this?

/kind bug
/area theme
/milestone 2.20.x

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

If we pass a query `language` while requesting index page, we will get the wrong header `Content-Language`. Please see the result below:

```bash
http https://www.halo.run/\?language\=zh-CN -p h

HTTP/1.1 200 OK
Content-Language: und
...
```

After fixing, we will get the right header `Content-Language`.

```bash
http http://localhost:8090/\?language\=zh-CN -p h

HTTP/1.1 200 OK
Content-Language: zh-CN
...
```

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

```release-note
修复主题端区域和语言解析错误的问题
```
2024-09-12 09:12:22 +00:00
John Niang ba18f7010b
Update attachment permalink only when handler is available (#6641) 2024-09-12 11:02:21 +08:00