liveBook · Manning

Server farm

As explained in ASP.NET Core in Action, 3e

A web farm is a deployment in which multiple servers host the same web application and must share state or cryptographic keys when processing requests.

A server farm runs the same web application on multiple servers. Requests can reach any server, so shared cryptographic material becomes essential: authentication cookies created by one server must be readable by the others. section 29.2

Configure shared data-protection keys when deploying across servers:

  • Recognize the failure mode: each server uses its own key by default, so a server cannot decrypt authentication cookies issued by another server. section 29.2
  • Store keys centrally so every server can use the same cryptographic material. section 29.2
  • Choose an appropriate shared location, such as a shared folder, Redis, or Azure Blob Storage. section 29.2

Authentication across servers

A user signs in through one server and receives an authentication cookie. If a later request reaches another server, that server can authenticate the user only when both servers share data-protection keys. section 29.2

Figure 29.5 Protecting against a CSRF attack using antiforgery tokens. The browser automatically forwards the cookie token, but the malicious site can’t read it and so can’t include a token in the form. The app rejects the malicious request because the tokens don’t match.
CH29_F05_Lock3

Antiforgery tokens add another cross-server security consideration: the application must consistently protect and validate tokens when requests may reach different servers. section 29.2

How ASP.NET Core in Action, 3e covers it

How deep it goes
Explains cross-server cookie failure and central key storage, but stops short of provider-specific configuration steps.
Examples
Uses authentication cookies crossing servers and names shared folders, Redis, and Azure Blob Storage as key stores.
What it assumes
Assumes authentication cookies and data-protection keys, while explaining why separate server keys break cookie decryption.
What you can do after
Configure centralized ASP.NET Core data-protection keys so all servers can read shared authentication cookies.
How it connects
Connects server farms with authentication cookies, data protection, key storage providers, CSRF, and antiforgery tokens.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of ASP.NET Core in Action, 3e. The section links point to the parts of the book it draws on.