Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions doc/admin-guide/plugins/authproxy.en.rst
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ Plugin Options
that by setting the :ts:cv:`proxy.config.http.cache.ignore_authentication`
option on the request.

--cache-internal
The option will allow the Traffic Server to cache internal
requests. By default, internally generated requests are
not cached as the agent needs to take the authorization decisions.

Examples
--------

Expand Down
17 changes: 15 additions & 2 deletions plugins/authproxy/authproxy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ struct AuthOptions {
int hostport = -1;
AuthRequestTransform transform = nullptr;
bool force = false;
bool cache_internal_requests = false;

AuthOptions() = default;
~AuthOptions() = default;
Expand Down Expand Up @@ -624,6 +625,14 @@ AuthRequestIsTagged(TSHttpTxn txn)
return AuthTaggedRequestArg != -1 && TSUserArgGet(txn, AuthTaggedRequestArg) != nullptr;
}

// Return true if the internal requests can be cached.
static bool
CacheInternalRequests(TSHttpTxn txn)
{
AuthOptions *opt = static_cast<AuthOptions *>(TSUserArgGet(txn, AuthTaggedRequestArg));
return opt ? opt->cache_internal_requests : false;
}

static int
AuthProxyGlobalHook(TSCont /* cont ATS_UNUSED */, TSEvent event, void *edata)
{
Expand All @@ -642,8 +651,8 @@ AuthProxyGlobalHook(TSCont /* cont ATS_UNUSED */, TSEvent event, void *edata)
// it as a global plugin (not highly recommended). Also remember that
// the HEAD auth request might trip a different remap rule, particularly
// if you do not have pristine host-headers enabled.
TSHttpTxnConfigIntSet(txn, TS_CONFIG_HTTP_CACHE_HTTP, 0);

if (!CacheInternalRequests(txn))
TSHttpTxnConfigIntSet(txn, TS_CONFIG_HTTP_CACHE_HTTP, 0);
AuthLogDebug("re-enabling internal transaction");
TSHttpTxnReenable(txn, TS_EVENT_HTTP_CONTINUE);
return TS_EVENT_NONE;
Expand Down Expand Up @@ -674,6 +683,7 @@ AuthParseOptions(int argc, const char **argv)
{const_cast<char *>("auth-port"), required_argument, nullptr, 'p'},
{const_cast<char *>("auth-transform"), required_argument, nullptr, 't'},
{const_cast<char *>("force-cacheability"), no_argument, nullptr, 'c'},
{const_cast<char *>("cache-internal"), no_argument, nullptr, 'i'},
{nullptr, 0, nullptr, 0},
};

Expand All @@ -695,6 +705,9 @@ AuthParseOptions(int argc, const char **argv)
case 'c':
options->force = true;
break;
case 'i':
options->cache_internal_requests = true;
break;
case 't':
if (strcasecmp(optarg, "redirect") == 0) {
options->transform = AuthWriteRedirectedRequest;
Expand Down