Skip to content

fix(http): enable xsrf for root-provided HttpClient#69823

Open
SkyZeroZx wants to merge 2 commits into
angular:mainfrom
SkyZeroZx:http/fix-xsrf-root-provider
Open

fix(http): enable xsrf for root-provided HttpClient#69823
SkyZeroZx wants to merge 2 commits into
angular:mainfrom
SkyZeroZx:http/fix-xsrf-root-provider

Conversation

@SkyZeroZx

Copy link
Copy Markdown
Contributor

Include the XSRF interceptor in the root token factory so the automatically provided HttpClient retains the documented default protection without requiring provideHttpClient().

Update test for the root-only provider graph and verify that withNoXsrfProtection() still disables the default header.

Include the XSRF interceptor in the root token factory so the automatically provided HttpClient retains the documented default protection without requiring provideHttpClient().

Update test for the root-only provider graph and verify that withNoXsrfProtection() still disables the default header.
@pullapprove
pullapprove Bot requested a review from crisbeto July 16, 2026 19:00
@angular-robot angular-robot Bot added the area: common/http Issues related to HTTP and HTTP Client label Jul 16, 2026
@ngbot ngbot Bot added this to the Backlog milestone Jul 16, 2026
@@ -200,7 +201,7 @@ export const HTTP_INTERCEPTORS = new InjectionToken<readonly HttpInterceptor[]>(
*/
export const HTTP_INTERCEPTOR_FNS = new InjectionToken<readonly HttpInterceptorFn[]>(
typeof ngDevMode !== 'undefined' && ngDevMode ? 'HTTP_INTERCEPTOR_FNS' : '',
{factory: () => []},
{factory: () => [xsrfInterceptorFn]},

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that when it became the default, it was omitted, or perhaps intentionally; if so, the documentation wasn't updated.

https://next.angular.dev/best-practices/security#httpclient-xsrf-csrf-security

@JeanMeche
JeanMeche removed the request for review from crisbeto July 16, 2026 23:15
@JeanMeche JeanMeche added action: merge The PR is ready for merge by the caretaker target: patch This PR is targeted for the next patch release labels Jul 16, 2026
@SkyZeroZx

Copy link
Copy Markdown
Contributor Author

Q: Since this would also affect Angular 21.2.X, should we perform a backport or can we merge it cleanly from this PR?

@angular-robot
angular-robot Bot requested a review from JeanMeche July 17, 2026 20:51
@JeanMeche

Copy link
Copy Markdown
Member

The question you're asking is, Is that a feature fix or a security fix ?

@SkyZeroZx

Copy link
Copy Markdown
Contributor Author

The question you're asking is, Is that a feature fix or a security fix ?

I would say it's both: it's a security fix in the sense that it should always have been the default according to Angular's security model, and a feature fix because this was always the default behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker area: common/http Issues related to HTTP and HTTP Client target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants