fix(idp): サービスアカウントが未設定なら graph の設定を使う

- ocis init が idp.service_account を書く前に作られた ocis.yaml でも
  Discord ログインが有効になるように、ランタイムで idp を起動する前に
  graph.service_account を写す
This commit is contained in:
sylph committed 2026-11-01 22:13:01 +09:00
1 parent de0eace537
commit 8b132a520e
1 file changed
+16
+16
View File
@@ -289,6 +289,7 @@ func NewService(ctx context.Context, options ...Option) (*Service, error) {
reg(3, opts.Config.IDP.Service.Name, func(ctx context.Context, cfg *ociscfg.Config) error {
cfg.IDP.Context = ctx
cfg.IDP.Commons = cfg.Commons
idpServiceAccountFallback(cfg)
return runServerCommand(ctx, idp.Server(cfg.IDP))
})
reg(3, opts.Config.Proxy.Service.Name, func(ctx context.Context, cfg *ociscfg.Config) error {
@@ -619,3 +620,18 @@ func newRPCServer(s *Service) (*http.Server, error) {
}
return srv, nil
}
// idpServiceAccountFallback copies the graph service account to the idp when
// the idp has none. Configs created before `ocis init` wrote
// idp.service_account only have it in the graph section.
func idpServiceAccountFallback(cfg *ociscfg.Config) {
if cfg.IDP == nil || cfg.Graph == nil {
return
}
sa := &cfg.IDP.ServiceAccount
if sa.ServiceAccountID != "" || sa.ServiceAccountSecret != "" {
return
}
sa.ServiceAccountID = cfg.Graph.ServiceAccount.ServiceAccountID
sa.ServiceAccountSecret = cfg.Graph.ServiceAccount.ServiceAccountSecret
}