Skip to content

Commit 1027e4c

Browse files
author
Rafał Miłecki
committed
Extract & log authentication challenge message
When gateway replies with a challenge it (usually?) provides a relevant message. Example: ret=6,actionurl=/remote/logincheck,magic=1-12345678,reqid=0,grpid=1,pid=249,is_chal_rsp=1,pass_renew=1,allow_cancel=1,chal_msg=Your password will expire in 3 days. Would you like to change it? Extract such messages and log them so user can understand what went wrong. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
1 parent cce87c7 commit 1027e4c

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

src/config.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ struct x509_digest {
4646
#define REALM_SIZE 63
4747
#define PEM_PASSPHRASE_SIZE 31
4848
#define AUTH_RET_SIZE 3 /* Numeric value (e.g. "0", "1", "6") */
49+
#define CHAL_MSG_SIZE 128 /* E.g. "Your password will expire in 3 days. Would you like to change it?" */
4950

5051
/*
5152
* RFC 6265 does not limit the size of cookies:

src/http.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,7 @@ int auth_log_in(struct tunnel *tunnel)
718718
ret = get_value_from_response(res, "ret=", auth_ret_text, sizeof(auth_ret_text));
719719
if (ret == 1) {
720720
int auth_ret = strtol(auth_ret_text, NULL, 10);
721+
char chal_msg[CHAL_MSG_SIZE + 1];
721722

722723
switch (auth_ret) {
723724
case 0:
@@ -729,6 +730,12 @@ int auth_log_in(struct tunnel *tunnel)
729730
break;
730731
case 6:
731732
log_error("Gateway replied to authentication with an unsupported challenge\n");
733+
734+
ret = get_value_from_response(res, "chal_msg=", chal_msg,
735+
sizeof(chal_msg));
736+
if (ret == 1)
737+
log_info("Challenge message: \"%s\"\n", chal_msg);
738+
732739
ret = ERR_HTTP_PERMISSION;
733740
goto end;
734741
default:

0 commit comments

Comments
 (0)