跳到正文
cccskills
免费在 GitHub 公开中文介绍

authz-configurator

为 SigNoz 后端功能和 API 路由配置完整的授权流程,包括注册资源、设置管理角色权限、按需迁移现有组织,并通过集成测试检查各角色对资源的允许或拒绝访问结果。

原文查看原文说明

Add authorization (authz) to a SigNoz backend feature end-to-end — register kinds/resources, grant managed-role permissions, wire routes with ResourceDefs, backfill tuples for existing orgs, and write the authz integration tests. Use this whenever the user mentions authz, authorization, permissions, access control, managed roles (admin/editor/viewer), OpenFGA, ResourceDef, CheckResources, 403/forbidden behavior on an endpoint, wiring or protecting a new route, registering a new resource/kind, or writing integration tests that assert role-based allow/deny. Also use it when a new API endpoint is being added and its access control hasn't been decided yet — every route needs an authz decision even if the user didn't say the word.

SigNoz/signoz星标 32,475(GitHub 32,475 + cccskills 0)

实测评分 未实测

查看安装方法

适用场景

  • 为新的 API 路由配置授权
  • 登记资源并设置管理角色权限
  • 将新权限应用到现有组织
  • 测试各角色的允许与拒绝访问

中文介绍

功能

此技能会引导你为 SigNoz 后端功能接入授权,从登记资源到配置路由和编写测试。你可以登记类型与资源,为 admin、editor、viewer 等管理角色分配权限,并为每条路由设置 ResourceDef,说明它涉及的资源和操作。如果现有组织也需要获得新权限,技能会引导你添加迁移,更新相关元组和角色信息。集成测试可用于检查不同角色是否获准访问,也可在需要时验证对具体资源的访问。

适用场景

新增 API 路由或调整现有功能的权限时,可以使用此技能。它也适合希望了解 SigNoz 如何通过 OpenFGA 实现授权,并避免遗漏资源登记或路由配置的开发者。具体步骤会根据工作范围变化,例如新增资源、为现有资源添加路由、修改角色权限或补充测试。

使用示例

  • “为这个新 API 路由添加所需的授权设置和角色权限。”
  • “让 viewer 只能读取这个资源,editor 可以更新,并编写集成测试。”
  • “创建迁移,把新的管理角色权限应用到现有组织。”

注意事项

流程会用到 SigNoz 开发步骤和参考资料、生成命令,以及 Go 和 Python 测试环境。需要确认现有组织是否也要获得新权限。新增 FGA 类型需要编辑架构文件,处理方式与新增 kind 不同。

本介绍由 AI(OpenAI Codex)根据公开的 SKILL.md 撰写。准确的规格请查看下方原文。

文档检查

AI 根据 SKILL.md 的内容检查了需要注意的操作和使用前提。评分只依据实际运行的结果(实测对比)。

安全性发送数据、删除文件、执行命令等是否有说明
B部分不足要求确认是否回填现有组织,但对部分操作影响的说明有限。
安装难易度所需工具和 API 密钥是否少且有说明
B部分不足需要 SigNoz 资料及 Go、Python 测试环境,但未完整说明安装步骤。

不计入评分。 由 AI(OpenAI Codex)于 2026年10月28日 评估。仅供参考,安装前请同时查看原文。

如果您认为评估有误,请申请复核

请写明哪一项有误以及原因。无需登录。我们会对照 SKILL.md 重新评估,并在此处更新结果。

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

包含的文件(3)

  • SKILL.md11.1 KB
  • references/integration-tests.md6.7 KB
  • references/route-wiring.md7.6 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

SigNoz Authz Workflow

This skill automates the procedure documented in docs/contributing/go/authz.md. Read that doc first — it is the canonical explanation of the concepts (types, verbs, kinds, resources, selectors, tuples, the community/enterprise split). This skill tells you what to do; the doc tells you why it works.

The core model in one paragraph: permissions are never attached to users. They are attached to roles as OpenFGA tuples, and users/service accounts are made assignees of roles. You declare everything in code registries under pkg/types/coretypes/; tuples for new organizations are derived from those registries at org bootstrap. Routes declare what resource+verb they touch via ResourceDefs, and middleware turns that into a check that works in both community (role gate) and enterprise (per-resource FGA) editions.

Before you start

Figure out what shape the work is. Ask the user if unclear:

  • New resource (new kind + routes) → all steps below.
  • New route on an existing resource → step 4 only (maybe step 3 if roles need new verbs).
  • Changing what a role can do → steps 3, 5, 6, 7.
  • Just tests → steps 6, 7.

Almost every feature resource is a metaresource (dashboards, rules, pipelines) or a telemetryresource (logs, traces, metrics). If the feature genuinely needs a brand-new FGA type, stop and flag it to the user — that requires editing both pkg/authz/openfgaschema/base.fga and ee/authz/openfgaschema/base.fga together and is almost never the right call. A new kind never touches the schema.

