Commit Graph

2413 Commits (e03aa4ef722fd55fb5eaacebed73b4f5aa0515ad)

Author SHA1 Message Date
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
guqing 89eeccd99c
fix: locale for unit test of json extension converter (#2170) 2022-06-20 15:18:28 +00:00
John Niang f5d629d2bf
Add user support for authentication and authorization (#2163)
* Move role and rolebinding extensions into core package

* Add UserExtensionUserDetailService to find user and update password

* Rename DefaultUserDetailService

* Fix test errors

* Add SuperAdminInitializer to initialize first user

* Add unit tests for DefaultUserDetailService and UserService

* Add test for verifying SuperAdminInitializer

* Fix unstable test due to database reusability

Signed-off-by: johnniang <johnniang@fastmail.com>
2022-06-20 03:26:18 +00:00
John Niang e52db6859f
Add feature to generate APIs for schemes automatically (#2158)
* Add ExtensionEndpointInstaller

* Refactor Schemes with SchemeManager

* Add some unit tests

1. Add ExtensionCompositeRouterFunctionTest
2. Add ExtensionConfigurationTest
3. Refactor Unstructured
4. Fix bad ObjectMapper in Json converter.

* Fix bad scheme registration
2022-06-16 03:10:14 +00:00
guqing fcbf0031a4
feat: plugin supports multiple ways of specifying licenses (#2152)
* feat: plugin supports multiple ways of specifying licenses

* feat: add unit test case for deserialize license
2022-06-15 15:36:12 +00:00
guqing 83d668b0a9
feat: add plugin unstructured resource loader (#2154)
* feat: add plugin unstructured resource loader

* feat: add test unit case
2022-06-14 15:38:12 +00:00
guqing 6bbaa9aeba
feat: add reverse proxy router registry for plugin by reverse proxy rules (#2151)
* feat: add reverse proxy router registry for plugin by reverse proxy rules

* Update src/main/java/run/halo/app/plugin/resources/ReverseProxyRouterFunctionFactory.java

Co-authored-by: John Niang <johnniang@fastmail.com>

* refactor: merge stream operation

* refactor: plugin composite router function

* feat: add unit test case

Co-authored-by: John Niang <johnniang@fastmail.com>
2022-06-14 10:58:21 +00:00
guqing a2f49c60bc
feat: add plugin life cycle management (#2134)
* feat: add plugin life cycle management

* refactor: plugin lifecycle endpoint mapping
2022-06-13 02:36:11 +00:00
Halo Dev Bot 95c6caaca1
docs: add CODE_OF_CONDUCT.md (#2150)
Co-authored-by: Ryan Wang <i@ryanc.cc>
2022-06-12 08:10:12 +00:00
John Niang a956758a2f
Overwrite Jackson2Json decoder and encoder (#2145) 2022-06-09 08:04:13 +00:00
John Niang 02a7143fe5
Enable CSRF token in Set-Cookie header (#2144) 2022-06-09 02:30:13 +00:00
guqing b3b13bc820
feat: add yaml descriptor finder for plugin (#2132)
* feat: add yaml plugin descriptor finder

* refactor: json assert

* refactor: plugin descriptor finder

* refactor: yaml plguin finder

* refactor: plugin dependencies
2022-06-07 06:32:12 +00:00
John Niang 1024f71635
Replace webmvc with webflux (#2138)
* Replace webmvc to webflux

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

* Remove jetty dependency

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

* Refactor authentication module

* Refactor authentication module

* Migrate authorization module

* Refactor Login components

* Fix broken imports

* Upgrade springdoc version

* Refine security matcher using pathMatchers utility
2022-06-07 02:20:12 +00:00
guqing 19db04c430
refactor: policy rule constructor to avoid null values (#2131)
* refactor: policy rule constructor to avoid null values

* fix: unit test case
2022-06-02 02:52:10 +00:00
guqing 2c057f4fe1
feat: add plugin implementation (#2128) 2022-05-31 04:06:10 +00:00
guqing f4a943e45a
refactor: rule resolver and role binding lister (#2119) 2022-05-30 09:08:09 +00:00
guqing 9a05942bc4
feat: add yaml unstructured loader (#2122) 2022-05-28 09:44:08 +00:00
guqing 3c856d04af
feat: add personal access token authentication mechanism (#2116)
* feat: add personal access token authentication

* fix: merge conflicts

* refactor: remove base62 codec

* refactor: remove deprecated method

* feat: add base64 test

* chore: add todo for test only methods
2022-05-27 06:26:37 +00:00
John Niang b5d7f194ef
Create unstructured Extension which can store any Extensions (#2111)
* Extract ExtensionOperator and MetadataOperator

* Move groupVersionKind methods up to ExtensionOperator interface

* Add Unstructured Extension for generic Extension

* Refine mapping of GVK and Scheme

* Add two compatible methods
2022-05-26 08:38:10 +00:00
guqing 0f4ae08fd8
feat: add logout handler (#2110)
* feat: add logout handler

* chore: delete unused code

* fix: merge conflicts
2022-05-25 09:58:10 +00:00
guqing c5df6d3dbb
feat: add default role binding lister and role getter (#2108)
* feat: add default role binding lister and role getter

* feat: add initial capacity for role binding list
2022-05-25 07:52:10 +00:00
John Niang 9990fdd086
Upgrade to Spring Boot 3.0.0-M3 (#2102)
Please see https://github.com/spring-projects/spring-boot/releases/tag/v3.0.0-M3
2022-05-20 03:35:34 +00:00
John Niang 5f9daf4735
Add JSON schema generator and validator (#2093)
Only validate the JSON schema when saving Extension into database.
2022-05-17 16:06:12 +00:00
John Niang 264f9e39cb
Add support for Extension mechanism (#2086)
* Add support for Extension mechanism

1. Add ExtensionStore
2. Add Extension
3. Add Scheme

* Add more unit tests

* Fix checkstyle violations

* Remove unused import
2022-05-17 10:36:13 +00:00
guqing be2c0654a2
chore: add checkstyle rule (#2091)
* feat: add unused imports checkstyle rule

* feat: add java doc style rule

* fix: check style
2022-05-17 06:46:11 +00:00