Skip to content

Commit 594ce03

Browse files
authored
Credentials: redact password in URL (#1511)
Signed-off-by: Bala.FA <bala@minio.io>
1 parent bb1a57a commit 594ce03

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

minio/credentials/providers.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import ipaddress
2525
import json
2626
import os
27+
import re
2728
import socket
2829
import sys
2930
import time
@@ -80,7 +81,12 @@ def _urlopen(
8081
"""Wrapper of urlopen() handles HTTP status code."""
8182
res = http_client.urlopen(method, url, body=body, headers=headers)
8283
if res.status not in [200, 204, 206]:
83-
raise ValueError(f"{url} failed with HTTP status code {res.status}")
84+
safe_url = re.sub(
85+
r"LDAPPassword=([^&]+)", "LDAPPassword=*REDACTED*", url,
86+
)
87+
raise ValueError(
88+
f"{safe_url} failed with HTTP status code {res.status}",
89+
)
8490
return res
8591

8692

0 commit comments

Comments
 (0)