@@ -78,6 +78,17 @@ void ConfigManager::loadConfig() {
7878
7979 std::filesystem::path template_path = getTemplateConfig ().path ;
8080 loadEndpointConfigsRecursively (template_path);
81+
82+ // Propagate global OIDC config to endpoints that have type:oidc but no local oidc block
83+ if (global_auth_config.oidc ) {
84+ for (auto & ep : endpoints) {
85+ if (ep.auth .type == " oidc" && !ep.auth .oidc ) {
86+ ep.auth .oidc = global_auth_config.oidc ;
87+ CROW_LOG_DEBUG << " Propagated global OIDC config to endpoint: " << ep.urlPath ;
88+ }
89+ }
90+ }
91+
8192 CROW_LOG_INFO << " Configuration loaded successfully" ;
8293 } catch (const YAML::Exception& e) {
8394 std::ostringstream error_msg;
@@ -580,8 +591,14 @@ void ConfigManager::parseEndpointAuth(const YAML::Node& endpoint_config, Endpoin
580591 CROW_LOG_DEBUG << " \t\t\t Secret Key: *****[" << aws_config.secret_key .length () << " ]" ;
581592 }
582593
594+ // Parse OIDC configuration if present
595+ if (auth_node[" oidc" ]) {
596+ CROW_LOG_DEBUG << " \t\t Parsing OIDC configuration for endpoint" ;
597+ endpoint.auth .oidc = parseOIDCConfigNode (auth_node[" oidc" ]);
598+ }
599+
583600 // Parse inline users if present
584- else if (auth_node[" users" ]) {
601+ if (auth_node[" users" ]) {
585602 CROW_LOG_DEBUG << " \t\t Parsing inline users configuration" ;
586603 for (const auto & user : auth_node[" users" ]) {
587604 AuthUser auth_user;
@@ -806,33 +823,37 @@ void ConfigManager::parseAuthConfig() {
806823 auto auth_node = config[" auth" ];
807824 auth_enabled = auth_node[" enabled" ].as <bool >();
808825 CROW_LOG_DEBUG << " Auth enabled: " << auth_enabled;
809- if (auth_enabled) {
810- AuthConfig auth_config;
811- auth_config.type = auth_node[" type" ].as <std::string>();
812- auth_config.jwt_secret = auth_node[" jwt-secret" ].as <std::string>();
813- auth_config.jwt_issuer = auth_node[" jwt-issuer" ].as <std::string>();
814- CROW_LOG_DEBUG << " Auth type: " << auth_config.type ;
815- CROW_LOG_DEBUG << " JWT issuer: " << auth_config.jwt_issuer ;
816-
817- if (auth_node[" users" ]) {
818- for (const auto & user : auth_node[" users" ]) {
819- AuthUser auth_user;
820- auth_user.username = user[" username" ].as <std::string>();
821- auth_user.password = user[" password" ].as <std::string>();
822- if (user[" roles" ]) {
823- auth_user.roles = user[" roles" ].as <std::vector<std::string>>();
824- }
825- auth_config.users .push_back (auth_user);
826- CROW_LOG_DEBUG << " Added user: " << auth_user.username << " with " << auth_user.roles .size () << " roles" ;
826+
827+ if (auth_node[" type" ]) {
828+ global_auth_config.type = auth_node[" type" ].as <std::string>();
829+ CROW_LOG_DEBUG << " Auth type: " << global_auth_config.type ;
830+ }
831+ if (auth_node[" jwt-secret" ]) {
832+ global_auth_config.jwt_secret = auth_node[" jwt-secret" ].as <std::string>();
833+ }
834+ if (auth_node[" jwt-issuer" ]) {
835+ global_auth_config.jwt_issuer = auth_node[" jwt-issuer" ].as <std::string>();
836+ CROW_LOG_DEBUG << " JWT issuer: " << global_auth_config.jwt_issuer ;
837+ }
838+
839+ if (auth_node[" users" ]) {
840+ for (const auto & user : auth_node[" users" ]) {
841+ AuthUser auth_user;
842+ auth_user.username = user[" username" ].as <std::string>();
843+ auth_user.password = user[" password" ].as <std::string>();
844+ if (user[" roles" ]) {
845+ auth_user.roles = user[" roles" ].as <std::vector<std::string>>();
827846 }
847+ global_auth_config.users .push_back (auth_user);
848+ CROW_LOG_DEBUG << " Added user: " << auth_user.username << " with " << auth_user.roles .size () << " roles" ;
828849 }
850+ }
829851
830- // Parse OIDC configuration if present
831- if (auth_node[" oidc" ]) {
832- CROW_LOG_INFO << " Parsing OIDC configuration" ;
833- auth_config.oidc = parseOIDCConfigNode (auth_node[" oidc" ]);
834- CROW_LOG_INFO << " OIDC configuration parsed successfully" ;
835- }
852+ // Parse OIDC configuration if present — store in global_auth_config
853+ if (auth_node[" oidc" ]) {
854+ CROW_LOG_INFO << " Parsing global OIDC configuration" ;
855+ global_auth_config.oidc = parseOIDCConfigNode (auth_node[" oidc" ]);
856+ CROW_LOG_INFO << " Global OIDC configuration parsed: issuer=" << global_auth_config.oidc ->issuer_url ;
836857 }
837858 }
838859}
@@ -1111,6 +1132,7 @@ const RateLimitConfig& ConfigManager::getRateLimitConfig() const { return rate_l
11111132bool ConfigManager::isHttpsEnforced () const { return https_config.enabled ; }
11121133const HttpsConfig& ConfigManager::getHttpsConfig () const { return https_config; }
11131134bool ConfigManager::isAuthEnabled () const { return auth_enabled; }
1135+ std::optional<OIDCConfig> ConfigManager::getGlobalOIDCConfig () const { return global_auth_config.oidc ; }
11141136const std::vector<EndpointConfig>& ConfigManager::getEndpoints () const { return endpoints; }
11151137std::string ConfigManager::getBasePath () const { return base_path.string (); }
11161138
0 commit comments