@@ -34,50 +34,61 @@ func main() {
3434
3535 // Read Network configuration from environment variables
3636 externalBase := strings .TrimSpace (os .Getenv ("AGGREGATOR_EXTERNAL_HOST" ))
37+ model .ClientId = strings .TrimSpace (os .Getenv ("CLIENT_ID" ))
38+ model .ClientSecret = strings .TrimSpace (os .Getenv ("CLIENT_SECRET" ))
39+
40+ missingRequired := make ([]string , 0 , 3 )
3741 if externalBase == "" {
38- logrus .Fatal ("Environment variables AGGREGATOR_EXTERNAL_HOST must be set" )
42+ missingRequired = append (missingRequired , "AGGREGATOR_EXTERNAL_HOST" )
43+ }
44+ if model .ClientId == "" {
45+ missingRequired = append (missingRequired , "CLIENT_ID" )
3946 }
47+ if model .ClientSecret == "" {
48+ missingRequired = append (missingRequired , "CLIENT_SECRET" )
49+ }
50+ if len (missingRequired ) > 0 {
51+ logrus .Fatalf ("Missing required environment variables: %s" , strings .Join (missingRequired , ", " ))
52+ }
53+
4054 model .Protocol = "http"
4155 model .ExternalHost = externalBase
4256 if parsed , err := url .Parse (externalBase ); err == nil && parsed .Scheme != "" {
4357 model .Protocol = strings .ToLower (parsed .Scheme )
4458 model .ExternalHost = parsed .Host
4559 }
4660
47- // Read Authorization configuration from environment variables
48- model .ClientId = os .Getenv ("CLIENT_ID" )
49- if model .ClientId == "" {
50- logrus .Fatal ("Environment variable CLIENT_ID must be set" )
51- }
52- model .ClientSecret = os .Getenv ("CLIENT_SECRET" )
53- if model .ClientSecret == "" {
54- logrus .Fatal ("Environment variable CLIENT_SECRET must be set" )
55- }
56-
57- model .ProvisionClientID = os .Getenv ("PROVISION_CLIENT_ID" )
58- model .ProvisionClientSecret = os .Getenv ("PROVISION_CLIENT_SECRET" )
59- model .ProvisionWebID = os .Getenv ("PROVISION_WEBID" )
60- model .ProvisionIDP = os .Getenv ("PROVISION_IDP" )
61- model .ProvisionAuthorizationServer = os .Getenv ("PROVISION_AUTHORIZATION_SERVER" )
61+ model .ProvisionClientID = strings .TrimSpace (os .Getenv ("PROVISION_CLIENT_ID" ))
62+ model .ProvisionClientSecret = strings .TrimSpace (os .Getenv ("PROVISION_CLIENT_SECRET" ))
63+ model .ProvisionWebID = strings .TrimSpace (os .Getenv ("PROVISION_WEBID" ))
64+ model .ProvisionIDP = strings .TrimSpace (os .Getenv ("PROVISION_IDP" ))
65+ model .ProvisionAuthorizationServer = strings .TrimSpace (os .Getenv ("PROVISION_AUTHORIZATION_SERVER" ))
6266 model .IDPServerType = strings .ToLower (strings .TrimSpace (os .Getenv ("IDP_SERVER_TYPE" )))
6367
6468 allowedTypes := parseAllowedRegistrationTypes (os .Getenv ("ALLOWED_REGISTRATION_TYPES" ))
6569 model .AllowedRegistrationTypes = allowedTypes
6670 if hasRegistrationType (allowedTypes , "provision" ) {
71+ missingProvision := make ([]string , 0 , 5 )
6772 if model .ProvisionClientID == "" {
68- logrus . Fatal ( "Environment variable PROVISION_CLIENT_ID must be set when provision registration is allowed " )
73+ missingProvision = append ( missingProvision , "PROVISION_CLIENT_ID " )
6974 }
7075 if model .ProvisionClientSecret == "" {
71- logrus . Fatal ( "Environment variable PROVISION_CLIENT_SECRET must be set when provision registration is allowed " )
76+ missingProvision = append ( missingProvision , "PROVISION_CLIENT_SECRET " )
7277 }
7378 if model .ProvisionWebID == "" {
74- logrus . Fatal ( "Environment variable PROVISION_WEBID must be set when provision registration is allowed " )
79+ missingProvision = append ( missingProvision , "PROVISION_WEBID " )
7580 }
7681 if model .ProvisionIDP == "" {
77- logrus . Fatal ( "Environment variable PROVISION_IDP must be set when provision registration is allowed " )
82+ missingProvision = append ( missingProvision , "PROVISION_IDP " )
7883 }
7984 if model .ProvisionAuthorizationServer == "" {
80- logrus .Fatal ("Environment variable PROVISION_AUTHORIZATION_SERVER must be set when provision registration is allowed" )
85+ missingProvision = append (missingProvision , "PROVISION_AUTHORIZATION_SERVER" )
86+ }
87+ if len (missingProvision ) > 0 {
88+ logrus .Fatalf (
89+ "Missing required provisioning environment variables (ALLOWED_REGISTRATION_TYPES includes provision): %s" ,
90+ strings .Join (missingProvision , ", " ),
91+ )
8192 }
8293 }
8394
0 commit comments