Skip to content

Added localhost bypass option #23

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

ngates87
Copy link

@ngates87 ngates87 commented Mar 4, 2021

  • Added option to allow localhost traffic through unchallenged.
  • cleaned up formatting

Comment on lines +1545 to +1548
char* localhost = "localhost";
int localhostLen = strlen(localhost);
char* loopback = "127.0.0.1";
int loopbackLen = strlen(loopback);

Choose a reason for hiding this comment

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

These don't change so you can make them static.

Comment on lines +146 to +153
const int isLocalHost = ngx_http_auth_digest_is_loopback(&(r->headers_in.server)) == 0;

if (isLocalHost) {
const int isLocalHostBypass = ngx_strcmp(alcf->allow_localhost.data, "on") == 0;
if (isLocalHostBypass) {
return NGX_DECLINED;
}
}

Choose a reason for hiding this comment

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

The isLocalHostBypass check is much faster and will most of the time fail since the default is off.

  1. Can we convert alcf->allow_localhost to an int (different variable) in ngx_http_auth_digest_merge_loc_conf so we just have to compare 1 int instead of a string each request?
  2. Its better to do this test first before we do the more expensive isLocalHost test.

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