Skip to content

Commit 37a8f09

Browse files
committed
Enhance the log messages for check_authentication failures
1 parent 51f13b9 commit 37a8f09

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

cherokee/connection.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2315,6 +2315,7 @@ cherokee_connection_check_authentication (cherokee_connection_t *conn, cherokee_
23152315
*/
23162316
ret = cherokee_header_get_known (&conn->header, header_authorization, &ptr, &len);
23172317
if (ret != ret_ok) {
2318+
LOG_ERROR_S(CHEROKEE_ERROR_CONNECTION_HEADER_AUTH);
23182319
goto unauthorized;
23192320
}
23202321

@@ -2330,6 +2331,7 @@ cherokee_connection_check_authentication (cherokee_connection_t *conn, cherokee_
23302331
*/
23312332
ret = get_authorization (conn, config_entry->authentication, conn->validator, ptr, len);
23322333
if (ret != ret_ok) {
2334+
LOG_ERROR_S(CHEROKEE_ERROR_CONNECTION_AUTH_GET_HEADER);
23332335
goto unauthorized;
23342336
}
23352337

@@ -2339,11 +2341,13 @@ cherokee_connection_check_authentication (cherokee_connection_t *conn, cherokee_
23392341
void *foo;
23402342

23412343
if (cherokee_buffer_is_empty (&conn->validator->user)) {
2344+
LOG_ERROR_S(CHEROKEE_ERROR_CONNECTION_NO_USER);
23422345
goto unauthorized;
23432346
}
23442347

23452348
ret = cherokee_avl_get (config_entry->users, &conn->validator->user, &foo);
23462349
if (ret != ret_ok) {
2350+
LOG_ERROR(CHEROKEE_ERROR_CONNECTION_NO_VALID_USER, conn->validator->user.buf);
23472351
goto unauthorized;
23482352
}
23492353
}
@@ -2359,6 +2363,7 @@ cherokee_connection_check_authentication (cherokee_connection_t *conn, cherokee_
23592363
ret = cherokee_validator_check (conn->validator, conn);
23602364

23612365
if (ret != ret_ok) {
2366+
LOG_ERROR_S(CHEROKEE_ERROR_CONNECTION_LOGIN_ERROR);
23622367
goto unauthorized;
23632368
}
23642369

cherokee/error_list.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -964,6 +964,27 @@
964964

965965
# cherokee/connection.c
966966
#
967+
968+
e('CONNECTION_HEADER_AUTH',
969+
title = "Could not get authentication information from the header",
970+
desc = CODING_BUG)
971+
972+
e('CONNECTION_AUTH_GET_HEADER',
973+
title = "Could not parse the authentication information in the header",
974+
desc = "The authentication information in the connection header does not match with the configuration type.")
975+
976+
e('CONNECTION_LOGIN_ERROR',
977+
title = "Login failed: invalid password",
978+
desc = "The supplied password is invalid.")
979+
980+
e('CONNECTION_NO_USER',
981+
title = "The connection does not have users",
982+
desc = BROKEN_CONFIG)
983+
984+
e('CONNECTION_NO_VALID_USER',
985+
title = "The connection's user (%s) is not valid, please check the configuration.",
986+
desc = BROKEN_CONFIG)
987+
967988
e('CONNECTION_AUTH',
968989
title = "Unknown authentication method",
969990
desc = BROKEN_CONFIG)

0 commit comments

Comments
 (0)