Commit Graph

2187 Commits (84eef5460322ad54530fa57b8572021c7e9b4489)

Author SHA1 Message Date
John Niang 84eef54603
Add Menu and MenuItem Extension (#2303)
#### What type of PR is this?

/kind feature
/area core
/kind api-change
/milestone 2.0

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

Add Menu and MenuItem Extension to realise multi menu feature.

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

```release-note
添加菜单功能
```
2022-08-11 15:52:14 +00:00
guqing 7026681747
feat: add theme uninstall endpoint (#2315)
<!--  Thanks for sending a pull request!  Here are some tips for you:
1. 如果这是你的第一次,请阅读我们的贡献指南:<https://github.com/halo-dev/halo/blob/master/CONTRIBUTING.md>。
1. If this is your first time, please read our contributor guidelines: <https://github.com/halo-dev/halo/blob/master/CONTRIBUTING.md>.
2. 请根据你解决问题的类型为 Pull Request 添加合适的标签。
2. Please label this pull request according to what type of issue you are addressing, especially if this is a release targeted pull request.
3. 请确保你已经添加并运行了适当的测试。
3. Ensure you have added or ran the appropriate tests for your PR.
-->

#### What type of PR is this?
/kind feature
/milestone 2.0
/area core
/kind api-change
<!--
添加其中一个类别:
Add one of the following kinds:

/kind bug
/kind cleanup
/kind documentation
/kind feature
/kind improvement

适当添加其中一个或多个类别(可选):
Optionally add one or more of the following kinds if applicable:

/kind api-change
/kind deprecation
/kind failing-test
/kind flake
/kind regression
-->

#### What this PR does / why we need it:
新增主题卸载 endpoint

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

<!--
PR 合并时自动关闭 issue。
Automatically closes linked issue when PR is merged.

用法:`Fixes #<issue 号>`,或者 `Fixes (粘贴 issue 完整链接)`
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->
Fixes #2306

#### Special notes for your reviewer:
/cc @halo-dev/sig-halo 
#### 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
```
2022-08-10 09:12:21 +00:00
guqing 349db687e3
feat: add theme install endpoint (#2302)
<!--  Thanks for sending a pull request!  Here are some tips for you:
1. 如果这是你的第一次,请阅读我们的贡献指南:<https://github.com/halo-dev/halo/blob/master/CONTRIBUTING.md>。
1. If this is your first time, please read our contributor guidelines: <https://github.com/halo-dev/halo/blob/master/CONTRIBUTING.md>.
2. 请根据你解决问题的类型为 Pull Request 添加合适的标签。
2. Please label this pull request according to what type of issue you are addressing, especially if this is a release targeted pull request.
3. 请确保你已经添加并运行了适当的测试。
3. Ensure you have added or ran the appropriate tests for your PR.
-->

#### What type of PR is this?
/kind feature
/area core
/milestone 2.0
<!--
添加其中一个类别:
Add one of the following kinds:

/kind bug
/kind cleanup
/kind documentation
/kind feature
/kind improvement

适当添加其中一个或多个类别(可选):
Optionally add one or more of the following kinds if applicable:

/kind api-change
/kind deprecation
/kind failing-test
/kind flake
/kind regression
-->

#### What this PR does / why we need it:
新增主题安装功能,endpoint:POST /apis/api.halo.run/v1alpha1/themes/install
限制:主题不允许重复安装,重复安装属于更新功能
#### Which issue(s) this PR fixes:

<!--
PR 合并时自动关闭 issue。
Automatically closes linked issue when PR is merged.

用法:`Fixes #<issue 号>`,或者 `Fixes (粘贴 issue 完整链接)`
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->
Fixes #2291

#### Special notes for your reviewer:
/cc @halo-dev/sig-halo 
#### 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
```
2022-08-04 09:24:16 +00:00
guqing ebecef89c6
refactor: support configuration settings and configmap name (#2299)
<!--  Thanks for sending a pull request!  Here are some tips for you:
1. 如果这是你的第一次,请阅读我们的贡献指南:<https://github.com/halo-dev/halo/blob/master/CONTRIBUTING.md>。
1. If this is your first time, please read our contributor guidelines: <https://github.com/halo-dev/halo/blob/master/CONTRIBUTING.md>.
2. 请根据你解决问题的类型为 Pull Request 添加合适的标签。
2. Please label this pull request according to what type of issue you are addressing, especially if this is a release targeted pull request.
3. 请确保你已经添加并运行了适当的测试。
3. Ensure you have added or ran the appropriate tests for your PR.
-->

#### What type of PR is this?
/kind improvement
/area core
/milestone 2.0
<!--
添加其中一个类别:
Add one of the following kinds:

/kind bug
/kind cleanup
/kind documentation
/kind feature
/kind improvement

适当添加其中一个或多个类别(可选):
Optionally add one or more of the following kinds if applicable:

/kind api-change
/kind deprecation
/kind failing-test
/kind flake
/kind regression
-->

#### What this PR does / why we need it:
主题支持配置 settingName 和 configMapName

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

<!--
PR 合并时自动关闭 issue。
Automatically closes linked issue when PR is merged.

用法:`Fixes #<issue 号>`,或者 `Fixes (粘贴 issue 完整链接)`
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->
Fixes #2298

#### Special notes for your reviewer:
/cc @halo-dev/sig-halo 
#### 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
```
2022-08-03 15:14:15 +00:00
guqing 3d38979d80
feat: Theme temporals supports time zone (#2297)
<!--  Thanks for sending a pull request!  Here are some tips for you:
1. 如果这是你的第一次,请阅读我们的贡献指南:<https://github.com/halo-dev/halo/blob/master/CONTRIBUTING.md>。
1. If this is your first time, please read our contributor guidelines: <https://github.com/halo-dev/halo/blob/master/CONTRIBUTING.md>.
2. 请根据你解决问题的类型为 Pull Request 添加合适的标签。
2. Please label this pull request according to what type of issue you are addressing, especially if this is a release targeted pull request.
3. 请确保你已经添加并运行了适当的测试。
3. Ensure you have added or ran the appropriate tests for your PR.
-->

#### What type of PR is this?
/kind feature
/area core
/milestone 2.0
<!--
添加其中一个类别:
Add one of the following kinds:

/kind bug
/kind cleanup
/kind documentation
/kind feature
/kind improvement

适当添加其中一个或多个类别(可选):
Optionally add one or more of the following kinds if applicable:

/kind api-change
/kind deprecation
/kind failing-test
/kind flake
/kind regression
-->

#### What this PR does / why we need it:
主题可以通过 temporals 表达式方言来格式化日期,格式化时会根据时区显示,例如:`${#temporals.format(instants, 'yyyy-MM-dd HH:mm:ss')}`
访问主题时通过携带 cookie 如 cookie:time_zone=Africa/Accra 来切换时区

支持的时区列表参考:https://jenkov.com/tutorials/java-date-time/java-util-timezone.html
表达式更多用法参考:https://github.com/thymeleaf/thymeleaf-extras-java8time
#### Which issue(s) this PR fixes:

<!--
PR 合并时自动关闭 issue。
Automatically closes linked issue when PR is merged.

用法:`Fixes #<issue 号>`,或者 `Fixes (粘贴 issue 完整链接)`
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->
Fixes #2293

#### Special notes for your reviewer:
/cc @halo-dev/sig-halo 
#### 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
```
2022-08-03 10:24:15 +00:00
John Niang 86f9daf421
Replace JSON schema with OpenAPI 3.0 (#2300)
#### What type of PR is this?

/kind improvement
/area core
/milestone 2.0

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

This PR introduces [openapi4j](https://github.com/openapi4j/openapi4j) to replace JSON schema. See #2294 for more.

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

Fix #2294

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

```release-note
None
```
2022-08-03 03:34:14 +00:00
guqing 3302ce68c9
feat: specific implementation of theme design (#2280)
<!--  Thanks for sending a pull request!  Here are some tips for you:
1. 如果这是你的第一次,请阅读我们的贡献指南:<https://github.com/halo-dev/halo/blob/master/CONTRIBUTING.md>。
1. If this is your first time, please read our contributor guidelines: <https://github.com/halo-dev/halo/blob/master/CONTRIBUTING.md>.
2. 请根据你解决问题的类型为 Pull Request 添加合适的标签。
2. Please label this pull request according to what type of issue you are addressing, especially if this is a release targeted pull request.
3. 请确保你已经添加并运行了适当的测试。
3. Ensure you have added or ran the appropriate tests for your PR.
-->

#### What type of PR is this?
/kind feature
/area core
/milestone 2.0
<!--
添加其中一个类别:
Add one of the following kinds:

/kind bug
/kind cleanup
/kind documentation
/kind feature
/kind improvement

适当添加其中一个或多个类别(可选):
Optionally add one or more of the following kinds if applicable:

/kind api-change
/kind deprecation
/kind failing-test
/kind flake
/kind regression
-->

#### What this PR does / why we need it:
主题设计的具体实现
https://github.com/halo-dev/rfcs/tree/main/theme

1. 主题支持多语言,在主题目录的 i18n目录下
2. 主题支持预览,但暂未添加是否开启预览的限制
3. 主题及语言文件默认支持缓存,但暂未支持是否关闭缓存选项
4. 主题名称与主题目录必须一致
5. 主题可以通过添加参数 language 来切换语言,例如 /post?language=en
```text
├── i18n
│   └── default.properties
│   └── en.properties
├── templates
│   └── assets
      ├── css
      │   └── style.css
      ├── js
      │   └── main.js
│   └── index.html
├── README.md
└── settings.yaml
└── theme.yaml
```
#### Which issue(s) this PR fixes:

<!--
PR 合并时自动关闭 issue。
Automatically closes linked issue when PR is merged.

用法:`Fixes #<issue 号>`,或者 `Fixes (粘贴 issue 完整链接)`
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->
Fixes #

#### Special notes for your reviewer:
/cc @halo-dev/sig-halo 
#### 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
```
2022-08-02 09:04:13 +00:00
John Niang bd6c2a544b
Add IN operator for fieldSelector and labelSelector (#2290)
#### What type of PR is this?

/kind feature
/kind api-change
/area core
/milestone 2.0
/release-note-none

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

- Add `IN` operator for fieldSelector and labelSelector.
- Adapt name field selector with `IN` operator.

```release-note
None
```
2022-08-02 04:24:12 +00:00
John Niang 3640dca0a1
Add label and field selector to Extension list API (#2279)
#### What type of PR is this?

/kind feature
/kind api-change
/area core
/milestone 2.0

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

Add label and field selector to Extension list API for filtering Extensions.

<img width="322" alt="image" src="https://user-images.githubusercontent.com/16865714/181462887-549162fd-5e8d-4cec-834c-24875ada4789.png">

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

```release-note
None
```
2022-07-29 05:22:14 +00:00
John Niang fdbb513cb2
Add all-api group for swagger (#2278)
#### What type of PR is this?

/kind improvement
/area core
/milestone 2.0

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

Add all-api group for swagger. Related to https://github.com/halo-dev/halo/pull/2273.

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

```release-note
None
```
2022-07-27 10:46:13 +00:00
John Niang 5eec9da2e6
Initialize required extensions when system starts up (#2274)
#### What type of PR is this?

/kind improvement
/area core
/milestone 2.0

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

This PR makes required extensions got initialized when system starts up. Of course, we can stop the initialization by setting property `halo.required-extension-disabled=true`.

Secondly, we are using [PathMatchingResourcePatternResolver](https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/core/io/support/PathMatchingResourcePatternResolver.html) support more functional Extension locations, please see the doc for more.

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

```release-note
None
```
2022-07-26 03:52:13 +00:00
John Niang 71f9209006
Refine Swagger API with group (#2273)
#### What type of PR is this?

/kind feature
/area core
/milestone 2.0

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

1. Add grouped OpenAPI

    <img width="505" alt="image" src="https://user-images.githubusercontent.com/16865714/180638783-acd5f437-b5d0-4701-9ebb-3221540f167c.png">

3. Enable basic authentication on API endpoints.

    ```bash
    curl -s -u admin:iY4PcvZLN4Dm0woV --basic 'http://localhost:8090/api/v1alpha1/users'
    ```

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

```release-note
None
```
2022-07-25 04:24:10 +00:00
guqing d85c83bf6e
refactor: plugin components finder to avoid cannot be started after installing the plugin (#2272)
<!--  Thanks for sending a pull request!  Here are some tips for you:
1. 如果这是你的第一次,请阅读我们的贡献指南:<https://github.com/halo-dev/halo/blob/master/CONTRIBUTING.md>。
1. If this is your first time, please read our contributor guidelines: <https://github.com/halo-dev/halo/blob/master/CONTRIBUTING.md>.
2. 请根据你解决问题的类型为 Pull Request 添加合适的标签。
2. Please label this pull request according to what type of issue you are addressing, especially if this is a release targeted pull request.
3. 请确保你已经添加并运行了适当的测试。
3. Ensure you have added or ran the appropriate tests for your PR.
-->

#### What type of PR is this?
/kind improvement
/milestone 2.0
/area core
<!--
添加其中一个类别:
Add one of the following kinds:

/kind bug
/kind cleanup
/kind documentation
/kind feature
/kind improvement

适当添加其中一个或多个类别(可选):
Optionally add one or more of the following kinds if applicable:

/kind api-change
/kind deprecation
/kind failing-test
/kind flake
/kind regression
-->

#### What this PR does / why we need it:
使用 SpringComponentsFinder 覆盖 pf4j 默认实现的插件组件类缓存逻辑,以解决插件安装后缓存没有更新导致插件类加载不正确问题
原问题浮现步骤:
1. 先删除插件目录的所有插件
2. 通过接口上传一个插件`apis/api.halo.run/v1alpha1/plugins/install`
3. 启动它
4. 再上传另一个插件并启动它就会发现这个插件无法启动

现在修复过后可以重复测试上述步骤并观察日志显示的插件组件是否被正确加载,再此之前你可能需要配置以下日志级别
```
logging:
  level:
    org.pf4j.AbstractExtensionFinder: DEBUG
```
启动插件时观察这样的日志是否符合预期:
```
r.h.app.plugin.SpringComponentsFinder    : Read 'META-INF/plugin-components.idx'
org.pf4j.AbstractExtensionFinder         : Found possible 2 extensions:
org.pf4j.AbstractExtensionFinder         :    run.halo.template.TemplatePlugin
org.pf4j.AbstractExtensionFinder         :    run.halo.template.ApplesController
r.h.app.plugin.SpringComponentsFinder    : Load [2] component names into storage cache for plugin [PluginTemplate].
```
可以结合此 PR 上传插件进行测试 https://github.com/halo-dev/halo-admin/pull/590
#### Which issue(s) this PR fixes:

<!--
PR 合并时自动关闭 issue。
Automatically closes linked issue when PR is merged.

用法:`Fixes #<issue 号>`,或者 `Fixes (粘贴 issue 完整链接)`
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->
Fixes #

#### Special notes for your reviewer:
/cc @halo-dev/sig-halo 
#### 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
```
2022-07-23 12:40:10 +00:00
John Niang 0b4b1c321b
Provide an endpoint to install plugin using Jar file (#2271)
#### What type of PR is this?

/kind feature
/area core
/milestone 2.0

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

Provide an endpoint to install plugin using Jar file.

#### Special notes for your reviewer:

Currently, you could login and open the swagger ui to test against this feature.

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

```release-note
None
```
2022-07-22 10:11:51 +00:00
John Niang 4cb94d3752
Upgrade Spring Boot to 3.0.0-M4 (#2269)
#### What type of PR is this?

/kind flake
/area core
/milestone 2.0

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

Upgrade Spring Boot to 3.0.0-M4. Please see <https://github.com/spring-projects/spring-boot/releases/tag/v3.0.0-M4>.

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

```release-note
None
```
2022-07-22 03:13:50 +00:00
John Niang 50932fc2a9
Refactor deletion of Extension in Extension client (#2267)
#### What type of PR is this?

/kind improvement
/area core
/milestone 2.0

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

Do not delete directly when invoking ExtensionClient#delete. We just flag it by setting metadata.deletionTimestamp.

The rest should be done by garbage collector.

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

```release-note
None
```
2022-07-21 06:29:52 +00:00
guqing bb0b5b26e2
feat: add plugin initial resource cleanup when plugin stop (#2262)
* refactor: the way of plugin extension update

* feat: add plugin initial resource cleanup when plugin stop

* refactor: remove role delete watcher
2022-07-20 14:35:24 +08:00
guqing ba20f71504
feat: add role templates for system (#2260)
* feat: add role templates for system

* fix: permissions manage config

* feat: add hidden labels

* feat: add ui permissions for role template

* fix: user password change definition
2022-07-20 14:35:07 +08:00
John Niang 9ed0dcafcc
Change image name to halo-dev (#2264) 2022-07-19 23:47:36 +08:00
guqing 275df33d75
refactor: scanning of the jsBundleRule for plugins (#2249)
<!--  Thanks for sending a pull request!  Here are some tips for you:
1. 如果这是你的第一次,请阅读我们的贡献指南:<https://github.com/halo-dev/halo/blob/master/CONTRIBUTING.md>。
1. If this is your first time, please read our contributor guidelines: <https://github.com/halo-dev/halo/blob/master/CONTRIBUTING.md>.
2. 请根据你解决问题的类型为 Pull Request 添加合适的标签。
2. Please label this pull request according to what type of issue you are addressing, especially if this is a release targeted pull request.
3. 请确保你已经添加并运行了适当的测试。
3. Ensure you have added or ran the appropriate tests for your PR.
-->

#### What type of PR is this?
/kind improvement
/area core
/milestone 2.0
<!--
添加其中一个类别:
Add one of the following kinds:

/kind bug
/kind cleanup
/kind documentation
/kind feature
/kind improvement

适当添加其中一个或多个类别(可选):
Optionally add one or more of the following kinds if applicable:

/kind api-change
/kind deprecation
/kind failing-test
/kind flake
/kind regression
-->

#### What this PR does / why we need it:
重构 JsBundle 获取方式,增加对 js entry 的文件校验如果不存在,则启用插件时不生成反向代理 APIs
#### Which issue(s) this PR fixes:

<!--
PR 合并时自动关闭 issue。
Automatically closes linked issue when PR is merged.

用法:`Fixes #<issue 号>`,或者 `Fixes (粘贴 issue 完整链接)`
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->
Fixes #

#### Special notes for your reviewer:
/cc @halo-dev/sig-halo 
#### 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
```
2022-07-18 14:42:04 +00:00
John Niang 1571b9bcf8
Add an API to change password of user (#2250)
#### What type of PR is this?

/kind feature
/area core
/milestone 2.0

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

This PR provides an API to change password of user. If the username is equal to `-`, we will change the password of current login user. Otherwise, we update the password according the request URI.

Here is an example:

- Request

```bash
curl -X 'PUT' \
  'http://localhost:8090/apis/api.halo.run/v1alpha1/users/-/password' \
  -H 'accept: */*' \
  -H 'Content-Type: */*' \
  -d '{
  "password": "openhalo"
}'
```

- Response

```json
{
  "spec": {
    "displayName": "Administrator",
    "email": "admin@halo.run",
    "password": "{bcrypt}$2a$10$/v8/nbxoUFGBDoWfOF2NHOHk.2RS0OFfS5AtN2g/mCGjScX19KvSG",
    "registeredAt": "2022-07-15T07:50:25.151513387Z",
    "twoFactorAuthEnabled": false,
    "disabled": false
  },
  "apiVersion": "v1alpha1",
  "kind": "User",
  "metadata": {
    "name": "admin",
    "annotations": {
      "rbac.authorization.halo.run/role-names": "[\"super-role\"]"
    },
    "version": 5,
    "creationTimestamp": "2022-07-15T07:50:25.255909669Z"
  }
}
```
#### Which issue(s) this PR fixes:

<!--
PR 合并时自动关闭 issue。
Automatically closes linked issue when PR is merged.

用法:`Fixes #<issue 号>`,或者 `Fixes (粘贴 issue 完整链接)`
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->
Fixes #

#### Special notes for your reviewer:

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

```release-note
None
```
2022-07-18 04:18:11 +00:00
guqing 49ea6fbdec
feat: plugin class is registered as a bean at startup (#2255)
<!--  Thanks for sending a pull request!  Here are some tips for you:
1. 如果这是你的第一次,请阅读我们的贡献指南:<https://github.com/halo-dev/halo/blob/master/CONTRIBUTING.md>。
1. If this is your first time, please read our contributor guidelines: <https://github.com/halo-dev/halo/blob/master/CONTRIBUTING.md>.
2. 请根据你解决问题的类型为 Pull Request 添加合适的标签。
2. Please label this pull request according to what type of issue you are addressing, especially if this is a release targeted pull request.
3. 请确保你已经添加并运行了适当的测试。
3. Ensure you have added or ran the appropriate tests for your PR.
-->

#### What type of PR is this?
/kind feature
/milestone 2.0
/area core
<!--
添加其中一个类别:
Add one of the following kinds:

/kind bug
/kind cleanup
/kind documentation
/kind feature
/kind improvement

适当添加其中一个或多个类别(可选):
Optionally add one or more of the following kinds if applicable:

/kind api-change
/kind deprecation
/kind failing-test
/kind flake
/kind regression
-->

#### What this PR does / why we need it:
插件 plugin.yaml 中不用在写 pluginClass 属性,插件的生命周期类通过标注 `@Component` 注解在启动时通过 PluginApplicationContext 依赖注入并创建实例,这得益于每个插件都有一个单独的 PluginApplicationContext 插件启动时可以将PluginWrapper 放到 Context 以支撑 pluginClass 实例的创建
```yaml
apiVersion: plugin.halo.run/v1alpha1
kind: Plugin
metadata:
  # The name defines how the plugin is invoked,A unique name
  name: PluginTemplate
spec:
  pluginClass: run.halo.template.TemplatePlugin
```
现在只需要如下方式即可无需配置 pluginClass
```java
@Component
public class TemplatePlugin extends BasePlugin {}
```
#### Which issue(s) this PR fixes:

<!--
PR 合并时自动关闭 issue。
Automatically closes linked issue when PR is merged.

用法:`Fixes #<issue 号>`,或者 `Fixes (粘贴 issue 完整链接)`
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->
Fixes #

#### Special notes for your reviewer:
/cc @halo-dev/sig-halo 
#### 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
```
2022-07-18 02:56:10 +00:00
John Niang ca3cff277a
Create super admin initializer and run extension controllers conditionally (#2248)
#### What type of PR is this?

/kind improvement
/kind failing-test
/area core
/milestone 2.0

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

Before this PR, our unit tests were flaky to run. After my inspection, I found that extension controllers will run asynchronously at every unit test that is annotated `@SpringBootTest` annotation. Please see the log of failing test:

```java
ExtensionConfigurationTest > shouldReturnNotFoundWhenSchemeNotRegistered() FAILED
    java.lang.AssertionError at ExtensionConfigurationTest.java:72
```

So this PR makes Halo create super admin initializer and run extension controllers conditionally, especially in tests.

You can configure the following property to disable super admin initialization and extension controllers running:

```yaml
halo:
  security:
    initializer:
      disabled: true
  extension:
    controller:
      disabled: true
```

BTW, we can configure the initial username and password for super administrator:

```yaml
halo:
  security:
    initializer:
      super-admin-username: admin
      super-admin-password: P@88w0rd
```

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

Fixes #

#### Special notes for your reviewer:

#### 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
```
2022-07-15 06:43:09 +00:00
guqing 7000885133
refactor: super administrator role has all UI permissions (#2247)
<!--  Thanks for sending a pull request!  Here are some tips for you:
1. 如果这是你的第一次,请阅读我们的贡献指南:<https://github.com/halo-dev/halo/blob/master/CONTRIBUTING.md>。
1. If this is your first time, please read our contributor guidelines: <https://github.com/halo-dev/halo/blob/master/CONTRIBUTING.md>.
2. 请根据你解决问题的类型为 Pull Request 添加合适的标签。
2. Please label this pull request according to what type of issue you are addressing, especially if this is a release targeted pull request.
3. 请确保你已经添加并运行了适当的测试。
3. Ensure you have added or ran the appropriate tests for your PR.
-->

#### What type of PR is this?
/kind improvement
/area core
/milestone 2.0
<!--
添加其中一个类别:
Add one of the following kinds:

/kind bug
/kind cleanup
/kind documentation
/kind feature
/kind improvement

适当添加其中一个或多个类别(可选):
Optionally add one or more of the following kinds if applicable:

/kind api-change
/kind deprecation
/kind failing-test
/kind flake
/kind regression
-->

#### What this PR does / why we need it:
- 超级管理员具有所有 ui-permissions
- 根据用户名获取权限的接口标记非空文档注解
#### Which issue(s) this PR fixes:

<!--
PR 合并时自动关闭 issue。
Automatically closes linked issue when PR is merged.

用法:`Fixes #<issue 号>`,或者 `Fixes (粘贴 issue 完整链接)`
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->
Fixes #

#### Special notes for your reviewer:
/cc @halo-dev/sig-halo 
#### 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
```
2022-07-15 04:23:09 +00:00
guqing 90da5a13a1
refactor: the way of plugin initialize load (#2242)
<!--  Thanks for sending a pull request!  Here are some tips for you:
1. 如果这是你的第一次,请阅读我们的贡献指南:<https://github.com/halo-dev/halo/blob/master/CONTRIBUTING.md>。
1. If this is your first time, please read our contributor guidelines: <https://github.com/halo-dev/halo/blob/master/CONTRIBUTING.md>.
2. 请根据你解决问题的类型为 Pull Request 添加合适的标签。
2. Please label this pull request according to what type of issue you are addressing, especially if this is a release targeted pull request.
3. 请确保你已经添加并运行了适当的测试。
3. Ensure you have added or ran the appropriate tests for your PR.
-->

#### What type of PR is this?
/kind improvement
/area core
/milestone 2.0
<!--
添加其中一个类别:
Add one of the following kinds:

/kind bug
/kind cleanup
/kind documentation
/kind feature
/kind improvement

适当添加其中一个或多个类别(可选):
Optionally add one or more of the following kinds if applicable:

/kind api-change
/kind deprecation
/kind failing-test
/kind flake
/kind regression
-->

#### What this PR does / why we need it:
1. 优化插件初始化加载方式及 Plugin 自定义模型资源的更新
2. 插件 plugin.yaml 中 license 配置不再支持只配置字符串,而使用如下替代
```yaml
license:
  - name: "MIT"
```
3. 可以在 application.yaml 中配置
```yaml
halo:
  initial-extension-locations:
    - "path/to/extensions/yaml"
```
用于在系统启动时创建或更新自定义模型数据
#### Which issue(s) this PR fixes:

<!--
PR 合并时自动关闭 issue。
Automatically closes linked issue when PR is merged.

用法:`Fixes #<issue 号>`,或者 `Fixes (粘贴 issue 完整链接)`
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->
Fixes #

#### Special notes for your reviewer:
/cc @halo-dev/sig-halo 
#### 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
```
2022-07-14 14:55:09 +00:00
John Niang 1cbd3c74e3
Refactor the response structure of Extension list API (#2244)
#### What type of PR is this?

/kind improvement
/kind api-change
/area core
/milestone 2.0

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

This PR is refactoring the response structure of Extension list API as follows:

```json
{
  "page": 0,
  "size": 0,
  "total": 1,
  "items": [
    {
      "spec": {
        "displayName": "Administrator",
        "email": "admin@halo.run",
        "password": "{bcrypt}$2a$10$/YveWyuf9vyYrHE3fiToI.bGBy5Hgs1eViRvKzU7Kl982la5NSwWO",
        "registeredAt": "2022-06-17T09:35:47.237625514Z",
        "twoFactorAuthEnabled": false,
        "disabled": false
      },
      "apiVersion": "v1alpha1",
      "kind": "User",
      "metadata": {
        "name": "admin",
        "annotations": {
          "user.halo.run/roles": "[\"super-role\"]",
          "rbac.authorization.halo.run/role-names": "[\"second-super-role\",\"super-role\"]"
        },
        "version": 3077,
        "creationTimestamp": "2022-06-17T09:35:47.367919552Z"
      }
    }
  ],
  "first": true,
  "last": true,
  "hasNext": false,
  "hasPrevious": false
}
```

Instead of items only.

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

Fixes #

#### Special notes for your reviewer:

Steps to test:

1. Start Halo server
2. Request <http://localhost:8090/swagger-ui.html> from browser and you might be redirected to login page
3. Login with your username and password
4. Try to request the list endpoints and see the result.

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

```release-note
None
```
2022-07-14 08:53:09 +00:00
guqing a8db2e5e4b
refactor: the value structure of ConfigMap for Setting custom extension (#2243)
<!--  Thanks for sending a pull request!  Here are some tips for you:
1. 如果这是你的第一次,请阅读我们的贡献指南:<https://github.com/halo-dev/halo/blob/master/CONTRIBUTING.md>。
1. If this is your first time, please read our contributor guidelines: <https://github.com/halo-dev/halo/blob/master/CONTRIBUTING.md>.
2. 请根据你解决问题的类型为 Pull Request 添加合适的标签。
2. Please label this pull request according to what type of issue you are addressing, especially if this is a release targeted pull request.
3. 请确保你已经添加并运行了适当的测试。
3. Ensure you have added or ran the appropriate tests for your PR.
-->

#### What type of PR is this?
/kind improvement
/area core
/milestone 2.0
<!--
添加其中一个类别:
Add one of the following kinds:

/kind bug
/kind cleanup
/kind documentation
/kind feature
/kind improvement

适当添加其中一个或多个类别(可选):
Optionally add one or more of the following kinds if applicable:

/kind api-change
/kind deprecation
/kind failing-test
/kind flake
/kind regression
-->

#### What this PR does / why we need it:
由于 Setting 自定义模型关联表单值的存储结构改变,对应修改 SettingFetcher 的取值方式
https://github.com/halo-dev/rfcs/pull/18
#### Which issue(s) this PR fixes:

<!--
PR 合并时自动关闭 issue。
Automatically closes linked issue when PR is merged.

用法:`Fixes #<issue 号>`,或者 `Fixes (粘贴 issue 完整链接)`
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->
Fixes #

#### Special notes for your reviewer:
/cc @halo-dev/sig-halo 
#### 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
```
2022-07-14 08:19:09 +00:00
guqing 55040d6918
feat: add an API to fetch user permissions (#2240)
<!--  Thanks for sending a pull request!  Here are some tips for you:
1. 如果这是你的第一次,请阅读我们的贡献指南:<https://github.com/halo-dev/halo/blob/master/CONTRIBUTING.md>。
1. If this is your first time, please read our contributor guidelines: <https://github.com/halo-dev/halo/blob/master/CONTRIBUTING.md>.
2. 请根据你解决问题的类型为 Pull Request 添加合适的标签。
2. Please label this pull request according to what type of issue you are addressing, especially if this is a release targeted pull request.
3. 请确保你已经添加并运行了适当的测试。
3. Ensure you have added or ran the appropriate tests for your PR.
-->

#### What type of PR is this?
/kind feature
/area core
/milestone 2.0
<!--
添加其中一个类别:
Add one of the following kinds:

/kind bug
/kind cleanup
/kind documentation
/kind feature
/kind improvement

适当添加其中一个或多个类别(可选):
Optionally add one or more of the following kinds if applicable:

/kind api-change
/kind deprecation
/kind failing-test
/kind flake
/kind regression
-->

#### What this PR does / why we need it:
新增 `/apis/api.halo.run/v1alpha1/users/{name}/permissions` endpoint 用于根据用户名查询所具有的角色和 ui 权限
1. 当 Role 变更时在 Role reconciler 中查询该 Role 的依赖 Role 聚合其 metadata.annotations 中的 `rbac.authorization.halo.run/ui-permissions` 到当前 Role 的 metadata.annotations 中 key 为`rbac.authorization.halo.run/ui-permissions-aggregated`避免覆盖修改当前 Role 的 `rbac.authorization.halo.run/ui-permissions`
2. 根据用户名查询 ui 权限时,先根据用户名获取 RoleBinding 再获取 Role 然后合并 metadata.annotation 中的两个 key:`rbac.authorization.halo.run/ui-permissions` 和 `rbac.authorization.halo.run/ui-permissions-aggregated` 得到权限作为 API 返回值
#### Which issue(s) this PR fixes:

<!--
PR 合并时自动关闭 issue。
Automatically closes linked issue when PR is merged.

用法:`Fixes #<issue 号>`,或者 `Fixes (粘贴 issue 完整链接)`
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->
Fixes #

#### Special notes for your reviewer:
/cc @halo-dev/sig-halo 
#### 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
```
2022-07-14 03:17:09 +00:00
John Niang fe816e6843
Add checkout-from parameter for composite action (#2241)
#### What type of PR is this?

/kind bug

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

Add checkout-from parameter for composite action. Please see <a801af5be5/README.md>.

If we don't set the parameter for the action, it will checkout from `default branch` to build docker image. You can see <https://github.com/halo-dev/halo/runs/7316162265?check_suite_focus=true#step:2:478>.

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

<!--
PR 合并时自动关闭 issue。
Automatically closes linked issue when PR is merged.

用法:`Fixes #<issue 号>`,或者 `Fixes (粘贴 issue 完整链接)`
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->
Fixes #

#### Special notes for your reviewer:

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

```release-note
None
```
2022-07-13 09:41:09 +00:00
John Niang faae645e88
Add an endpoint to grant permissions to user (#2239)
#### What type of PR is this?

/kind feature
/kind api-change
/area core
/milestone 2.0

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

Add an endpoint to grant permissions to user.

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

Fixes #

#### Special notes for your reviewer:

Test steps:

1. Start Halo
2. Check the initial password in the console log
3. Request <http://localhost:8090/webjars/swagger-ui/index.html> from browser and you will be redirected to login page
4. Input the username(admin) and the password you got just now
5. Grant permission as you wish

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

```release-note
None
```
2022-07-13 07:17:08 +00:00
guqing de493ccb2c
feat: add plugin setting support (#2238)
<!--  Thanks for sending a pull request!  Here are some tips for you:
1. 如果这是你的第一次,请阅读我们的贡献指南:<https://github.com/halo-dev/halo/blob/master/CONTRIBUTING.md>。
1. If this is your first time, please read our contributor guidelines: <https://github.com/halo-dev/halo/blob/master/CONTRIBUTING.md>.
2. 请根据你解决问题的类型为 Pull Request 添加合适的标签。
2. Please label this pull request according to what type of issue you are addressing, especially if this is a release targeted pull request.
3. 请确保你已经添加并运行了适当的测试。
3. Ensure you have added or ran the appropriate tests for your PR.
-->

#### What type of PR is this?
/kind feature
/area core
/milestone 2.0
<!--
添加其中一个类别:
Add one of the following kinds:

/kind bug
/kind cleanup
/kind documentation
/kind feature
/kind improvement

适当添加其中一个或多个类别(可选):
Optionally add one or more of the following kinds if applicable:

/kind api-change
/kind deprecation
/kind failing-test
/kind flake
/kind regression
-->

#### What this PR does / why we need it:
新增插件设置,允许通过 Setting 自定义模型生成表单并收集其值为 ConfigMap
插件可以通过注入 SettingFetcher 来获取值并使用它,例如:
```java
Sns sns = settingFetcher.getGroupForObject("sns", Sns.class);
```
#### Which issue(s) this PR fixes:

<!--
PR 合并时自动关闭 issue。
Automatically closes linked issue when PR is merged.

用法:`Fixes #<issue 号>`,或者 `Fixes (粘贴 issue 完整链接)`
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->
Fixes #

#### Special notes for your reviewer:
/cc @halo-dev/sig-halo 
#### 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
```
2022-07-12 14:57:08 +00:00
guqing abe29c12bf
feat: add configmap extension (#2232)
* feat: add configmap extension
2022-07-12 15:31:29 +08:00
John Niang 5953d2201d
Refactor CICD for Halo next (#2236) 2022-07-12 11:01:00 +08:00
Ryan Wang c97804780b
refactor: configure the api request to allow credentials and X-XSRF-TOKEN,COOKIE headers (#2227)
Signed-off-by: Ryan Wang <i@ryanc.cc>
2022-07-08 09:44:13 +00:00
guqing 3e8f8b8789
feat: add plugin reconciler (#2221)
* feat: add plugin reconciler

* feat: add unit test case
2022-07-08 07:08:13 +00:00
John Niang 3f7cb58370
Add support for custom endpoints (#2223)
* Support to add custom endpoints

Signed-off-by: johnniang <johnniang@fastmail.com>

* Update docs/developer-guide/custom-endpoint.md

Co-authored-by: guqing <38999863+guqing@users.noreply.github.com>

Co-authored-by: Ryan Wang <i@ryanc.cc>
Co-authored-by: guqing <38999863+guqing@users.noreply.github.com>
2022-07-08 04:40:13 +00:00
guqing 73d43cae64
refactor: JSON serialize exception (#2222) 2022-07-07 09:32:14 +00:00
John Niang 2afe19f1b9
Add rolebinding reconciler to reset role names of users (#2217)
* Add rolebinding reconciler to reset role names of users

Signed-off-by: johnniang <johnniang@fastmail.com>

* Add @Bean annotations on roleBindingController

* Fix errors complained by unneccesary catch

Signed-off-by: johnniang <johnniang@fastmail.com>
2022-07-07 03:36:10 +00:00
guqing f62d089237
feat: add role reconciler (#2212)
* feat: add role reconciler

* refactor: get role by name

* refactor: reconcile

* refactor: reconciler

* fix: test
2022-07-06 08:40:12 +00:00
guqing f7945081a5
refactor: plugin custom api generate rules (#2211)
* refactor: plugin custom api generate rules

* refactor: boolean convert

* fix: unit test
2022-07-05 07:00:12 +00:00
John Niang 27435a1aeb
Implement Extension reconciliation mechanism (#2204) 2022-07-04 03:14:24 +00:00
guqing d7cfe4c4a5
refactor: Unstructured loading opportunity for plugin (#2191)
* refactor: Unstructured loading opportunity for plugin

* refactor: gvk
2022-06-27 07:14:10 +00:00
John Niang 61d2169a51
Add additional method to fetch Extension by GVK and name (#2190) 2022-06-26 16:04:09 +00:00
guqing c0758f32d1
refactor: plugin configuration loading to adapt to plugin development mode (#2183)
* refactor: plugin configuration loading to adapt to plugin development mode

* refactor: extension locations

* refactor: plugin labels

* fix: unit test
2022-06-23 09:56:26 +00:00
guqing 273ffaad48
feat: add plugin status manage (#2177)
* feat: add plugin status manage

* feat: add plugin state changed listener

* refactor: plugin status

* refactor: plugin
2022-06-23 03:08:24 +00:00
John Niang c24df6fb05
Refine Swagger document for Extension APIs (#2180) 2022-06-22 04:36:21 +00:00
John Niang ac7a3c86c8
Configure CORS for API endpoints (#2175) 2022-06-21 11:06:20 +00:00
John Niang d556787b3a
Add update and delete handlers for Extensions (#2172) 2022-06-21 11:04:21 +00:00
guqing b9e5ed2f4c
feat: add shared application context for plugin (#2174)
* feat: add shared application context for plugin

* chore: remove todo notes

* fix: router function composite
2022-06-21 07:34:25 +00:00
guqing 7cd1282ad3
feat: add request mapping handler mapping for plugin (#2161)
* feat: add requet mapping handler mapping for plugin

* fix: request info resolve

* fix: test code style

* refactor: plugin api version resolve

* fix: merge conflicts
2022-06-21 03:22:24 +00:00