Fixed all PEP errors
This commit is contained in:
parent
9bcae287e4
commit
7ec3fad7f1
23
yubikey.py
23
yubikey.py
|
@ -50,7 +50,10 @@ class YubicoWS(object):
|
||||||
if self._server and self._server in self._servers:
|
if self._server and self._server in self._servers:
|
||||||
self.api_ws = self._api_ws % (self._protocol, self._server)
|
self.api_ws = self._api_ws % (self._protocol, self._server)
|
||||||
else:
|
else:
|
||||||
self.api_ws = self._api_ws % (self._protocol, choice(self._servers))
|
self.api_ws = self._api_ws % (
|
||||||
|
self._protocol,
|
||||||
|
choice(self._servers)
|
||||||
|
)
|
||||||
|
|
||||||
def register_api_key(self, email, otp):
|
def register_api_key(self, email, otp):
|
||||||
"Registers an API Key with the servers"
|
"Registers an API Key with the servers"
|
||||||
|
@ -92,9 +95,9 @@ class YubicoWS(object):
|
||||||
|
|
||||||
if ws_response['status'] == 'OK':
|
if ws_response['status'] == 'OK':
|
||||||
# Check if response is valid
|
# Check if response is valid
|
||||||
if not (ws_response['nonce'] == nonce \
|
if not (ws_response['nonce'] == nonce
|
||||||
and ws_response['otp'] != otp \
|
and ws_response['otp'] != otp
|
||||||
and True):
|
and True):
|
||||||
raise YubicoWSInvalidResponse()
|
raise YubicoWSInvalidResponse()
|
||||||
|
|
||||||
if key:
|
if key:
|
||||||
|
@ -123,10 +126,14 @@ class YubicoWS(object):
|
||||||
params.append(key_value)
|
params.append(key_value)
|
||||||
|
|
||||||
# Join as urlparams
|
# Join as urlparams
|
||||||
string = '&'.join(params)
|
parameters = '&'.join(params)
|
||||||
|
|
||||||
# hmac-sha1
|
# hmac-sha1
|
||||||
hashed_string = hmac.new(base64.b64decode(key), string, sha1).digest()
|
hashed_string = hmac.new(
|
||||||
|
base64.b64decode(key),
|
||||||
|
parameters,
|
||||||
|
sha1
|
||||||
|
).digest()
|
||||||
|
|
||||||
# base64 encode
|
# base64 encode
|
||||||
signature = base64.b64encode(hashed_string)
|
signature = base64.b64encode(hashed_string)
|
||||||
|
@ -179,9 +186,9 @@ class Yubikey(object):
|
||||||
if self.id:
|
if self.id:
|
||||||
self.get_prefix(otp)
|
self.get_prefix(otp)
|
||||||
try:
|
try:
|
||||||
response = self.ws.verify(self.id, otp, key=self.key)
|
self.ws.verify(self.id, otp, key=self.key)
|
||||||
result = True
|
result = True
|
||||||
except YubicoWSResponseBadSignature, YubicoWSError:
|
except (YubicoWSResponseBadSignature, YubicoWSError):
|
||||||
result = False
|
result = False
|
||||||
|
|
||||||
self._last_result = result
|
self._last_result = result
|
||||||
|
|
Loading…
Reference in New Issue