Skip to content
Permalink
Browse files
[git-webkit] Check expiration in token
https://bugs.webkit.org/show_bug.cgi?id=240883
<rdar://problem/93859778>

Reviewed by Chris Dumez.

* Tools/Scripts/libraries/webkitbugspy/setup.py: Bump version.
* Tools/Scripts/libraries/webkitbugspy/webkitbugspy/__init__.py: Ditto.
* Tools/Scripts/libraries/webkitbugspy/webkitbugspy/github.py:
(Tracker.credentials.validater): Check token expiration explicitly.

Canonical link: https://commits.webkit.org/250954@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@294798 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
JonWBedard committed May 25, 2022
1 parent d6ff115 commit c3876a11b579724c14a39338f6e3f95e4c4af466
Showing 3 changed files with 6 additions and 3 deletions.
@@ -30,7 +30,7 @@ def readme():

setup(
name='webkitbugspy',
version='0.6.1',
version='0.6.2',
description='Library containing a shared API for various bug trackers.',
long_description=readme(),
classifiers=[
@@ -46,7 +46,7 @@ def _maybe_add_library_path(path):
"Please install webkitcorepy with `pip install webkitcorepy --extra-index-url <package index URL>`"
)

version = Version(0, 6, 1)
version = Version(0, 6, 2)

from .user import User
from .issue import Issue
@@ -103,7 +103,10 @@ def validater(username, access_token):
headers=dict(Accept='application/vnd.github.v3+json'),
auth=HTTPBasicAuth(username, access_token),
)
if response.status_code == 200 and response.json().get('login') == username:
expiration = response.headers.get('github-authentication-token-expiration', None)
if expiration:
expiration = int(calendar.timegm(datetime.strptime(expiration, '%Y-%m-%d %H:%M:%S UTC').timetuple()))
if (expiration is None or expiration > time.time()) and response.status_code == 200 and response.json().get('login') == username:
return True
sys.stderr.write('Login to {} for {} failed\n'.format(self.api_url, username))
return False

0 comments on commit c3876a1

Please sign in to comment.