apiVersion: v1alpha1
kind: Role
metadata:
  name: sharelink-public-apis
  labels:
    halo.run/role-template: "true"
    halo.run/hidden: "true"
    rbac.authorization.halo.run/aggregate-to-anonymous: "true"
  annotations:
    rbac.authorization.halo.run/module: "资源下载管理"
    rbac.authorization.halo.run/display-name: "Sharelink Public APIs"
rules:
  - apiGroups: [ "api.sharelink.halo.run" ]
    resources: [ "email-verify/send" ]
    verbs: [ "create" ]
  - apiGroups: [ "api.sharelink.halo.run" ]
    resources: [ "email-verify/check" ]
    verbs: [ "create" ]
  - apiGroups: [ "api.sharelink.halo.run" ]
    resources: [ "downloads/token" ]
    verbs: [ "create" ]
---
apiVersion: v1alpha1
kind: Role
metadata:
  name: role-template-sharelink-view
  labels:
    halo.run/role-template: "true"
  annotations:
    rbac.authorization.halo.run/module: "资源下载管理"
    rbac.authorization.halo.run/display-name: "下载资源查看"
    rbac.authorization.halo.run/ui-permissions: '["plugin:sharelink:view"]'
rules:
  - apiGroups: [ "console.api.sharelink.halo.run" ]
    resources: [ "download-resources", "download-records", "references" ]
    verbs: [ "get", "list" ]
  - apiGroups: [ "console.api.sharelink.halo.run" ]
    resources: [ "download-records/export" ]
    resourceNames: [ "-" ]
    verbs: [ "get" ]
  # 引用扫描需要读取已发布文章及其快照内容
  - apiGroups: [ "content.halo.run" ]
    resources: [ "posts", "snapshots" ]
    verbs: [ "get", "list" ]
---
apiVersion: v1alpha1
kind: Role
metadata:
  name: role-template-sharelink-manage
  labels:
    halo.run/role-template: "true"
  annotations:
    rbac.authorization.halo.run/module: "资源下载管理"
    rbac.authorization.halo.run/display-name: "下载资源管理"
    rbac.authorization.halo.run/ui-permissions: '["plugin:sharelink:manage"]'
    rbac.authorization.halo.run/dependencies: '["role-template-sharelink-view"]'
rules:
  - apiGroups: [ "console.api.sharelink.halo.run" ]
    resources: [ "download-resources" ]
    verbs: [ "create", "update", "delete" ]
  - apiGroups: [ "console.api.sharelink.halo.run" ]
    resources: [ "download-records" ]
    verbs: [ "delete" ]
  - apiGroups: [ "console.api.sharelink.halo.run" ]
    resources: [ "references/refresh" ]
    resourceNames: [ "-" ]
    verbs: [ "create" ]
