mirror of
https://github.com/3proxy/3proxy.git
synced 2026-11-16 06:05:50 +08:00
proxy: credentials of an earlier request not inherited by the next
This commit is contained in:
parent
796eff444a
commit
79583d7aa7
@ -632,6 +632,15 @@ for(;;){
|
|||||||
hdrfree(&buf, &bufown);
|
hdrfree(&buf, &bufown);
|
||||||
hdrsdone = 0;
|
hdrsdone = 0;
|
||||||
|
|
||||||
|
/* What the request brought belongs to it alone. A connection can carry
|
||||||
|
a request after another's, so the credentials of an earlier request
|
||||||
|
decide nothing for this one. */
|
||||||
|
*param->username = 0;
|
||||||
|
*param->password = 0;
|
||||||
|
param->pwtype = 0;
|
||||||
|
*param->extusername = 0;
|
||||||
|
*param->extpassword = 0;
|
||||||
|
|
||||||
if(keepalive && (param->cliinbuf == param->clioffset) && (param->remsock != INVALID_SOCKET)){
|
if(keepalive && (param->cliinbuf == param->clioffset) && (param->remsock != INVALID_SOCKET)){
|
||||||
memset(fds, 0, sizeof(fds));
|
memset(fds, 0, sizeof(fds));
|
||||||
fds[0].fd = param->clisock;
|
fds[0].fd = param->clisock;
|
||||||
|
|||||||
@ -4,6 +4,8 @@ Access rules accumulate until "flush", so each service section here starts
|
|||||||
from a clean list.
|
from a clean list.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import base64
|
||||||
|
|
||||||
|
|
||||||
def run(t):
|
def run(t):
|
||||||
if not t.skip_unless("httpsrv"):
|
if not t.skip_unless("httpsrv"):
|
||||||
@ -108,3 +110,18 @@ def run(t):
|
|||||||
t.eq(407, t.http(origin + "/echo", proxy=needs_auth,
|
t.eq(407, t.http(origin + "/echo", proxy=needs_auth,
|
||||||
proxy_auth=("alice", "wrong")).status,
|
proxy_auth=("alice", "wrong")).status,
|
||||||
"wrong proxy credentials are refused")
|
"wrong proxy credentials are refused")
|
||||||
|
|
||||||
|
# credentials do not outlive the request which carried them: a second
|
||||||
|
# request on the same connection, without them, is asked again
|
||||||
|
creds = base64.b64encode(b"alice:secret").decode()
|
||||||
|
text, closed = t.raw_session(auth,
|
||||||
|
f"GET {origin}/echo HTTP/1.1\r\nHost: 127.0.0.1:{srv}\r\n"
|
||||||
|
f"Proxy-Authorization: Basic {creds}\r\n\r\n"
|
||||||
|
f"GET {origin}/echo HTTP/1.1\r\nHost: 127.0.0.1:{srv}\r\n"
|
||||||
|
f"Connection: close\r\n\r\n")
|
||||||
|
parts = text.split("HTTP/1.")
|
||||||
|
t.eq(3, len(parts), "the kept connection answers both requests")
|
||||||
|
t.eq(True, parts[1].startswith("1 200"),
|
||||||
|
"the request with credentials is allowed")
|
||||||
|
t.eq(True, parts[2].startswith("0 407"),
|
||||||
|
"the request after it, without credentials, is refused")
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user