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

Show authenticated user in API logs #67

Merged
merged 5 commits into from
Jul 13, 2018
Merged

Show authenticated user in API logs #67

merged 5 commits into from
Jul 13, 2018

Conversation

mgmacias95
Copy link
Contributor

Hello,

This PR implements a new option in the API logs: show the user who made the request. For example, the following request:

# curl -u marta:bar "localhost:55000?pretty"
{
   "error": 0,
   "data": {
      "msg": "Welcome to Wazuh HIDS API",
      "api_version": "v3.3.0",
      "hostname": "node01",
      "timestamp": "Fri Feb 16 2018 19:11:47 GMT+0100 (CET)"
   }
}

will produce the following log line:

WazuhAPI 2018-02-16 19:11:47 marta: [::1] GET /?pretty - 200 - error: '0'.

If a wrong user is used, the log will show the last correct user:

# curl -u pepe:bar "localhost:55000?pretty"
401 Unauthorized
# tail -n1 /var/ossec/logs/api.log st:55000?pretty"
WazuhAPI 2018-02-16 19:15:15 marta: [::1] User: "pepe" - Authentication failed.

Best regards,
Marta

mgmacias95 pushed a commit that referenced this pull request Feb 16, 2018
@jesuslinares
Copy link
Contributor

Fix this:

WazuhAPI 2018-02-16 19:15:15 marta: [::1] User: "pepe" - Authentication failed.

@mgmacias95 mgmacias95 changed the base branch from master to 3.5 July 13, 2018 00:19
@mgmacias95
Copy link
Contributor Author

@jesuslinares Fixed in commit e9e4dcc:

WazuhAPI 2018-07-13 01:50:32 pepe: [::1] User: "pepe" - Authentication failed.

@jesuslinares jesuslinares merged commit eee06cf into 3.5 Jul 13, 2018
@jesuslinares jesuslinares deleted the show-user-api-logs branch July 13, 2018 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants