填写这份《一分钟调查》,帮我们(开发组)做得更好!去填写Home

HttpClientXsrfModule

配置 XSRF 保护,以支持外发请求。

Configures XSRF protection support for outgoing requests.

查看"说明"...

      
      class HttpClientXsrfModule {
  static disable(): ModuleWithProviders<HttpClientXsrfModule>
  static withOptions(options: { cookieName?: string; headerName?: string; } = {}): ModuleWithProviders<HttpClientXsrfModule>
}
    

说明

对于支持基于 Cookie 的 XSRF 保护系统的服务器来说,只要配置上正确的 Cookie 名和请求头的名字,就可以自动获得 XSRF 保护。

For a server that supports a cookie-based XSRF protection system, use directly to configure XSRF protection with the correct cookie and header names.

如果没有提供名字,则默认的 Cookie 名是 XSRF-TOKEN,默认的请求头名字是 X-XSRF-TOKEN

If no names are supplied, the default cookie name is XSRF-TOKEN and the default header name is X-XSRF-TOKEN.

静态方法

禁用默认的 XSRF 保护。

Disable the default XSRF protection.

static disable(): ModuleWithProviders<HttpClientXsrfModule>
      
      static disable(): ModuleWithProviders<HttpClientXsrfModule>
    
参数

没有参数。

返回值

ModuleWithProviders<HttpClientXsrfModule>

配置 XSRF 保护。

Configure XSRF protection.

static withOptions(options: { cookieName?: string; headerName?: string; } = {}): ModuleWithProviders<HttpClientXsrfModule>
      
      static withOptions(options: { cookieName?: string; headerName?: string; } = {}): ModuleWithProviders<HttpClientXsrfModule>
    
参数
options object

一个对象,可以指定 Cookie 名和/或请求头的名字。

An object that can specify either or both cookie name or header name.

  • Cookie 名默认值是 XSRF-TOKEN

    Cookie name default is XSRF-TOKEN.

  • 请求头的名字默认是 X-XSRF-TOKEN

    Header name default is X-XSRF-TOKEN.

可选. 默认值是 {}.

返回值

ModuleWithProviders<HttpClientXsrfModule>

提供商

提供商
HttpXsrfInterceptor
      
      HttpXsrfInterceptor
    
{ provide: HTTP_INTERCEPTORS, useExisting: HttpXsrfInterceptor, multi: true }
      
      { provide: HTTP_INTERCEPTORS, useExisting: HttpXsrfInterceptor, multi: true }
    
{ provide: HttpXsrfTokenExtractor, useClass: HttpXsrfCookieExtractor }
      
      { provide: HttpXsrfTokenExtractor, useClass: HttpXsrfCookieExtractor }
    
{ provide: XSRF_COOKIE_NAME, useValue: 'XSRF-TOKEN' }
      
      { provide: XSRF_COOKIE_NAME, useValue: 'XSRF-TOKEN' }
    
{ provide: XSRF_HEADER_NAME, useValue: 'X-XSRF-TOKEN' }
      
      { provide: XSRF_HEADER_NAME, useValue: 'X-XSRF-TOKEN' }