Skip to content

Commit 3e2ef5e

Browse files
committed
Sanitise authentication/authorisation log messages
Re ECFLOW-2004
1 parent fe3a462 commit 3e2ef5e

4 files changed

Lines changed: 16 additions & 17 deletions

File tree

libs/base/src/ecflow/base/AuthenticationDetails.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,7 @@ inline authentication_t verify_user_authentication_rules(const AbstractServer& s
7272
return authentication_t::success("Authentication (user command) successful");
7373
}
7474

75-
return authentication_t::failure("Authentication (user command) failed, due to: Incorrect credentials for (" +
76-
command.identity().username() + " / " + command.identity().password() +
77-
") is not authentic");
75+
return authentication_t::failure("Authentication (user command) failed, due to: Incorrect credentials detected");
7876
}
7977

8078
template <typename COMMAND>

libs/core/src/ecflow/core/Identity.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class CustomUserX {
8181
[[nodiscard]] std::string username() const { return username_; }
8282
[[nodiscard]] std::string password() const { return password_; }
8383

84-
[[nodiscard]] std::string as_string() const { return "{UserX: " + username_ + ":" + password_ + "}"; }
84+
[[nodiscard]] std::string as_string() const { return "{UserX: " + username_ + ":<omitted>}"; }
8585

8686
private:
8787
std::string username_;
@@ -97,7 +97,7 @@ class SecureUserX {
9797
[[nodiscard]] std::string username() const { return username_; }
9898
[[nodiscard]] std::string password() const { return password_; }
9999

100-
[[nodiscard]] std::string as_string() const { return "{SecuredUserX: " + username_ + ":" + password_ + "}"; }
100+
[[nodiscard]] std::string as_string() const { return "{SecuredUserX: " + username_ + ":<omitted>}"; }
101101

102102
private:
103103
std::string username_;

libs/core/src/ecflow/core/PasswdFile.cpp

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ bool PasswdFile::check_at_least_one_user_with_host_and_port(const std::string& h
131131

132132
std::string PasswdFile::get_passwd(const std::string& user, const std::string& host, const std::string& port) {
133133
#ifdef DEBUG_ME
134-
cout << "PasswdFile::get_passwd user(" << user << ") host(" << host << ") port(" << port << ")\n";
134+
std::cout << "PasswdFile::get_passwd user(" << user << ") host(" << host << ") port(" << port << ")\n";
135135
#endif
136136
size_t vec_size = vec_.size();
137137
for (size_t i = 0; i < vec_size; i++) {
@@ -144,22 +144,22 @@ std::string PasswdFile::get_passwd(const std::string& user, const std::string& h
144144

145145
bool PasswdFile::authenticate(const std::string& user, const std::string& passwd) const {
146146
#ifdef DEBUG_ME
147-
cout << " PasswdFile::authenticate user:" << user << " passwd:" << passwd << " file:" << passwd_file_
148-
<< " vec_.size(): " << vec_.size() << "\n";
149-
cout << dump() << "\n";
147+
std::cout << " PasswdFile::authenticate user:" << user << " passwd: <omitted> file:" << passwd_file_
148+
<< " vec_.size(): " << vec_.size() << "\n";
149+
std::cout << dump() << "\n";
150150
#endif
151151

152152
if (user.empty()) {
153153
#ifdef DEBUG_ME
154-
cout << " PasswdFile::authenticate: user empty: FAIL\n";
154+
std::cout << " PasswdFile::authenticate: user empty: FAIL\n";
155155
#endif
156156
return false;
157157
}
158158

159159
// no password specified, and password file is empty
160160
if (passwd.empty() && vec_.empty()) {
161161
#ifdef DEBUG_ME
162-
cout << " PasswdFile::authenticate no password and password file empty: PASS\n";
162+
std::cout << " PasswdFile::authenticate no password and password file empty: PASS\n";
163163
#endif
164164
return true;
165165
}
@@ -170,13 +170,13 @@ bool PasswdFile::authenticate(const std::string& user, const std::string& passwd
170170
if (vec_[i].user() == user) {
171171
if (vec_[i].passwd() == passwd) {
172172
#ifdef DEBUG_ME
173-
cout << " PasswdFile::authenticate user and password match: PASS\n";
173+
std::cout << " PasswdFile::authenticate user and password match: PASS\n";
174174
#endif
175175
return true;
176176
}
177177
else {
178178
#ifdef DEBUG_ME
179-
cout << " PasswdFile::authenticate: user found but passwd did not match: FAIL\n";
179+
std::cout << " PasswdFile::authenticate: user found but passwd did not match: FAIL\n";
180180
#endif
181181
return false;
182182
}
@@ -188,21 +188,22 @@ bool PasswdFile::authenticate(const std::string& user, const std::string& passwd
188188
// User not found, but if passwd is not empty, then fail.
189189
if (!passwd.empty()) {
190190
#ifdef DEBUG_ME
191-
cout << " PasswdFile::authenticate: user NOT found, passwd is NOT EMPTY: FAIL\n";
191+
std::cout << " PasswdFile::authenticate: user NOT found, passwd is NOT EMPTY: FAIL\n";
192192
#endif
193193
return false;
194194
}
195195

196196
// Server has a password file, but user not found and passwd is empty.
197197
if (vec_.empty()) {
198198
#ifdef DEBUG_ME
199-
cout << " PasswdFile::authenticate: true, user NOT found, and passwd EMPTY, and password file EMPTY\n";
199+
std::cout
200+
<< " PasswdFile::authenticate: true, user NOT found, and passwd EMPTY, and password file EMPTY\n";
200201
#endif
201202
return true;
202203
}
203204

204205
#ifdef DEBUG_ME
205-
cout << " PasswdFile::authenticate false, user NOT found, and passwd EMPTY\n";
206+
std::cout << " PasswdFile::authenticate false, user NOT found, and passwd EMPTY\n";
206207
#endif
207208
return false;
208209
}

libs/service/src/ecflow/service/mirror/MirrorClient.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ MirrorData MirrorClient::get_node_status(const std::string& remote_host,
7171
const std::string& remote_username,
7272
const std::string& remote_password) const {
7373
SLOG(D, "MirrorClient: Accessing " << remote_host << ":" << remote_port << ", path=" << node_path);
74-
SLOG(D, "MirrorClient: Authentication Credentials: " << remote_username << ":" << remote_password);
74+
SLOG(D, "MirrorClient: Authentication credentials: " << remote_username << ":<omitted>");
7575

7676
try {
7777
if (!impl_->initialized_) {

0 commit comments

Comments
 (0)