Skip to content

Added localhost bypass option#23

Open
ngates87 wants to merge 4 commits intoatomx:masterfrom
daktronics:localhost-bypass-opt
Open

Added localhost bypass option#23
ngates87 wants to merge 4 commits intoatomx:masterfrom
daktronics:localhost-bypass-opt

Conversation

@ngates87
Copy link
Copy Markdown

@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);
Copy link
Copy Markdown

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;
}
}
Copy link
Copy Markdown

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