Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #1169 by Proxy-Authorization header generation #1172

Merged
merged 1 commit into from Feb 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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