在 spring 引导 Web 应用程序中禁用 csrf 的原因是什么?
What is the reason to disable csrf in spring boot web application?
有很多教程展示了如何禁用 csrf,
csrf().disable()
(以及其他可能性,如 .properties
、.yml
等)
但无处解释他们为什么这样做?
所以我的问题是:
禁用它的现实原因是什么?
它是否提高了性能?
Spring 建议在为 浏览器客户端提供服务时使用它 ,否则可能会被禁用:
Our recommendation is to use CSRF protection for any request that could be processed by a browser by normal users. If you are only creating a service that is used by non-browser clients, you will likely want to disable CSRF protection.
我要补充一点,即使您为浏览器客户端提供服务,但它仅在内部使用,您可以 want/able 将其删除。
What is the real-life reason to disable it?
Spring 文档建议:
Our recommendation is to use CSRF protection for any request that could be processed by a browser by normal users. If you are only creating a service that is used by non-browser clients, you will likely want to disable CSRF protection.
Does it improve performance?
它应该不会影响性能。将从请求处理链中删除过滤器(或其他组件)以使该功能不可用。
What is the reason to disable csrf
in a Spring Boot application?
- 您正在使用另一种令牌机制。
- 您想简化客户端和服务器之间的交互。
是的,如果您有其他无法隐藏的身份验证机制,则可以安全地禁用它。对于内部企业应用程序,不是很关心。
我们不得不禁用它,因为它会干扰我们现有的身份验证机制。
有很多教程展示了如何禁用 csrf,
csrf().disable()
(以及其他可能性,如 .properties
、.yml
等)
但无处解释他们为什么这样做?
所以我的问题是:
禁用它的现实原因是什么?
它是否提高了性能?
Spring 建议在为 浏览器客户端提供服务时使用它 ,否则可能会被禁用:
Our recommendation is to use CSRF protection for any request that could be processed by a browser by normal users. If you are only creating a service that is used by non-browser clients, you will likely want to disable CSRF protection.
我要补充一点,即使您为浏览器客户端提供服务,但它仅在内部使用,您可以 want/able 将其删除。
What is the real-life reason to disable it?
Spring 文档建议:
Our recommendation is to use CSRF protection for any request that could be processed by a browser by normal users. If you are only creating a service that is used by non-browser clients, you will likely want to disable CSRF protection.
Does it improve performance?
它应该不会影响性能。将从请求处理链中删除过滤器(或其他组件)以使该功能不可用。
What is the reason to disable
csrf
in a Spring Boot application?
- 您正在使用另一种令牌机制。
- 您想简化客户端和服务器之间的交互。
是的,如果您有其他无法隐藏的身份验证机制,则可以安全地禁用它。对于内部企业应用程序,不是很关心。 我们不得不禁用它,因为它会干扰我们现有的身份验证机制。