forked from baron/baron-sso
- Database: Add user_login_ids table for 1:N identifier mapping and remove legacy login_id column - Kratos: Update identity schema to use custom_login_ids array instead of a single id trait - Backend: Implement syncCustomLoginIDs to collect isLoginId fields across tenant schemas - Backend: Add backtracking logic to auto-assign session tenant based on used login identifier - Backend: Add 409 Conflict exception handling for Create/Update operations - AdminFront: Refactor UserDetailPage to a tabbed grid layout (Info, Tenants, Security) - AdminFront: Show '로그인 ID' badge on tenant schema fields used for authentication - UserFront: Remove legacy optional 'Login ID' input from signup flow - Tests: Add multi-identifier repository tests and update handler tests
47 lines
1.1 KiB
Go
47 lines
1.1 KiB
Go
package bootstrap
|
|
|
|
import (
|
|
"baron-sso-backend/internal/domain"
|
|
"fmt"
|
|
"log/slog"
|
|
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
// Run executes the application bootstrap logic (migrations, seeding, etc.)
|
|
func Run(db *gorm.DB) error {
|
|
slog.Info("[Bootstrap] Starting application bootstrap...")
|
|
|
|
// 1. Auto Migration
|
|
if err := migrateSchemas(db); err != nil {
|
|
return fmt.Errorf("migration failed: %w", err)
|
|
}
|
|
|
|
// 2. Seed Tenants
|
|
if err := SeedTenants(db); err != nil {
|
|
return fmt.Errorf("tenant seeding failed: %w", err)
|
|
}
|
|
|
|
slog.Info("[Bootstrap] User seed skipped (Kratos is SoT)")
|
|
slog.Info("[Bootstrap] Bootstrap completed successfully.")
|
|
return nil
|
|
}
|
|
|
|
func migrateSchemas(db *gorm.DB) error {
|
|
slog.Info("[Bootstrap] Migrating database schemas...")
|
|
// Add all domain models here
|
|
return db.AutoMigrate(
|
|
&domain.Tenant{},
|
|
&domain.TenantDomain{},
|
|
&domain.User{},
|
|
&domain.UserLoginID{},
|
|
&domain.UserGroup{},
|
|
&domain.ApiKey{},
|
|
&domain.IdentityProviderConfig{},
|
|
&domain.ClientSecret{},
|
|
&domain.ClientConsent{},
|
|
&domain.KetoOutbox{},
|
|
// &domain.RelyingParty{}, // Removed: SSOT is Hydra + Keto
|
|
)
|
|
}
|