Step 1: Register the kind

Edit pkg/types/coretypes/registry_kind.go. Add a var and append it to the Kinds slice (both are required — the slice is what gets validated and iterated):

KindThing = MustNewKind("thing")

Kind names are lowercase, hyphen-separated (quick-filter, trace-funnel, notification-channel).

Also add the kind to Kind.Enum() in pkg/types/coretypes/kind.go — a second hand-maintained list mirroring Kinds that feeds the OpenAPI enum. It is easy to miss because nothing fails at build time without it; the drift only shows up in the generated spec.

Step 2: Register the resource

Edit pkg/types/coretypes/registry_resource.go. Add a var and append it to the Resources slice:

ResourceMetaResourceThing = NewResourceMetaResource(KindThing)

Use NewResourceTelemetryResource(KindThing) for telemetry data resources. Pass an explicit verb list only when the resource supports fewer verbs than the type default — see ResourceMetaResourceFactorAPIKey in that file for the shape.

Step 3: Grant permissions to managed roles

Edit pkg/types/coretypes/registry_managed_role.go. Add Transaction entries to ManagedRoleToTransactions for each role that may act on the resource:

{Verb: VerbCreate, Object: *MustNewObject(ResourceRef{Type: TypeMetaResource, Kind: KindThing}, WildCardSelectorString)},

The convention: admin gets everything; editor gets full CRUD only on day-to-day observability resources (dashboards, rules, saved views — not access control or org settings); viewer gets read/list; anonymous gets nothing (public dashboards are the only exception). Match the file's existing style, including its one-line grouping comment per resource block (e.g. // thing — editors manage, viewers read) — that file uses grouping comments as structure; do not add comments anywhere else.

This map is the single source of truth: changing it affects only organizations created afterwards (see step 5 for existing orgs), and the integration suite asserts its contents via a golden file (see step 6).

Step 4: Wire the route

Register routes in the existing domain file under pkg/apiserver/signozapiserver/ — do not create new per-sub-resource route files. Each route needs three coordinated pieces:

  1. provider.authzMiddleware.CheckResources(handlerFn, roles...) — the role list is the community-edition fallback gate (which managed roles may call this route when per-resource checks are unavailable).
  2. handler.WithResourceDefs(...) — declares resource, verb, audit category, ID extractor, and selector.
  3. SecuritySchemes: newScopedSecuritySchemes([]string{resource.Scope(verb)}) — advertises the scope in the OpenAPI spec.

Selector rules (getting these wrong silently over- or under-authorizes):

OperationSelectorID extractor
createWildcardSelectorResponseJSONPath("data.id") (ID exists only after the handler runs; recorded for audit)
listWildcardSelectornone
read/update/delete of one instanceIDSelectorPathParam("id") or BodyJSONPath(...)
request ID ≠ FGA selector (e.g. route has a role UUID, FGA objects use role names)custom SelectorFuncas appropriate

Routes that link two resources check both sides. Read references/route-wiring.md before wiring any create route, linking route (attach/detach, parent-child), or custom selector — it has complete real examples from serviceaccount.go.

Prefer CheckResources + ResourceDef for anything resource-shaped. The legacy gates ViewAccess/EditAccess/AdminAccess are coarse role-only checks — do not use them for new routes. OpenAccess means no authorization (authentication still applies); CheckWithoutClaims serves anonymous routes.

Step 5: Backfill existing organizations (only if needed)

New organizations derive their tuples from the registries at creation — no migration needed for them. If existing organizations must get the new permissions, add a migration in pkg/sqlmigration/ that does two things per org:

  1. Insert the FGA tuples — follow 083_add_role_crud_tuples.go: one tuple row (+ changelog row) per role/verb/object, with ON CONFLICT ... DO NOTHING so it stays idempotent, handling both the Postgres and SQLite tuple column layouts as that file does.
  2. Refresh the managed roles' JSON record — since 099_add_role_transaction_groups.go, each role row carries a transaction_groups JSON column that mirrors its permissions. Tuples and JSON must move together or the stored record drifts from the registry. Follow 099's managed-role loop: marshal authtypes.NewTransactionGroupsFromTransactions(coretypes.ManagedRoleToTransactions[roleName]) and UPDATE role SET transaction_groups = ? WHERE org_id = ? AND type = 'managed' AND name = ?. Serializing from the registry (which already contains your new grants) makes this step self-updating. Custom roles need no changes — only managed roles mirror the registry.

Register the new migration factory in NewSQLMigrationProviderFactories in pkg/signoz/provider.go, appended after the existing entries. The factory name passed to factory.MustNewName must match ^[a-z][a-z0-9_-]{0,30}$ — at most 31 characters, or it panics at startup; prefer a short name like notification_template_tuples over add_notification_template_tuples.

