Skip to content

feat(admin tenants): add --allowed-origins flag (closes #115)#116

Merged
miya0001 merged 2 commits into
mainfrom
feature/issue-115-allowed-origins
Apr 30, 2026
Merged

feat(admin tenants): add --allowed-origins flag (closes #115)#116
miya0001 merged 2 commits into
mainfrom
feature/issue-115-allowed-origins

Conversation

@miya0001

@miya0001 miya0001 commented Apr 30, 2026

Copy link
Copy Markdown
Member

Summary

  • admin tenants create / admin tenants update--allowed-origins <origins> フラグを追加し、テナント単位の CORS origin 制御 (settings.allowedOrigins, geolonia/geonicdb#1069 対応) を専用フラグから設定可能にした
  • api-keys--origins と同じカンマ区切り命名規則を踏襲。空文字列 ""[](deny all)として扱う点が api-keys との差分。wildcard / max-50 件のバリデーションは本体側 zod に委譲
  • 既存 JSON payload の settings.* 他キーは保持してマージ。フラグ単独でも JSON 入力なしで動作

Closes #115

CLI surface

# 完全一致リスト
geonic admin tenants update <tenant-id> --allowed-origins "https://app.example.com,https://admin.example.com"

# wildcard
geonic admin tenants update <tenant-id> --allowed-origins "*"

# 全 deny
geonic admin tenants update <tenant-id> --allowed-origins ""
挙動
フラグ未指定 全 origin 許可(後方互換)
"" [] — 全 deny
"*" wildcard — 全 origin 許可(CLI / S2S 含む)
"https://a,https://b" 完全一致リスト(最大 50 件、本体バリデーション)

Changes

  • src/commands/admin/tenants.tsapplyAllowedOriginsFlag() ヘルパーで body.settings.allowedOrigins にマージ。create / update に --allowed-origins オプションと addNotes / addExamples を追加
  • tests/admin-tenants.test.ts — 7 ケース追加(フラグマージ、wildcard、空文字列、空白 trim、既存 settings 保持、上書き、未指定時の regression guard 等)
  • README.mdadmin tenants セクションに値別挙動表と実用例を追加
  • CHANGELOG.md[Unreleased] に Feat エントリを追加

Test plan

  • npm run lint
  • npm run typecheck
  • npm test (733 tests passed, +7 from main)
  • npm run build
  • geonicdb 本体 #1069 とのインテグレーション確認(本体マージ後)

Summary by CodeRabbit

  • 新機能

    • admin tenants create / admin tenants update--allowed-origins フラグを追加。テナント単位のCORS許可オリジンをカンマ区切りで指定可能。""で全拒否、"*"で全許可(S2S含む)、カンマ区切りは厳密一致。フラグ未指定時は既存の動作(全オリジン)を維持。JSON入力と併用すると既存のsettingsを保持してallowedOriginsのみ上書き/追加します。
  • ドキュメント

    • READMEにオプションの詳細、動作例、マージ挙動を追記しました。

…ol (#115)

GeonicDB 本体 #1069 で導入された `Tenant.settings.allowedOrigins` を
`admin tenants create` / `update` の専用フラグから設定可能にする。

api-keys の --origins と同じカンマ区切り命名規則を踏襲し、空文字列を
[] (deny all) として扱う。wildcard / max-50 のバリデーションは本体側
zod に委譲。
@coderabbitai

coderabbitai Bot commented Apr 30, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 699ef8b4-d404-4c85-9573-b9b60d4eb4d3

📥 Commits

Reviewing files that changed from the base of the PR and between 8478565 and cb1ddae.

📒 Files selected for processing (2)
  • src/commands/admin/tenants.ts
  • tests/admin-tenants.test.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • tests/admin-tenants.test.ts
  • src/commands/admin/tenants.ts

📝 Walkthrough

Walkthrough

テナント管理コマンドに --allowed-origins フラグを追加し、tenants create / tenants update からテナントの settings.allowedOrigins を設定・上書きできるようにしました。README・CHANGELOG・テストも更新されています。

Changes

Cohort / File(s) Summary
ドキュメント
CHANGELOG.md, README.md
--allowed-origins <origins> の挙動を追加説明(未指定=全許可、""=全拒否 → []"*"=ワイルドカード → ["*"]、カンマ区切りで最大50件)。フラグ使用時は JSON の settings とマージする旨を明記。
CLI 実装
src/commands/admin/tenants.ts
tenants create / tenants update--allowed-origins オプションを追加。入力文字列をパースしてトリム・空要素除去・特殊ケース変換し、body.settings.allowedOrigins に設定(settings が無ければ作成)。JSON からの入力と正しくマージ/上書きする処理を導入。
テスト
tests/admin-tenants.test.ts
--allowed-origins のパース/マージ挙動を網羅するテストを追加。ワイルドカード、空文字列(空配列)、カンマ区切り、空要素除去、既存 settings の保持・上書き、stdin/TTY の扱いなどを検証。

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 ぴょんと跳ねて報告するよ
フラグが増えて風が通る
許可するOriginも止めるOriginも
テナントごとにぽんと収まるよ 🌱
CLIで楽しく管理しよう

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PRタイトルは主な変更内容を正確に要約しており、admin tenantsコマンドに--allowed-originsフラグを追加する意図が明確に伝わります。
Linked Issues check ✅ Passed PR実装は#115の全ての要件を満たしています。api-keys --originsと同じパース規則に従う--allowed-originsフラグの追加、サーバー側へのマッピング、セマンティクス(フラグ無し=全許可、""=[]"*"=['*']、カンマ区切り=リスト)の実装、バリデーション委譲、ドキュメント更新が完了しています。
Out of Scope Changes check ✅ Passed 全ての変更は#115で定義されたスコープ内です。tenants create/updateへの--allowed-originsフラグ追加、テスト、ドキュメント、CHANGELOGの更新に限定されており、スコープ外の変更は認められません。

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/issue-115-allowed-origins

Review rate limit: 3/5 reviews remaining, refill in 17 minutes and 33 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/commands/admin/tenants.ts`:
- Around line 113-119: The code currently returns {} when json is omitted and
opts.allowedOrigins is provided, which bypasses stdin/TTY parsing; instead, when
json is not provided call parseJsonInput() to populate body (as done elsewhere),
then after obtaining body merge or set the allowedOrigins value from
opts.allowedOrigins into that body object (e.g., body.allowedOrigins =
opts.allowedOrigins or Object.assign), applying the same change for the other
occurrence; reference the body variable, parseJsonInput(), and
opts.allowedOrigins when making this change.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d9e07ef7-70b8-4867-9c0a-61c352c1b656

📥 Commits

Reviewing files that changed from the base of the PR and between 5a34d06 and 8478565.

📒 Files selected for processing (4)
  • CHANGELOG.md
  • README.md
  • src/commands/admin/tenants.ts
  • tests/admin-tenants.test.ts

Comment thread src/commands/admin/tenants.ts Outdated
Address CodeRabbit feedback: dropping `body = {}` for the flag-only path
preserves stdin pipe and TTY interactive input. The flag now merges into
whatever body parseJsonInput() returns (inline JSON, @file, stdin, or
interactive prompt).
@miya0001
miya0001 merged commit bf9d84c into main Apr 30, 2026
7 checks passed
@miya0001
miya0001 deleted the feature/issue-115-allowed-origins branch April 30, 2026 09:57
@miya0001 miya0001 mentioned this pull request Apr 30, 2026
miya0001 added a commit that referenced this pull request Apr 30, 2026
* release: v0.15.0

* docs(changelog): add #116 reference for v0.15.0 entry
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(admin tenants): tenant settings に allowedOrigins フラグを追加 (geonicdb #1069 対応)

1 participant