Add nonInteractiveMode option

This commit is contained in:
Bartosz Wieczorek 2025-01-15 13:05:47 +01:00
parent 33b944b839
commit 0f19e0c145
3 changed files with 9 additions and 8 deletions

View File

@ -27,6 +27,7 @@ class Configuration {
bool logging{};
bool autopushPrompt{};
FailMode failMode{};
bool nonInteractiveMode{};
};
namespace {
@ -138,7 +139,7 @@ constexpr auto make_entry(const char * name, const char * defaultValue) {
return Entry{name, defaultValue, Entry::make_read_function< member >()};
}
constexpr static inline std::array< Entry, 8 > configurationVariables = { //
constexpr static inline std::array< Entry, 9 > configurationVariables = { //
make_entry< &Configuration::logging >("logging", "true"),
make_entry< &Configuration::systemToken >("systemToken", nullptr),
make_entry< &Configuration::secretKey >("secretKey", nullptr),
@ -146,7 +147,9 @@ constexpr static inline std::array< Entry, 8 > configurationVariables = { //
make_entry< &Configuration::prompt >("prompt", "1"),
make_entry< &Configuration::enablePasswdEmail >("enablePasswdEmail", "true"),
make_entry< &Configuration::autopushPrompt >("autopushPrompt", "false"),
make_entry< &Configuration::failMode >("failMode", "deny")};
make_entry< &Configuration::failMode >("failMode", "deny"),
make_entry< &Configuration::nonInteractiveMode >("nonInteractiveMode", "false")
};
class ConfigurationFactory {
public:

View File

@ -21,7 +21,7 @@ class RublonFactory {
return tl::unexpected{ConfigurationError{}};
}
return Session{pam, config.value(), true};
return Session{pam, config.value()};
}
};

View File

@ -17,14 +17,12 @@ class Session {
std::pmr::string _tid;
std::pmr::string _accessToken;
bool _interactiveMode;
CoreHandler_t _coreHandler;
/// TODO log
/// TODO momory resource
public:
Session(const Pam_t & pam, const Configuration & config, bool interactive = true)
: _pam{pam}, _config{config}, _interactiveMode{interactive}, _coreHandler{_config} {
Session(const Pam_t & pam, const Configuration & config)
: _pam{pam}, _config{config}, _coreHandler{_config} {
log(LogLevel::Debug, __PRETTY_FUNCTION__);
}
@ -52,7 +50,7 @@ class Session {
}
bool inInteractiveMode() const {
return _interactiveMode;
return _config.nonInteractiveMode == false;
}
void updateTransactionId(const Value * tid) {