check the validity of API key Returns: 200 HTTP code if it's valid otherwise 401 error
()
| 106 | |
| 107 | |
| 108 | def is_authorized(): |
| 109 | """ |
| 110 | check the validity of API key |
| 111 | |
| 112 | Returns: |
| 113 | 200 HTTP code if it's valid otherwise 401 error |
| 114 | |
| 115 | """ |
| 116 | api_access_key = app.config["OWASP_HONEYPOT_CONFIG"]["api_access_key"] |
| 117 | |
| 118 | key_from_request = get_value_from_request("key") |
| 119 | |
| 120 | if api_access_key is not None and api_access_key != key_from_request: |
| 121 | abort(401, "invalid API key") |
| 122 | return True |
| 123 | |
| 124 | |
| 125 | @app.errorhandler(400) |
no test coverage detected