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

Logging IP addresses of login attemts #12

Open
DarkWingMcQuack opened this issue Nov 1, 2022 · 0 comments
Open

Logging IP addresses of login attemts #12

DarkWingMcQuack opened this issue Nov 1, 2022 · 0 comments

Comments

@DarkWingMcQuack
Copy link

I have a service running with tide and basic auth and in the last few days it seems that some bots are trying to bruteforce the login credentials.
To analyse and avoid this i would like to log the login attemts and ip addresses of the peer which attemted the login.
Is this possible with tide-http-auth?
I wasnt able to do this.

I tried this:

if req.ext::<User>().is_none() {
  let sender = req.peer_addr().unwrap_or("<UNKNOWN>");
  warn!("{} tried to authenticate with wrong credentials!!", sender);

  let mut response: tide::Response = "fuck off!!!".to_string().into();
  response.set_status(tide::http::StatusCode::Unauthorized);
  return Ok(response);
}

But this only triggers if there is no authentication header at all and not if the credentials are wrong.

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

No branches or pull requests

1 participant