mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-22 02:51:03 +00:00
Plugin bitcoind_: fix base64 encoding for credentials
Python2.7 (as well as Python3.x) refused to execute the previously used encoding (`foo.encode('base64')`). It is unknown, whether it worked before with an older Python version.
This commit is contained in:
parent
7f77bdf74c
commit
b6a41513d7
1 changed files with 4 additions and 3 deletions
|
@ -50,6 +50,7 @@ Copyright (C) 2012 Mike Koss
|
||||||
|
|
||||||
=cut"""
|
=cut"""
|
||||||
|
|
||||||
|
import base64
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
@ -236,9 +237,9 @@ class Proxy(object):
|
||||||
}
|
}
|
||||||
request = urllib.request.Request(self.service.url, json.dumps(data))
|
request = urllib.request.Request(self.service.url, json.dumps(data))
|
||||||
if self.service.username:
|
if self.service.username:
|
||||||
# Strip the newline from the b64 encoding!
|
auth_string = '%s:%s' % (self.service.username, self.service.password)
|
||||||
b64 = ('%s:%s' % (self.service.username, self.service.password)).encode('base64')[:-1]
|
auth_b64 = base64.urlsafe_b64encode(auth_string.encode()).decode()
|
||||||
request.add_header('Authorization', 'Basic %s' % b64)
|
request.add_header('Authorization', 'Basic %s' % auth_b64)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
body = urllib.request.urlopen(request).read()
|
body = urllib.request.urlopen(request).read()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue