Skip to content

Commit

Permalink
Merge pull request #404 from silicon-heaven/always-recognize-ldap-config
Browse files Browse the repository at this point in the history
libshvbroker: Detect LDAP config even with missing LDAP support
  • Loading branch information
fvacek authored Feb 2, 2024
2 parents 3f07a5f + c140cd5 commit adfa557
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
2 changes: 0 additions & 2 deletions libshvbroker/include/shv/broker/appclioptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,12 @@ class SHVBROKER_DECL_EXPORT AppCliOptions : public shv::core::utils::ConfigCLIOp
CLIOPTION_GETTER_SETTER2(shv::chainpack::RpcValue, "masters.connections", m, setM, asterBrokersConnections)
CLIOPTION_GETTER_SETTER2(bool, "masters.enabled", is, set, MasterBrokersEnabled)

#ifdef WITH_SHV_LDAP
CLIOPTION_GETTER_SETTER2(std::string, "ldap.username", l, setL, dapUsername)
CLIOPTION_GETTER_SETTER2(std::string, "ldap.password", l, setL, dapPassword)
CLIOPTION_GETTER_SETTER2(std::string, "ldap.hostname", l, setL, dapHostname)
CLIOPTION_GETTER_SETTER2(std::string, "ldap.searchBaseDN", l, setL, dapSearchBaseDN)
CLIOPTION_GETTER_SETTER2(chainpack::RpcValue::List, "ldap.searchAttrs", l, setL, dapSearchAttrs)
CLIOPTION_GETTER_SETTER2(chainpack::RpcValue::List, "ldap.groupMapping", l, setL, dapGroupMapping)
#endif
CLIOPTION_GETTER_SETTER2(chainpack::RpcValue::List, "azure.groupMapping", a, setA, zureGroupMapping)
};

Expand Down
2 changes: 0 additions & 2 deletions libshvbroker/src/appclioptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,12 @@ AppCliOptions::AppCliOptions()
addOption("masters.connections").setType(cp::RpcValue::Type::Map).setComment("Can be used from config file only.");
addOption("masters.enabled").setType(cp::RpcValue::Type::Bool).setNames("--mce", "--master-connections-enabled").setComment("Enable slave connections to master broker.");

#ifdef WITH_SHV_LDAP
addOption("ldap.username").setType(cp::RpcValue::Type::String).setNames("--ldap-username").setComment("Set the LDAP username for the broker to use");
addOption("ldap.password").setType(cp::RpcValue::Type::String).setNames("--ldap-password").setComment("Set the LDAP password for the broker to use");
addOption("ldap.hostname").setType(cp::RpcValue::Type::String).setNames("--ldap-host").setComment("Set the LDAP server hostname");
addOption("ldap.searchBaseDN").setType(cp::RpcValue::Type::String).setNames("--ldap-search-base-dn").setComment("Set the base DN for LDAP searches (the DN where user entries live)");
addOption("ldap.searchAttrs").setType(cp::RpcValue::Type::List).setNames("--ldap-search-attrs").setComment("Set the LDAP attributes containing the login name for LDAP user entries");
addOption("ldap.groupMapping").setType(cp::RpcValue::Type::List).setComment("Set the mapping of LDAP groups to shv groups as an ordered list of pairs");
#endif
addOption("azure.groupMapping").setType(cp::RpcValue::Type::List).setComment("Set the mapping of Azure groups to shv groups as an ordered list of pairs");
}
}
6 changes: 4 additions & 2 deletions libshvbroker/src/brokerapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,8 @@ BrokerApp::BrokerApp(int &argc, char **argv, AppCliOptions *cli_opts)
});
}

#ifdef WITH_SHV_LDAP
if (cli_opts->ldapHostname_isset()) {
#ifdef WITH_SHV_LDAP
m_ldapLib = {dlopen(LDAP_LIBNAME, RTLD_LAZY), [] (void* handle) {
if (dlclose(handle)) {
shvError() << "Couldn't close OpenLDAP library:" << dlerror();
Expand Down Expand Up @@ -393,8 +393,10 @@ BrokerApp::BrokerApp(int &argc, char **argv, AppCliOptions *cli_opts)
.groupMapping = transform_cli_group_mapping(cli_opts->ldapGroupMapping())
};
new LdapAclNode(*m_ldapConfig, etc_acl_root_node);
}
#else
shvWarning() << "LDAP has been configured, but this broker wasn't compiled with LDAP support. LDAP will NOT be enabled.";
#endif
}
if (cli_opts->azureGroupMapping_isset()) {
m_azureConfig = AzureConfig {
.groupMapping = transform_cli_group_mapping(cli_opts->azureGroupMapping())
Expand Down

0 comments on commit adfa557

Please sign in to comment.