forked from baron/baron-sso
multi IDP 모델 적용 scaffolding
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"baron-sso-backend/internal/domain"
|
||||
"baron-sso-backend/internal/handler"
|
||||
"baron-sso-backend/internal/logger"
|
||||
"baron-sso-backend/internal/repository"
|
||||
"baron-sso-backend/internal/service"
|
||||
"baron-sso-backend/internal/validator"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"os"
|
||||
@@ -59,6 +61,27 @@ func main() {
|
||||
"redis_addr", getEnv("REDIS_ADDR", "redis:6379"),
|
||||
)
|
||||
|
||||
// --- Fail-Fast Schema Validation ---
|
||||
// Initialize the IDP Provider (Descope)
|
||||
descopeProjectID := getEnv("DESCOPE_PROJECT_ID", "")
|
||||
descopeManagementKey := getEnv("DESCOPE_MANAGEMENT_KEY", "")
|
||||
|
||||
// We create a provider instance to check schema compatibility.
|
||||
// This ensures that our BrokerUser model requirements (e.g. custom attributes)
|
||||
// are supported by the configured IDP.
|
||||
idpProvider := service.NewDescopeProvider(descopeProjectID, descopeManagementKey)
|
||||
|
||||
if err := validator.ValidateIDPCompatibility(domain.BrokerUser{}, idpProvider); err != nil {
|
||||
slog.Error("❌ [CRITICAL] Broker Schema Mismatch",
|
||||
"idp", idpProvider.Name(),
|
||||
"error", err,
|
||||
)
|
||||
fmt.Printf("\n!!! CRITICAL ERROR: IDP Schema Mismatch !!!\n%v\n\n", err)
|
||||
os.Exit(1) // Break the build/deployment
|
||||
}
|
||||
slog.Info("✅ IDP Schema Validation Passed", "idp", idpProvider.Name())
|
||||
// -----------------------------------
|
||||
|
||||
// 2. Initialize DB Connections
|
||||
chHost := getEnv("CLICKHOUSE_HOST", "localhost")
|
||||
chPort, _ := strconv.Atoi(getEnv("CLICKHOUSE_PORT_NATIVE", "9000"))
|
||||
|
||||
Reference in New Issue
Block a user