Skip to content

Instantly share code, notes, and snippets.

@vtml
Created April 11, 2023 05:43
Show Gist options
  • Save vtml/503d4b9a96d674e90e165b0147d8cb53 to your computer and use it in GitHub Desktop.
Save vtml/503d4b9a96d674e90e165b0147d8cb53 to your computer and use it in GitHub Desktop.
Adding a hard coded authentication header to the Coveo HTML Index Crawler
using Sitecore.Configuration;
using Coveo.SearchProvider.Processors.FetchPageContent.PreAuthenticators;
namespace CPA.Foundation.Coveo.Processors.preAuthentication
{
/// <summary>
/// Adds a custom authentication header so that Coveo indexer can bypass login page for authenticated content
/// https://docs.coveo.com/en/2326/coveo-for-sitecore-v5/index-page-content-with-the-fetchpagecontentprocessor#the-preauthentication-section
/// </summary>
public class PreAuthenticationCustomHeader : IFetchPageContentPreAuthenticatorProcessor
{
public void Process(FetchPageContentPreAuthenticatorArgs args)
{
var headerName = Settings.GetSetting(Constants.AuthenticationHeaderName);
var headerValue = Settings.GetSetting(Constants.AuthenticationHeaderValue);
args?.Request?.Headers?.Add(headerName, headerValue);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment