| 255 | # test with an auth layer that requires a JWT with a certain length |
| 256 | @app.server.before_request |
| 257 | def add_auth(): |
| 258 | if flask.request.method != "OPTIONS": |
| 259 | token = flask.request.headers.environ.get("HTTP_AUTHORIZATION") |
| 260 | if jwt_token.value and ( |
| 261 | not token or len(token) != jwt_token.value + len("Bearer ") |
| 262 | ): |
| 263 | # Read the data to prevent bug with base http server. |
| 264 | flask.request.get_json(silent=True) |
| 265 | flask.abort(expiry_code, description="JWT Expired " + str(token)) |
| 266 | |
| 267 | dash_duo.start_server(app) |
| 268 | |