Blockstream / blind_pin_server

MIT License
13 stars 10 forks source link

Allow session lifetime to be overridden from environment/dotenv #10

Closed JamieDriver closed 2 years ago

JamieDriver commented 2 years ago

As discussed, set the default to 5mins, and have the test use the env to set a short lifetime.

Test appears to work as desired - see time jump from 08:30:27 to 08:30:31

test_delayed_interaction (blind_pin_server.test.test_pinserver.PINServerTest) ... 127.0.0.1 - - [21/Nov/2022 08:30:27] "POST /start_handshake HTTP/1.1" 200 -
127.0.0.1 - - [21/Nov/2022 08:30:27] "POST /set_pin HTTP/1.1" 200 -
127.0.0.1 - - [21/Nov/2022 08:30:27] "POST /start_handshake HTTP/1.1" 200 -
127.0.0.1 - - [21/Nov/2022 08:30:27] "POST /get_pin HTTP/1.1" 200 -
127.0.0.1 - - [21/Nov/2022 08:30:27] "POST /start_handshake HTTP/1.1" 200 -
[2022-11-21 08:30:31,566] ERROR in flaskserver: Error: <class 'KeyError'> '0310605cac0440704b7ad3122baed466ca069d29f73d6efb935baf21578d4f12f2'
[2022-11-21 08:30:31,566] ERROR in flaskserver: Request body: b'{"ske": "0310605cac0440704b7ad3122baed466ca069d29f73d6efb935baf21578d4f12f2", "cke": "024e38e6d1cadad11eb0875c1074ad2b3848b86b574e7735b4412da4bbcdeba7a7", "encrypted_data": "c37f002bb1bb63c9b681929338a32f7403a239c49f8b09008b98a146caa6e4d854f41c3872eb67100791e94d68b68e50f2fb31579d6336da921a7dc23c17da3126274f956c03f5d8d08df1c52cbf632e923f0a2a8df410bac25c4636a5ffce13e108d3a60b4d604f32226a5602e26183e5248331d16e613b4902edad08ab45876ae8e33ee3d085500ff21a00c76a181470e83b662bfab1d1c6e9799e6dc70d90", "hmac_encrypted_data": "4ae810194942adbb9ebc4f775f5a310f943b72de1134e6e8c87de6e9508930ba"}'
[2022-11-21 08:30:31,566] ERROR in app: Exception on /get_pin [POST]
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.7.15/x64/lib/python3.7/site-packages/flask/app.py", line 2073, in wsgi_app
    response = self.full_dispatch_request()
  File "/opt/hostedtoolcache/Python/3.7.15/x64/lib/python3.7/site-packages/flask/app.py", line 1518, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/opt/hostedtoolcache/Python/3.7.15/x64/lib/python3.7/site-packages/flask/app.py", line 1516, in full_dispatch_request
    rv = self.dispatch_request()
  File "/opt/hostedtoolcache/Python/3.7.15/x64/lib/python3.7/site-packages/flask/app.py", line 1502, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
  File "/home/runner/work/blind_pin_server/blind_pin_server/flaskserver.py", line 93, in get_pin_route
    return _complete_server_call(PINDb.get_aes_key)
  File "/home/runner/work/blind_pin_server/blind_pin_server/flaskserver.py", line 89, in _complete_server_call
    raise e
  File "/home/runner/work/blind_pin_server/blind_pin_server/flaskserver.py", line 66, in _complete_server_call
    e_ecdh_server = sessions[ske]
KeyError: '0310605cac0440704b7ad3122baed466ca069d29f73d6efb935baf21578d4f12f2'
127.0.0.1 - - [21/Nov/2022 08:30:31] "POST /get_pin HTTP/1.1" 500 -
ok
jgriffiths commented 2 years ago

utack 188fdb01797074de92fb4ab2deaeeb697c44ef85

greenaddress commented 2 years ago

utack 188fdb01797074de92fb4ab2deaeeb697c44ef85