Everything,
I have a security server whose sole purpose is to provide media tokens from one endpoint: http://example.com/token
Request example:
POST http://example.com/token HTTP/1.1 User-Agent: Fiddler Content-Type: x-www-form-urlencoded Host: example.com Content-Length: 73 grant_type=password& username=example@example.com &password=examplePassword
Answer example:
HTTP/1.1 200 OK Cache-Control: no-cache Pragma: no-cache Content-Type: application/json;charset=UTF-8 Expires: -1 Server: Microsoft-IIS/10.0 X-Powered-By: ASP.NET Date: Tue, 16 Aug 2016 12:04:39 GMT { "access_token": "xxxx", "token_type": "bearer", "expires_in": 17999, "refresh_token": "xxxx", ".issued": "Tue, 16 Aug 2016 12:04:38 GMT", ".expires": "Tue, 16 Aug 2016 17:04:38 GMT" }
We have an angular application that uses this endpoint for authentication and does it just fine.
What we are trying to achieve without much success is to create an MVC application that uses the same server for authentication, we would like the code to sit on top of Identity 2.0, if possible.
In our AccountController ( AccountController project), we have our Login(LoginModel model) method Login(LoginModel model) , which processes the login and looks like this (the same as the sample project template):
var result = await _signInManager.PasswordSignInAsync(model.UserName, model.Password, model.RememberMe, shouldLockout: false);
We have our own implementation of IUserStore, UserManager, SignInManager.
I reviewed redefinition
public Task<SignInStatus> PasswordSignInAsync(string userName, string password, bool isPersistent, bool shouldLockout) on `SignInManager<,>` and make a web call across to the security server.
The standard implementation of PasswordSignInAsync calls UserManager.FindByNameAsync , but that would mean that I would have to set the search method on my security server to confirm that the username exists, which is really not very good.
I need to miss something, and I know that it is not so difficult, our MVC application should use cookie authentication, but also support the bear token for subsequent calls to our other resource server.
(I appreciate that I can mix technologies here, hence the question).
This also works in OWIN.