Skip to content

rerun the location regex after decryption #45

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 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions ngx_http_secure_token_encrypt_uri.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ ngx_int_t
ngx_http_secure_token_decrypt_uri(ngx_http_request_t *r)
{
ngx_http_secure_token_loc_conf_t *conf;
ngx_http_core_loc_conf_t *clcf;
ngx_str_t encrypt_uri_part;
ngx_str_t base64_decoded;
ngx_str_t decrypted;
Expand Down Expand Up @@ -298,6 +299,20 @@ ngx_http_secure_token_decrypt_uri(ngx_http_request_t *r)
r->uri = new_uri;
r->unparsed_uri = new_uri; // TODO: fix this

clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);

if (clcf->regex != NULL)
{
// execute the regex again, so that capture variables will contain the decrypted content
rc = ngx_http_regex_exec(r, clcf->regex, &r->uri);
if (rc != NGX_OK)
{
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
"ngx_http_secure_token_decrypt_uri: ngx_http_regex_exec failed");
return NGX_ERROR;
}
}

// free temporary buffer
ngx_pfree(r->pool, decrypted.data);

Expand Down