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

feat: Log invalid credentials on info level instead of error/warning #517

Merged
merged 2 commits into from
Sep 17, 2020

Conversation

catper
Copy link
Contributor

@catper catper commented Sep 15, 2020

Related issue

#505

Proposed changes

Invalid credentials or a malformed request is really the client's responsibility and should therefore not be considered an error.

Checklist

  • I have read the contributing guidelines.
  • I have read the security policy.
  • I confirm that this pull request does not address a security
    vulnerability. If this pull request addresses a security. vulnerability, I
    confirm that I got green light (please contact
    [email protected]) from the maintainers to push
    the changes.
  • I have added tests that prove my fix is effective or that my feature
    works.
  • I have added or changed the documentation.

Further comments

In the best of worlds I would also like to not have an error logged in the scenario where e.g. the token was expired:

level=error msg=An error occurred while handling a request code=401 debug= details=map[] error=The request could not be authorized reason= request-id=194689ec322a9ad1a71ae5 ...

but that seems to be rather a large change. Is there any easy way to accomplish this?

@catper catper changed the title Log invalid credentials on info level instead of error/warning feat: Log invalid credentials on info level instead of error/warning Sep 15, 2020
Warn("No authentication handler was responsible for handling the authentication request")
// found will only be true if an authenticator was found AND authorisation was granted so check
// that this wasn't just a problem with the request
if err.Error() != helper.ErrUnauthorized.ErrorField {
Copy link
Member

Choose a reason for hiding this comment

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

This is always false because we set the error to err := errors.WithStack(helper.ErrUnauthorized) right before - so this can be removed :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i see your point :), guess i need to think about this a bit more.

the problem is, if this if statement is removed, then invalid credentials or an expired token will result in level=warning msg=No authentication handler was responsible for handling the authentication request getting logged, which is inaccurate and misleading.

Copy link
Member

@aeneasr aeneasr left a comment

Choose a reason for hiding this comment

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

Awesome 🎉

Thank you for your contribution!

@aeneasr aeneasr merged commit a372b5f into ory:master Sep 17, 2020
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