Ask the user whether backfill is needed rather than assuming — shipping a feature to existing orgs almost always means yes.

Step 6: Update the golden testdata and regenerate CI-checked artifacts

If you changed ManagedRoleToTransactions, update tests/integration/testdata/role/managed_role_transactions.json to match — the role/01_register.py integration test compares each managed role's verb/type/kind matrix against this file and will fail otherwise.

If you touched the registries or Kind.Enum(), regenerate the derived artifacts. The goci GitHub workflow reruns each of these and fails the PR on any uncommitted diff:

go run cmd/enterprise/*.go generate openapi                    # docs/api/openapi.yml
go run cmd/enterprise/*.go generate authz                      # frontend/src/lib/authz/hooks/useAuthZ/permissions.type.ts
go run cmd/enterprise/*.go generate config transaction-groups  # frontend/src/schemas/generated/transactionGroups.schema.json

Commit whatever they change; never hand-edit these generated files.

generate authz is allowlist-based: it only emits resources listed in the allowedResources map inside runGenerateAuthz in cmd/authz.go. For the new resource to surface in the UI's permission gating (AuthZButton and friends), add it there —

coretypes.NewResourceRef(coretypes.ResourceMetaResourceThing).String(): true,

— then rerun generate authz and commit the regenerated permissions.type.ts. If the resource has no UI surface yet, skip the allowlist entry and the command produces no diff; that is expected.

Step 7: Write integration tests

Read references/integration-tests.md for the suite layout, fixtures, and canonical allow/deny test shapes. The minimum bar for a new authz'd resource: each managed role's expected 200-vs-403 matrix on the new routes, and (if enterprise/FGA behavior matters) per-object scoping with a custom role — granted instance succeeds, non-granted instance gets 403, revoke flips it back to 403.

Python test conventions that are hard rules in this repo: inline requests.* calls directly (never wrap single API calls in helpers), always pass timeout=, and run make py-fmt && make py-lint before finishing.

Verification

Run these before declaring the work done:

make go-build-community

Consistency greps — every one of these must hold:

  • the new Kind var appears in BOTH the Kinds slice (registry_kind.go) and Kind.Enum() (kind.go)
  • the three generate commands from step 6 have been run and leave git diff clean when re-run
  • if the resource is UI-gated, it appears in allowedResources in cmd/authz.go and permissions.type.ts was regenerated
  • the new Resource var appears in the Resources slice (registry_resource.go)
  • every ResourceDef in the route file references the registered resource and one of its allowed verbs
  • every route's SecuritySchemes scope matches its ResourceDef verb
  • if ManagedRoleToTransactions changed, managed_role_transactions.json changed with it

Then run the relevant integration suites (make py-test-setup from the repo root boots the environment; pytest runs from tests/):

uv run pytest --basetemp=./tmp/ -vv --reuse integration/tests/role/
uv run pytest --basetemp=./tmp/ -vv --reuse integration/tests/<your-suite>/

General repo conventions apply throughout: no code comments (the grouping comments in registry_managed_role.go are the sole exception), complete descriptive names, and never commit without an explicit ask.

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

将Redux或React Context中的状态按用途迁移到React Query、nuqs、Zustand或组件本地状态,整理API数据、可分享的URL条件及界面状态。

  • 从Redux或React Context迁移
  • 消除API数据重复存储
  • 通过网址分享筛选条件和页码
SigNoz/signoz3.2万2026年10月30日 更新

sbshot-visual-diff

免费有简介

对比代码更改前后的 Storybook 截图,检查明暗主题下的显示,区分真实变化与拍摄波动,并导出带注释、可供评审者查看的差异页面。

  • 比较更改前后的页面
  • 检查明暗主题布局
  • 在 PR 中分享带注释的差异
SigNoz/signoz3.2万2026年10月30日 更新

scaffold-feature

免费有简介

通过命令生成页面或组件的文件夹与文件模板,按功能归集相关内容。可创建多标签页面框架、测试和README,并在指定前端结构中登记页面路由。

  • 按统一结构创建新页面
  • 搭建带多个标签的页面框架
  • 在功能目录中添加组件
SigNoz/signoz3.2万2026年10月30日 更新

signoz-page-story

免费有简介

为SigNoz页面创建Storybook故事,梳理API请求、显示状态和网址参数,并用msw模拟响应及操作控件检查加载、错误、权限等状态。

  • 为SigNoz页面创建Storybook故事
  • 检查加载、空白和错误状态
  • 核对不同权限下的按钮行为
SigNoz/signoz3.2万2026年10月30日 更新

查看 SigNoz 的全部技能

报告此技能的问题