Table of Contents

Class BrowserOriginPolicy

Namespace
MailFathom.Infrastructure.Security.Transport
Assembly
MailFathom.Infrastructure.dll

Which browser origins a transport surface answers.

public sealed class BrowserOriginPolicy
Inheritance
BrowserOriginPolicy
Inherited Members

Remarks

Two surfaces configure one of these and each uses it for as much of the question as it asks. Both compose the CORS response headers from it, which is what tells a browser it may read an answer. The MCP surface also validates the Origin header of the request itself, because the Streamable HTTP transport requires a server to: a page the user never visited can otherwise make a browser send authenticated requests to an address it resolved back to the operator's own host. The two uses are deliberately separate — CORS tells a browser what it may read, whereas validation decides whether the request is served at all.

It is not authentication and must never be mistaken for it. A non-browser client sends no Origin at all and is served exactly as before, and any client that chooses its own headers can send whichever origin it likes. The value of the check is confined to the one attacker it is aimed at: a browser, which sets the header itself and does not let a page forge it.

Properties

AllowedOrigins

Gets the origins this policy serves, in their normalized form, empty when every origin is served.

AllowingAnyOrigin

Gets the policy that serves every origin, which is what a deployment configuring none receives.

AllowsAnyOrigin

Gets whether every origin is served.

ServingNoBrowserOrigin

Gets the policy that serves no browser at all, which a deployment states by configuring an empty origin list.

Methods

Permits(string?)

Gets whether a request carrying a given Origin is served.

Restricting(IEnumerable<string>)

Creates a policy that serves an exact set of origins.

TryNormalize(string?, out string)

Normalizes a configured origin into the form a browser sends.