Skip to content

Commit d5e7b70

Browse files
authored
Fix #1169 by Proxy-Authorization header generation (#1172)
1 parent cd9eed5 commit d5e7b70

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

integration_tests/samples/socket_mode/builtin_proxy_auth_example.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
from slack_sdk.socket_mode import SocketModeClient
1515

1616
# https://github.com/seratch/my-proxy-server
17-
# go build && ./my-proxy-sever -a
18-
proxy_url = "http://user:pass@localhost:9000"
17+
# go build && my-proxy-server -a -u user -p pass/word
18+
proxy_url = "http://user:pass%2Fword@localhost:9000"
1919

2020
client = SocketModeClient(
2121
app_token=os.environ.get("SLACK_SDK_TEST_SOCKET_MODE_APP_TOKEN"),

slack_sdk/socket_mode/builtin/internals.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from logging import Logger
1313
from threading import Lock
1414
from typing import Tuple, Optional, Union, List, Callable, Dict
15-
from urllib.parse import urlparse
15+
from urllib.parse import urlparse, unquote
1616

1717
from .frame_header import FrameHeader
1818

@@ -59,7 +59,9 @@ def _establish_new_socket_connection(
5959
message = [f"CONNECT {server_hostname}:{server_port} HTTP/1.0"]
6060
if parsed_proxy.username is not None and parsed_proxy.password is not None:
6161
# In the case where the proxy is "http://{username}:{password}@{hostname}:{port}"
62-
raw_value = f"{parsed_proxy.username}:{parsed_proxy.password}"
62+
raw_value = (
63+
f"{unquote(parsed_proxy.username)}:{unquote(parsed_proxy.password)}"
64+
)
6365
auth = b64encode(raw_value.encode("utf-8")).decode("ascii")
6466
message.append(f"Proxy-Authorization: Basic {auth}")
6567
if proxy_headers is not None:

0 commit comments

Comments
 (0)