This repository was archived by the owner on Aug 4, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +10
-3
lines changed
Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change 11"""Runner for swift-browser-ui upload and replication operations."""
22
33__name__ = 'swift_upload_runner'
4- __version__ = '0.1.0 '
4+ __version__ = '0.1.1 '
55__author__ = 'CSC Developers'
66__license__ = 'MIT License'
Original file line number Diff line number Diff line change 55import hashlib
66import typing
77import hmac
8+ import time
89
910import aiohttp .web
1011
1112from swift_browser_ui ._convenience import (
1213 initiate_os_session
1314)
1415
15-
1616AiohttpHandler = typing .Callable [
1717 [aiohttp .web .Request ],
1818 typing .Coroutine [
@@ -70,8 +70,14 @@ async def test_signature(
7070 tokens : typing .List [bytes ],
7171 signature : str ,
7272 message : str ,
73+ validity : str ,
7374) -> bool :
7475 """Validate signature against the given tokens."""
76+ # Check signature expiration
77+ if int (validity ) < time .time ():
78+ raise aiohttp .web .HTTPUnauthorized (
79+ reason = "Signature expired"
80+ )
7581 byte_message = message .encode ("utf-8" )
7682 for token in tokens :
7783 digest = hmac .new (
@@ -104,7 +110,8 @@ async def handle_validate_authentication(
104110 await test_signature (
105111 request .app ["tokens" ],
106112 signature ,
107- validity + path
113+ validity + path ,
114+ validity
108115 )
109116
110117 return await handler (request )
You can’t perform that action at this time.
0 commit comments