Skip to content

Commit

Permalink
Fix slackapi#1169 by Proxy-Authorization header generation
Browse files Browse the repository at this point in the history
  • Loading branch information
seratch committed Feb 7, 2022
1 parent cd9eed5 commit d984b77
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Expand Up @@ -14,8 +14,8 @@
from slack_sdk.socket_mode import SocketModeClient

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

client = SocketModeClient(
app_token=os.environ.get("SLACK_SDK_TEST_SOCKET_MODE_APP_TOKEN"),
Expand Down
6 changes: 4 additions & 2 deletions slack_sdk/socket_mode/builtin/internals.py
Expand Up @@ -12,7 +12,7 @@
from logging import Logger
from threading import Lock
from typing import Tuple, Optional, Union, List, Callable, Dict
from urllib.parse import urlparse
from urllib.parse import urlparse, unquote

from .frame_header import FrameHeader

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

0 comments on commit d984b77

Please sign in to comment.