Class DocToolkitOptions
- Namespace
- DocToolkit.Extensions.DependencyInjection
- Assembly
- DocToolkit.Extensions.DependencyInjection.dll
Options controlling the services registered by AddDocToolkit(IServiceCollection, Action<DocToolkitOptions>?).
public sealed class DocToolkitOptions
- Inheritance
-
DocToolkitOptions
- Inherited Members
Properties
AllowRemoteImageDownload
When true, HTML-to-DOCX and HTML-to-PDF conversion download images referenced by absolute
http/https URLs, bounded by RemoteImage. This issues outbound
network requests. Because this is a process-wide setting rather than a per-call choice,
enabling it opts every conversion in the application into fetching whatever URL the markup
names - narrow that with RemoteImage if any caller converts untrusted HTML.
Default: false.
This is the only switch that decides whether anything is fetched: while it is false
nothing is, no matter what RemoteImage says.
An air-gapped environment no longer fails the conversion - a host that cannot be reached leaves that image out of the result, at a cost of up to Timeout per image.
public bool AllowRemoteImageDownload { get; set; }
Property Value
RemoteImage
Bounds applied to every image fetch, when - and only when -
AllowRemoteImageDownload is true. Every default is already the
restrictive one: loopback, private and link-local addresses are refused (including
169.254.169.254, the cloud metadata endpoint), only http and https are
spoken, redirects are not followed, and each fetch is capped at 10 seconds and 5 MB.
Configured in place rather than assigned, so the restrictive defaults cannot be replaced wholesale by an object that missed one of them:
services.AddDocToolkit(o =>
{
o.AllowRemoteImageDownload = true;
o.RemoteImage.Timeout = TimeSpan.FromSeconds(3);
o.RemoteImage.AllowedHosts.Add("cdn.example.com");
});
This is not a complete SSRF defence; see RemoteImageOptions for the DNS-rebinding window it does not close.
public RemoteImageOptions RemoteImage { get; }