I am working on Angular 6 application with SSO login and .net core web API. The code hits the back end on /token url first time which is a post operation. How do I do the anti forgery in this scenario. Please explain the flow of token transfer
相关问题
- Angular RxJS mergeMap types
- npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fs
- How to update placeholder text in ng2-smart-table?
- How to instantiate Http service in main.ts manuall
- Angular: ngc or tsc?
相关文章
- angular脚手架在ie9+下兼容问题
- angular 前端项目 build 报错 "Cannot find module 'le
- Angular Material Stepper causes mat-formfield to v
- After upgrade to Angular 9 cannot find variable in
- is there any difference between import { Observabl
- Suppress “Circular dependency detected” suppress w
- How can you get current positional information abo
- Angular material table not showing data
I'm not sure if that's what you're looking for, but I'll try to explain how I achieved it in a similar case.
First of all Angular has built in helpers for XSRF handling:
So the hardest part is to create custom XSRF middleware at api level.
I did it some time ago for one of my apps which was built with Angular 6 on the front and ASP.NET Core WebApi on the back-end.
Article which help me with it:
Your middleware could look like this:
Then as per mentioned article you have to add it to services in ConfigureServices method of Startup class:
And use it in Configure method:
And of course to make use of it you have to decorate your api methods with [ValidateAntiForgeryToken] attribute.
Then in your Angular app you could create HttpInterceptor to send token only when it's needed.