Terminal state. Allow the original request to proceed.
| 620 | |
| 621 | // Terminal state. Allow the original request to proceed. |
| 622 | static TSEvent |
| 623 | StateAuthorized(AuthRequestContext *auth, void *) |
| 624 | { |
| 625 | const AuthOptions *options = auth->options(); |
| 626 | |
| 627 | AuthLogDebug("request authorized"); |
| 628 | |
| 629 | // Since the original request might have authentication headers, we may |
| 630 | // need to force ATS to ignore those in order to make it cacheable. |
| 631 | if (options->force) { |
| 632 | TSHttpTxnConfigIntSet(auth->txn, TS_CONFIG_HTTP_CACHE_IGNORE_AUTHENTICATION, 1); |
| 633 | } |
| 634 | |
| 635 | if (!options->forward_header_prefix.empty()) { |
| 636 | // Copy headers with configured prefix in the authentication response to the original request |
| 637 | TSMLoc field_loc; |
| 638 | TSMLoc next_field_loc; |
| 639 | TSMBuffer request_bufp; |
| 640 | TSMLoc request_hdr; |
| 641 | |
| 642 | TSReleaseAssert(TSHttpTxnClientReqGet(auth->txn, &request_bufp, &request_hdr) == TS_SUCCESS); |
| 643 | field_loc = TSMimeHdrFieldGet(auth->rheader.buffer, auth->rheader.header, 0); |
| 644 | TSReleaseAssert(field_loc != TS_NULL_MLOC); |
| 645 | |
| 646 | while (field_loc) { |
| 647 | int key_len = 0; |
| 648 | int val_len = 0; |
| 649 | |
| 650 | char *key = const_cast<char *>(TSMimeHdrFieldNameGet(auth->rheader.buffer, auth->rheader.header, field_loc, &key_len)); |
| 651 | char *val = |
| 652 | const_cast<char *>(TSMimeHdrFieldValueStringGet(auth->rheader.buffer, auth->rheader.header, field_loc, -1, &val_len)); |
| 653 | |
| 654 | if (key && val && ContainsPrefix(string_view(key, key_len), options->forward_header_prefix)) { |
| 655 | // Append the matched header key/val to the original request |
| 656 | HttpSetMimeHeader(request_bufp, request_hdr, string_view(key, key_len), string_view(val, val_len)); |
| 657 | } |
| 658 | |
| 659 | // Validate the next header field |
| 660 | next_field_loc = TSMimeHdrFieldNext(auth->rheader.buffer, auth->rheader.header, field_loc); |
| 661 | TSHandleMLocRelease(auth->rheader.buffer, auth->rheader.header, field_loc); |
| 662 | field_loc = next_field_loc; |
| 663 | } |
| 664 | } |
| 665 | |
| 666 | // Proceed with the modified request |
| 667 | TSHttpTxnReenable(auth->txn, TS_EVENT_HTTP_CONTINUE); |
| 668 | return TS_EVENT_CONTINUE; |
| 669 | } |
| 670 | |
| 671 | // Return true if the given request was tagged by a remap rule as needing |
| 672 | // authorization. |
nothing calls this directly
no test coverage detected