| 51 | |
| 52 | @functools.wraps(handler) |
| 53 | def handler_with_auth_check(*args, **kwargs): |
| 54 | next_check_due = _auth_expiry_timestamps.get(flask.request.sid, None) |
| 55 | |
| 56 | if (not next_check_due) or (utc.now() > next_check_due): |
| 57 | if not session.is_auth_valid(satisfies_role=auth.Role.OPERATOR): |
| 58 | flask_socketio.disconnect() |
| 59 | return None |
| 60 | |
| 61 | _auth_expiry_timestamps[flask.request.sid] = utc.now( |
| 62 | ) + datetime.timedelta(seconds=cache_ttl_seconds) |
| 63 | |
| 64 | return handler(*args, **kwargs) |
| 65 | |
| 66 | return handler_with_auth_check |
| 67 | |