aboutsummaryrefslogtreecommitdiff
path: root/oauth2client/crypt.py
diff options
context:
space:
mode:
authorCraig Citro <craigcitro@gmail.com>2014-08-18 10:29:51 -0700
committerCraig Citro <craigcitro@gmail.com>2014-08-18 10:29:51 -0700
commitb02156b372fa844693cab312ed2d1527c1b7aca7 (patch)
treefba576a4ecac887127959dadc1c49724b49a8ce5 /oauth2client/crypt.py
parent817eefd018e5c38c0f9b36e3f1c530bae6ee6b21 (diff)
downloadoauth2client-b02156b372fa844693cab312ed2d1527c1b7aca7.tar.gz
Assorted import/lint cleanup.
This is mostly a cleanup around import statements and a few related pylint issues.
Diffstat (limited to 'oauth2client/crypt.py')
-rw-r--r--oauth2client/crypt.py18
1 files changed, 8 insertions, 10 deletions
diff --git a/oauth2client/crypt.py b/oauth2client/crypt.py
index d0e48ef..02d3b42 100644
--- a/oauth2client/crypt.py
+++ b/oauth2client/crypt.py
@@ -336,9 +336,8 @@ def verify_signed_jwt_with_certs(jwt, certs, audience):
"""
segments = jwt.split('.')
- if (len(segments) != 3):
- raise AppIdentityError(
- 'Wrong number of segments in token: %s' % jwt)
+ if len(segments) != 3:
+ raise AppIdentityError('Wrong number of segments in token: %s' % jwt)
signed = '%s.%s' % (segments[0], segments[1])
signature = _urlsafe_b64decode(segments[2])
@@ -352,9 +351,9 @@ def verify_signed_jwt_with_certs(jwt, certs, audience):
# Check signature.
verified = False
- for (keyname, pem) in certs.items():
+ for _, pem in certs.items():
verifier = Verifier.from_string(pem, True)
- if (verifier.verify(signed, signature)):
+ if verifier.verify(signed, signature):
verified = True
break
if not verified:
@@ -372,16 +371,15 @@ def verify_signed_jwt_with_certs(jwt, certs, audience):
if exp is None:
raise AppIdentityError('No exp field in token: %s' % json_body)
if exp >= now + MAX_TOKEN_LIFETIME_SECS:
- raise AppIdentityError(
- 'exp field too far in future: %s' % json_body)
+ raise AppIdentityError('exp field too far in future: %s' % json_body)
latest = exp + CLOCK_SKEW_SECS
if now < earliest:
raise AppIdentityError('Token used too early, %d < %d: %s' %
- (now, earliest, json_body))
+ (now, earliest, json_body))
if now > latest:
raise AppIdentityError('Token used too late, %d > %d: %s' %
- (now, latest, json_body))
+ (now, latest, json_body))
# Check audience.
if audience is not None:
@@ -390,6 +388,6 @@ def verify_signed_jwt_with_certs(jwt, certs, audience):
raise AppIdentityError('No aud field in token: %s' % json_body)
if aud != audience:
raise AppIdentityError('Wrong recipient, %s != %s: %s' %
- (aud, audience, json_body))
+ (aud, audience, json_body))
return parsed