Skip to content

Commit afc4953

Browse files
author
Rafał Miłecki
committed
Detect redirection command in authentication response
In some situations server may command user agent to redirect to a specific page as a result of (failed?) authentication attempt. Example of such response: ret=0,redir=/remote/login?&err=sslvpn_login_permission_denied&lang=en When using real web browser is results in JavaScript redirecting user to the /remote/login?&err=sslvpn_login_permission_denied&lang=en . In future we may try to use redirection info to retreive the cause of authentication failure. It's not clear what would be the best way to handle that. Check for "err" parameter value? Send another HTTP request? For now just log relevant info for debugging purposes. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
1 parent bb6be54 commit afc4953

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/http.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ int auth_log_in(struct tunnel *tunnel)
661661
sizeof("ajax=1")
662662
)] = { '\0' };
663663
#undef OFV_MAX
664-
char token[128], tokenresponse[256], tokenparams[320];
664+
char redir[128], token[128], tokenresponse[256], tokenparams[320];
665665
char action_url[1024] = { '\0' };
666666
char *res = NULL;
667667
uint32_t response_size;
@@ -730,6 +730,12 @@ int auth_log_in(struct tunnel *tunnel)
730730
ret = ERR_HTTP_BAD_RES_CODE;
731731
goto end;
732732
}
733+
734+
ret = get_value_from_response(res, "redir=", redir, 128);
735+
if (ret == 1) {
736+
log_debug("Received redirection: \"%s\"\n", redir);
737+
}
738+
733739
ret = auth_get_cookie(tunnel, res, response_size);
734740
if (ret == ERR_HTTP_NO_COOKIE) {
735741
struct vpn_config *cfg = tunnel->config;

0 commit comments

Comments
 (0)