Authenticates a user with username and password. Returns: Empty response on success, error object otherwise.
()
| 237 | @api_blueprint.route('/auth', methods=['POST']) |
| 238 | @no_auth_required() |
| 239 | def auth_post(): |
| 240 | """Authenticates a user with username and password. |
| 241 | |
| 242 | Returns: |
| 243 | Empty response on success, error object otherwise. |
| 244 | """ |
| 245 | logger.info_sensitive( |
| 246 | 'Login request from IP %s', |
| 247 | flask.request.headers.get('X-Forwarded-For', flask.request.remote_addr)) |
| 248 | try: |
| 249 | username, password = request_parsers.credentials.parse_credentials( |
| 250 | flask.request) |
| 251 | except request_parsers.errors.Error as e: |
| 252 | return json_response.error(e), 400 |
| 253 | if auth.can_authenticate(username, password): |
| 254 | session.login(username) |
| 255 | return json_response.success() |
| 256 | return json_response.error( |
| 257 | NotAuthenticatedError('Invalid username and password')), 401 |
| 258 | |
| 259 | |
| 260 | @api_blueprint.route('/logout', methods=['POST']) |
nothing calls this directly
no test coverage detected