Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove useless set_user_name function #13119

Merged
merged 1 commit into from Apr 20, 2022

Conversation

yanazaeva
Copy link
Contributor

Related issue
#12144

Description

This closes #12144. The goal of this pull is to remove the unused set_user_function from the middlewares.py file, as this function is no longer useful:

@web.middleware
async def set_user_name(request, handler):
if 'token_info' in request:
request['user'] = request['token_info']['sub']
return await handler(request)

@yanazaeva yanazaeva added type/enhancement New feature or request module/api labels Apr 12, 2022
@yanazaeva yanazaeva self-assigned this Apr 12, 2022
Copy link
Contributor

@vicferpoy vicferpoy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@davidjiglesias davidjiglesias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to manually test the log status with the most common use cases after this change.

@Selutario
Copy link
Member

Manual tests

I have tested multiple endpoints after the changes performed in this PR and all responses were correct. These things were checked:

  • No strange behavior in API.
  • Info and debug logs do not show anything weird.
  • Run_as in Kibana working as expected.

As mentioned above, there are no error logs in the api.log:

2022/04/20 07:47:14 INFO: wazuh 172.19.0.1 "GET /security/user/authenticate" with parameters {} and body {} done in 0.470s: 200
2022/04/20 07:47:23 INFO: wazuh 172.19.0.1 "GET /agents" with parameters {} and body {} done in 0.049s: 200
2022/04/20 07:47:39 INFO: wazuh 172.19.0.1 "POST /agents" with parameters {} and body {"name": "test_agent", "ip": "any", "force_time": 0} done in 0.007s: 400
2022/04/20 07:47:50 INFO: wazuh 172.19.0.1 "POST /agents" with parameters {} and body {"name": "test_agent", "ip": "any"} done in 0.015s: 200
2022/04/20 07:48:11 INFO: wazuh 172.19.0.1 "GET /agents/001/key" with parameters {} and body {} done in 0.011s: 200
2022/04/20 07:48:22 INFO: wazuh 172.19.0.1 "GET /security/user/authenticate" with parameters {} and body {} done in 0.466s: 200
2022/04/20 07:48:22 INFO: wazuh 172.19.0.1 "PUT /agents/001/restart" with parameters {} and body {} done in 0.044s: 200
2022/04/20 07:48:36 INFO: wazuh 172.19.0.1 "GET /agents/no_group" with parameters {} and body {} done in 0.011s: 200
2022/04/20 07:51:25 INFO: wazuh 172.19.0.1 "GET /security/user/authenticate" with parameters {} and body {} done in 0.465s: 200
2022/04/20 07:51:25 INFO: wazuh 172.19.0.1 "GET /agents/outdated" with parameters {} and body {} done in 0.040s: 200
2022/04/20 07:51:40 INFO: wazuh 172.19.0.1 "GET /agents/stats/distinct" with parameters {} and body {} done in 0.014s: 200
2022/04/20 07:52:04 INFO: wazuh 172.19.0.1 "GET /agents/summary/os" with parameters {} and body {} done in 0.011s: 200
2022/04/20 07:52:07 INFO: wazuh 172.19.0.1 "GET /decoders" with parameters {} and body {} done in 0.358s: 200
2022/04/20 07:52:13 INFO: wazuh 172.19.0.1 "GET /decoders/files" with parameters {} and body {} done in 0.275s: 200
2022/04/20 07:52:46 INFO: wazuh 172.19.0.1 "GET /security/user/authenticate" with parameters {} and body {} done in 0.479s: 200
2022/04/20 07:52:46 INFO: wazuh 172.19.0.1 "GET /decoders/files/0005-wazuh_decoders.xml" with parameters {"raw": "true"} and body {} done in 0.043s: 200
2022/04/20 07:53:18 INFO: wazuh 172.19.0.1 "DELETE /decoders/files/0005-wazuh_decoders.xml" with parameters {} and body {} done in 0.009s: 200
2022/04/20 07:55:19 INFO: wazuh 172.19.0.1 "GET /security/user/authenticate" with parameters {} and body {} done in 0.461s: 200
2022/04/20 07:55:20 INFO: wazuh 172.19.0.1 "PUT /decoders/files/test_decoder.xml" with parameters {} and body {} done in 0.035s: 406
2022/04/20 07:55:28 INFO: wazuh 172.19.0.1 "PUT /decoders/files/test_decoder.xml" with parameters {} and body {} done in 0.011s: 200
2022/04/20 07:56:03 INFO: wazuh 172.19.0.1 "GET /cluster/api/config" with parameters {} and body {} done in 0.031s: 200
2022/04/20 07:56:21 INFO: wazuh 172.19.0.1 "GET /security/user/authenticate" with parameters {} and body {} done in 0.470s: 200
2022/04/20 07:56:21 INFO: wazuh 172.19.0.1 "GET /manager/status" with parameters {} and body {} done in 0.039s: 200
2022/04/20 07:56:27 INFO: wazuh 172.19.0.1 "GET /manager/configuration/validation" with parameters {} and body {} done in 0.930s: 200
2022/04/20 07:56:32 INFO: wazuh 172.19.0.1 "GET /mitre/mitigations" with parameters {} and body {} done in 0.255s: 200
2022/04/20 07:56:36 INFO: wazuh 172.19.0.1 "PUT /rootcheck" with parameters {} and body {} done in 0.013s: 200
2022/04/20 07:56:52 INFO: wazuh 172.19.0.1 "GET /rootcheck/000/last_scan" with parameters {} and body {} done in 0.014s: 200
2022/04/20 07:56:57 INFO: wazuh 172.19.0.1 "DELETE /rootcheck/000" with parameters {} and body {} done in 0.015s: 200
2022/04/20 07:57:03 INFO: wazuh 172.19.0.1 "GET /overview/agents" with parameters {} and body {} done in 0.021s: 200
2022/04/20 07:59:23 INFO: wazuh 172.19.0.1 "GET /security/user/authenticate" with parameters {} and body {} done in 0.476s: 200
2022/04/20 07:59:24 INFO: wazuh 172.19.0.1 "GET /rules" with parameters {} and body {} done in 0.877s: 200
2022/04/20 07:59:26 INFO: wazuh 172.19.0.1 "GET /rules/groups" with parameters {} and body {} done in 0.805s: 200
2022/04/20 07:59:34 INFO: wazuh 172.19.0.1 "DELETE /rules/files/local_rules.xml" with parameters {} and body {} done in 0.011s: 200
2022/04/20 07:59:45 INFO: wazuh 172.19.0.1 "GET /sca/000" with parameters {} and body {} done in 0.018s: 200
2022/04/20 08:00:03 INFO: wazuh 172.19.0.1 "DELETE /security/user/authenticate" with parameters {} and body {} done in 0.029s: 200
2022/04/20 08:00:13 INFO: wazuh 172.19.0.1 "GET /security/user/authenticate" with parameters {} and body {} done in 0.600s: 200
2022/04/20 08:00:20 INFO: wazuh 172.19.0.1 "GET /security/users/me/policies" with parameters {} and body {} done in 0.034s: 200
2022/04/20 08:00:27 INFO: wazuh 172.19.0.1 "PUT /security/user/revoke" with parameters {} and body {} done in 1.293s: 200
2022/04/20 08:00:32 INFO: unknown_user 172.19.0.1 "GET /security/actions" with parameters {} and body {} done in 0.002s: 401
2022/04/20 08:00:37 INFO: unknown_user 172.19.0.1 "GET /security/resources" with parameters {} and body {} done in 0.002s: 401
2022/04/20 08:00:39 INFO: unknown_user 172.19.0.1 "GET /security/users" with parameters {} and body {} done in 0.003s: 401
2022/04/20 08:00:52 INFO: wazuh 172.19.0.1 "GET /security/user/authenticate" with parameters {} and body {} done in 0.483s: 200
2022/04/20 08:01:04 INFO: wazuh 172.19.0.1 "DELETE /security/user/authenticate" with parameters {} and body {} done in 0.051s: 200
2022/04/20 08:01:09 INFO: unknown_user 172.19.0.1 "GET /security/users/me" with parameters {} and body {} done in 0.016s: 401
2022/04/20 08:01:12 INFO: wazuh 172.19.0.1 "POST /security/user/authenticate/run_as" with parameters {} and body {} done in 0.468s: 200
2022/04/20 08:01:19 INFO: unknown_user 172.19.0.1 "POST /security/roles" with parameters {} and body {"name": "test_role"} done in 0.004s: 401
2022/04/20 08:01:24 INFO: wazuh 172.19.0.1 "GET /security/user/authenticate" with parameters {} and body {} done in 0.515s: 200
2022/04/20 08:01:26 INFO: wazuh 172.19.0.1 "POST /security/roles" with parameters {} and body {"name": "test_role"} done in 0.049s: 200
2022/04/20 08:01:55 INFO: wazuh 172.19.0.1 "PUT /security/roles/test_role" with parameters {} and body {"name": "new_test_role"} done in 0.008s: 400
2022/04/20 08:02:04 INFO: wazuh 172.19.0.1 "PUT /security/roles/100" with parameters {} and body {"name": "new_test_role"} done in 0.033s: 200
2022/04/20 08:02:16 INFO: wazuh 172.19.0.1 "DELETE /security/roles" with parameters {"role_ids": "100"} and body {} done in 0.067s: 200
2022/04/20 08:02:29 INFO: wazuh 172.19.0.1 "GET /security/user/authenticate" with parameters {} and body {} done in 0.471s: 200
2022/04/20 08:02:29 INFO: wazuh 172.19.0.1 "GET /syscheck/000" with parameters {} and body {} done in 0.112s: 200

@davidjiglesias davidjiglesias merged commit 08cadc9 into master Apr 20, 2022
@davidjiglesias davidjiglesias deleted the feature/12144-remove-set-user-name branch April 20, 2022 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module/api type/enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consider removing the set_user_name API middleware as it is unused
4 participants