Add role templates for posts in user center (#4965)

#### What type of PR is this?

/kind cleanup
/area core
/milestone 2.11.0

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

This PR adds role templates for posts in user center for recreating more flexible roles. Related to <https://github.com/halo-dev/halo/pull/4866>.

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

```release-note
None
```
pull/4968/head v2.11.0
John Niang 2023-12-01 11:54:09 +08:00 committed by GitHub
parent abd049719d
commit 0351a67377
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 59 additions and 18 deletions

View File

@ -5,11 +5,25 @@ metadata:
labels: labels:
rbac.authorization.halo.run/system-reserved: "true" rbac.authorization.halo.run/system-reserved: "true"
annotations: annotations:
rbac.authorization.halo.run/module: "Posts Management"
# Currently, yaml definition does not support i18n, please see https://github.com/halo-dev/halo/issues/3573 # Currently, yaml definition does not support i18n, please see https://github.com/halo-dev/halo/issues/3573
rbac.authorization.halo.run/display-name: "编辑者" rbac.authorization.halo.run/display-name: "编辑者"
rbac.authorization.halo.run/dependencies: | rbac.authorization.halo.run/dependencies: |
["role-template-manage-posts", "post-author"] ["role-template-post-editor"]
rules: [ ]
---
apiVersion: v1alpha1
kind: "Role"
metadata:
name: role-template-post-editor
labels:
halo.run/role-template: "true"
annotations:
rbac.authorization.halo.run/module: "Posts Management"
# Currently, yaml definition does not support i18n, please see https://github.com/halo-dev/halo/issues/3573
rbac.authorization.halo.run/display-name: "Post Editor"
rbac.authorization.halo.run/dependencies: |
["role-template-manage-posts", "role-template-post-author"]
rules: [ ] rules: [ ]
--- ---
@ -20,13 +34,27 @@ metadata:
labels: labels:
rbac.authorization.halo.run/system-reserved: "true" rbac.authorization.halo.run/system-reserved: "true"
annotations: annotations:
rbac.authorization.halo.run/module: "Posts Management"
# Currently, yaml definition does not support i18n, please see https://github.com/halo-dev/halo/issues/3573 # Currently, yaml definition does not support i18n, please see https://github.com/halo-dev/halo/issues/3573
rbac.authorization.halo.run/display-name: "作者" rbac.authorization.halo.run/display-name: "作者"
rbac.authorization.halo.run/disallow-access-console: "true" rbac.authorization.halo.run/disallow-access-console: "true"
rbac.authorization.halo.run/redirect-on-login: "/uc" rbac.authorization.halo.run/redirect-on-login: "/uc"
rbac.authorization.halo.run/dependencies: | rbac.authorization.halo.run/dependencies: |
[ "post-contributor", "post-publisher" ] [ "role-template-post-author" ]
rules: [ ]
---
apiVersion: v1alpha1
kind: "Role"
metadata:
name: role-template-post-author
labels:
halo.run/role-template: "true"
annotations:
rbac.authorization.halo.run/module: "Posts Management"
# Currently, yaml definition does not support i18n, please see https://github.com/halo-dev/halo/issues/3573
rbac.authorization.halo.run/display-name: "Post Author"
rbac.authorization.halo.run/dependencies: |
[ "role-template-post-contributor", "role-template-post-publisher", "role-template-post-attachment-manager" ]
rules: [ ] rules: [ ]
--- ---
@ -37,11 +65,25 @@ metadata:
labels: labels:
rbac.authorization.halo.run/system-reserved: "true" rbac.authorization.halo.run/system-reserved: "true"
annotations: annotations:
rbac.authorization.halo.run/module: "Posts Management"
# Currently, yaml definition does not support i18n, please see https://github.com/halo-dev/halo/issues/3573 # Currently, yaml definition does not support i18n, please see https://github.com/halo-dev/halo/issues/3573
rbac.authorization.halo.run/display-name: "投稿者" rbac.authorization.halo.run/display-name: "投稿者"
rbac.authorization.halo.run/disallow-access-console: "true" rbac.authorization.halo.run/disallow-access-console: "true"
rbac.authorization.halo.run/redirect-on-login: "/uc" rbac.authorization.halo.run/redirect-on-login: "/uc"
rbac.authorization.halo.run/dependencies: |
[ "role-template-post-contributor" ]
rules: [ ]
---
apiVersion: v1alpha1
kind: "Role"
metadata:
name: role-template-post-contributor
labels:
halo.run/role-template: "true"
annotations:
rbac.authorization.halo.run/module: "Posts Management"
# Currently, yaml definition does not support i18n, please see https://github.com/halo-dev/halo/issues/3573
rbac.authorization.halo.run/display-name: "Post Contributor"
rbac.authorization.halo.run/dependencies: | rbac.authorization.halo.run/dependencies: |
[ "role-template-view-categories", "role-template-view-tags" ] [ "role-template-view-categories", "role-template-view-tags" ]
rbac.authorization.halo.run/ui-permissions: | rbac.authorization.halo.run/ui-permissions: |
@ -58,7 +100,7 @@ rules:
apiVersion: v1alpha1 apiVersion: v1alpha1
kind: Role kind: Role
metadata: metadata:
name: post-publisher name: role-template-post-publisher
labels: labels:
halo.run/role-template: "true" halo.run/role-template: "true"
annotations: annotations:
@ -70,18 +112,17 @@ rules:
- apiGroups: [ "uc.api.content.halo.run" ] - apiGroups: [ "uc.api.content.halo.run" ]
resources: [ "posts/publish", "posts/unpublish" ] resources: [ "posts/publish", "posts/unpublish" ]
verbs: [ "update" ] verbs: [ "update" ]
--- ---
apiVersion: v1alpha1 apiVersion: v1alpha1
kind: Role kind: Role
metadata: metadata:
name: post-attachment-manager name: role-template-post-attachment-manager
labels: labels:
halo.run/role-template: "true" halo.run/role-template: "true"
annotations: annotations:
rbac.authorization.halo.run/module: "Posts Management" rbac.authorization.halo.run/module: "Posts Management"
rbac.authorization.halo.run/display-name: "Post Attachment Manager" rbac.authorization.halo.run/display-name: "Post Attachment Manager"
rbac.authorization.halo.run/dependencies: |
[ "role-template-post-attachment-viewer" ]
rbac.authorization.halo.run/ui-permissions: | rbac.authorization.halo.run/ui-permissions: |
[ "uc:attachments:manage" ] [ "uc:attachments:manage" ]
rules: rules:

View File

@ -1347,9 +1347,9 @@ core:
Notification Configuration: Notification Configuration Notification Configuration: Notification Configuration
Configure Notifier: Configure Notifier Configure Notifier: Configure Notifier
Post Attachment Manager: Allow images to be uploaded in posts Post Attachment Manager: Allow images to be uploaded in posts
Post Author: Author Post Author: Contributions allowed
Post Contributor: Contributor Post Contributor: Allows you to manage your own posts
Post Editor: Editor Post Editor: Allow management of all posts
Post Publisher: Allow to publish own posts Post Publisher: Allow to publish own posts
components: components:
submit_button: submit_button:

View File

@ -1298,9 +1298,9 @@ core:
Cache Manage: 缓存管理 Cache Manage: 缓存管理
Notification Configuration: 通知配置 Notification Configuration: 通知配置
Configure Notifier: 配置通知器 Configure Notifier: 配置通知器
Post Editor: 编辑者 Post Editor: 允许管理所有文章
Post Contributor: 投稿者 Post Contributor: 允许管理自己的文章
Post Author: 作者 Post Author: 允许投稿
Post Attachment Manager: 允许在文章中上传图片 Post Attachment Manager: 允许在文章中上传图片
Post Publisher: 允许发布自己的文章 Post Publisher: 允许发布自己的文章
components: components:

View File

@ -1263,9 +1263,9 @@ core:
Configure Notifier: 配置通知器 Configure Notifier: 配置通知器
Notification Configuration: 通知配置 Notification Configuration: 通知配置
Post Attachment Manager: 允許在文章中上傳圖片 Post Attachment Manager: 允許在文章中上傳圖片
Post Author: 作者 Post Author: 允许管理自己的文章
Post Contributor: 投稿 Post Contributor: 允许投稿
Post Editor: 編輯者 Post Editor: 允许管理所有文章
Post Publisher: 允許發布自己的文章 Post Publisher: 允許發布自己的文章
components: components:
submit_button: submit_button: