How does Angular handle XSS or CSRF?

前端 未结 3 1275
闹比i
闹比i 2020-12-08 07:45

How does Angular (2) handle XSS and CSRF. Does it even handle these attacks? If so, what do I have to do to use this protection? If not, do I have to handle all these attac

3条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-08 08:08

    Following is brief guide on how CSRF is handled in backend/server-side implementation when using SpringBoot

    The token in CSRF can be associated either with HttpSession or in a cookie

    To handle as a cookie, we may pass

    .csrfTokenRepository(new CookieCsrfTokenRepository())
    

    To handle as a HttpSession, we may pass

    .csrfTokenRepository(new HttpSessionCsrfTokenRepository())   
    

    Even we can have a custom csrf token repository by implmenting CsrfTokenRepository in case we need skip specific url and so on

    all above can be used when overriding configure method of WebSecurityConfigurerAdapter

提交回复
热议问题