traPtitech / traPtitech/Checkin

起動時の設定検証が stripeSecretKey だけで、他の必須の鍵は使うまで欠落が出ない

Open
#65 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
TypeScript
Stars
0
Forks
0
Avg merge
3d 5h
Merged PRs (30d)
7

Description

現状

apps/web/server/plugins/validate-config.ts は、import.meta.dev のときに早期 return し、本番でだけ runtimeConfigstripeSecretKey が空文字でないことを見る。検証しているのはこの 1 つだけである。

一方、packages/api/src/billing/config.tsBillingConfigpackages/api/src/auth/config.tsAuthConfig は、他にも多くの値を読む。

  • BillingConfig: prices の 4 つ(shinkiZenkishinkiKoukikeizokuStandardkeizokuSpecial)、stripeWebhookSecretconnectWebhookSecretinvoiceDaysUntilDue
  • AuthConfig: mailHashSecrettraq の 7 つ(clientIdclientSecretauthorizeUrltokenUrluserinfoUrlscopeuserIdField)、mailer の 3 つ、allowedEmailDomainsappOriginemailVerificationTtlSecsessionTtlSecaccountantTraqIdstrustForwardAuth

このうち既定値を持たないもの(mailHashSecrettraqclientId から scope まで、prices の 4 つ、2 つの webhook シークレット)は、空文字のままでも起動する。欠落が現れるのは、その値を使う機能を実際に呼んだときである。たとえば mailHashSecret が空なら、packages/api/src/auth/crypto.tsderiveMailHash がメール確認の時点で例外を投げる。

誰が何を誤るか

設定を投入する人が、起動できたことを設定が揃った証拠と受け取る。実際には、入部の請求書発行、traQ のログイン、webhook の署名検証のどれかを実行するまで欠落が出ない。webhook のシークレットが欠けている場合、Stripe からの配信が署名検証で落ち続け、その原因が起動時には分からない。

決めること

どの値が本番で必須かは機能ごとの要件で決まる。たとえば、traQ の OAuth は forward-auth を信頼する配備では使わないので、その配備では traq の値が空でも正しい。したがって「すべて必須」とはできず、配備の形ごとに必須の集合を決める必要がある。

  • 配備の形(forward-auth を使うか、traQ OAuth を使うか、Connect を有効にするか)ごとに必須の集合を定義する
  • 集合を validate-config.ts に落とし、欠けている名前を列挙して起動を止める

直さずに残した理由

どの値がどの配備で必須かを確かめていない。確かめないまま検証の対象を広げると、その値を使わない配備で起動できなくなる。

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with apps/web/server/plugins/validate-config.ts, then trace the deployment modes and consumers in packages/api/src/billing/config.ts, packages/api/src/auth/config.ts, and packages/api/src/auth/crypto.ts. Determine which values are required for each mode, including forward-auth, traQ OAuth, and Connect. Done means the required sets are agreed, missing names are reported, and startup is blocked without rejecting valid deployments.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
authentication, backend, payments
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.