I have solution with Webapplication and REST api (webapi). In REST api I have implemented Token based security between Web and service. So there is a way to implement custom security check ( for token validation, is it expired, etc) and use [Authorize] attribute? In other words there is a way to check my for my own is user authorized or not in Webapplication ? I have to write my own middleware or smth ?
1 Answer
The MVC 5 template uses the .Net Identity OWIN middleware. If you left it as the default authentication option when creating the solution it will be installed. You just need to use the Bearer Token authorisation by configuring it.
Once that's done you'll get all the handy stuff you'd get if it were a cookie. E.g the User principal is available as part of the request.
4 Comments
user3091350
I used empty project, so there is nothing inside.
John Mc
Fear not! You can install everything you need through Nuget. There's loads of info over on asp.net/identity. For the API, you can have a read of this: asp.net/web-api/overview/security/…
user3091350
It will work on DNX Core 5 ? Btw, you mentioned MVC5, but I'm using MVC6 (vNext)
John Mc
Sorry I haven't delved into the DNX Core world myself yet so can't tell you with certainty. It's still being actively developed by MS so probably