I have the following setup.
2 mobile apps communicating with an asp.net web api 2
project and they use Token Authentication
. Each mobile client stores the token client side, never username and password.
I then have my web portal hosted on an asp.net mvc 5
project which uses standard cookie authentication.
Now in some cases my mobile apps needs to load webpages from the mvc 5
web portal. For example our payment gateway page. But the client needs to be authenticated in order to load this page.
At the moment when we show the user a web wrap of out web portal. It asks them to login again. This is very bad UX.
How can I authenticate the client on the MVC site, using my web api Token
I'm imagining a function like this in the MVC site:
pubic Action LogInWithToken(String token)
{
var user = GetUserFromToken(token);
var isAllowed = AuthenticateUserFromToken(user,token);
if(!isAllowed) return 401;
return CreateCookieForUser(user);
}