본문으로 건너뛰기
Skillpedia
API 및 서버 (백엔드)19k · #10490

iii-worker-manager

하는 일

워커가 iii 엔진에 연결할 때 쓰는 수신기를 설정하고, 각 연결이 쓸 수 있는 함수를 제어합니다. 엔진을 다른 워커나 네트워크에 열면서 접근 제어가 필요한 개발자를 위한 스킬입니다.

사용하는 경우

  • ✓다른 네트워크의 워커가 내 엔진에 안전하게 연결하도록 하고 싶을 때.
  • ✓연결된 워커가 호출할 수 있는 함수를 제한해야 할 때.
  • ✓엔진을 지나는 모든 호출을 기록하거나 호출 횟수를 제한하고 싶을 때.

스킬 링크

https://github.com/iii-hq/iii/blob/main/engine/src/workers/worker/skills/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/iii-hq/iii/blob/main/engine/src/workers/worker/skills/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“신뢰할 수 없는 네트워크에 제 iii 엔진을 열어 주세요. 연결된 각 워커가 호출할 수 있는 함수는 접근 규칙으로 제한해 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

이 스킬은 서로 다른 포트에 WebSocket 수신기를 설정하고, 각각에 고유한 접근 규칙을 붙입니다. 연결마다 접근 검사가 실행되며, 선택 사항인 미들웨어 함수가 각 호출을 감사하거나, 호출 횟수를 제한하거나, 내용을 바꾼 뒤 대상에 전달할 수 있습니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

iii-worker-manager

The iii-worker-manager is a mandatory engine worker that opens WebSocket listeners. The base engine.workers.iii-worker-manager entry sets the main port (49134 by default); #instance entries open separate listeners with their own RBAC, middleware, and registration hooks. Channels are mounted on every listener at /ws/channels/{channel_id}.

When to Use

  • Exposing the engine to an untrusted network — RBAC is mandatory, never open the engine port itself. Use the standalone rbac-proxy worker (iii trigger compose::add worker=rbac-proxy), which applies these RBAC rules on its own port out of process. A second #instance listener with an rbac block and an auth_function_id is the in-engine alternative.
  • Restricting which functions a connected worker can invoke — combine expose_functions filters (operator-side) with forbidden_functions from AuthResult (per-session, hard deny).
  • Auditing, rate-limiting, or enriching every invocation — set middleware_function_id on the listener; the middleware decides whether to call the target and what to return.
  • Per-tenant or per-session namespace isolation — return function_registration_prefix from the auth function so every function/trigger this session registers is transparently prefixed without the worker code knowing.
  • Gating dynamic registration — wire on_function_registration_function_id, on_trigger_registration_function_id, or on_trigger_type_registration_function_id to validate or rewrite registrations.

Boundaries

  • The infrastructure carve-out (engine::channels::create, engine::workers::register, engine::log::*, engine::baggage::*) is always allowed on RBAC listeners regardless of expose_functions. Adding one of those IDs to forbidden_functions denies it but logs a warning — workers may behave unpredictably (broken setup, lost logs, missing context).
  • The engine port must remain internal. Only rbac-proxy or an RBAC-protected #instance listener may face an external network.
  • The middleware is not a pre-handler — it must invoke the target function itself (typically via iii.trigger) and return its result. Returning early without invoking simply skips the call.
  • forbidden_functions from the auth result wins over both allowed_functions and expose_functions. There is no way for a session to override an operator's deny list.
  • Registration hooks return mapped fields or throw to deny. Omitted result fields keep their original values; returning {} is a no-op (allow as-is).
  • Triggers and functions registered through an RBAC session are scoped to that session and cleaned up automatically on disconnect.

Configuration

Two listeners — one internal, one external with in-engine RBAC (the rbac-proxy worker accepts the same rbac block through the configuration worker instead):

engine:
  workers:
    iii-worker-manager:
      port: 49134

    "iii-worker-manager#rbac":
      host: 0.0.0.0
      port: 49135
      middleware_function_id: my-project::middleware
      rbac:
        auth_function_id: my-project::auth
        on_function_registration_function_id: my-project::on-fn-reg
        on_trigger_registration_function_id: my-project::on-trig-reg
        on_trigger_type_registration_function_id: my-project::on-trig-type-reg
        expose_functions:
          - match("api::*")
          - match("*::public")
          - metadata:
              public: true

Auth function

Receives AuthInput { headers, query_params, ip_address }, returns AuthResult. Throw to reject the connection.

import type { AuthInput, AuthResult } from '@iii-dev/helpers/worker-connection-manager'

iii.registerFunction(
  'my-project::auth',
  async (input: AuthInput): Promise<AuthResult> => {
    const token = input.headers?.['authorization']?.replace(/^Bearer\s+/i, '')
    if (!token) throw new Error('Missing credentials')

    const user = await validateToken(token)

    return {
      allowed_functions: [],
      forbidden_functions: user.role === 'readonly'
        ? ['api::users::delete', 'api::users::update']
        : [],
      allowed_trigger_types: user.role === 'admin' ? ['cron', 'webhook'] : undefined,
      allow_trigger_type_registration: user.role === 'admin',
      function_registration_prefix: `tenant-${user.tenant_id}`,
      context: { user_id: user.id, role: user.role, tenant_id: user.tenant_id },
    }
  },
)

`A

자주 묻는 질문

엔진 포트를 인터넷에 바로 열어도 되나요?

아니요. 신뢰할 수 없는 네트워크에는 접근 규칙이 꼭 필요하며, 이를 적용하려면 별도의 프록시 워커를 두는 것이 권장됩니다.

고객마다 별도의 네임스페이스를 줄 수 있나요?

네. 인증 함수가 세션이 등록하는 모든 함수와 트리거에 접두사를 붙일 수 있으며, 이렇게 하면 각 테넌트가 분리됩니다.

미들웨어는 무엇을 하나요?

미들웨어는 자신의 리스너를 거치는 모든 호출을 확인하고, 그 호출을 다음 단계로 넘길지와 어떤 값을 돌려줄지를 결정합니다.

상세 정보

작성자의 원본 설명

WebSocket listener that SDK workers connect to. Use to expose the engine to trusted (internal) and untrusted (RBAC-protected) workers, gate function and trigger registration, and audit or transform every invocation through a middleware function. Mounts channel WebSocket endpoints on every listener.

repo: iii-hq/iii

인기도

GitHub 스타
19k
순위
#10490
라이선스
—
업데이트
2026. 11. 2.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