Hey!
First of all GREAT JOB. You can learn a lot from this fabulous project.
Back to question. I am playing around with the solution and there is something which I cannot understand.
How WebMVC project calls methods from Identity.API.Controllers.AccountController.cs (I guess that there is some configuration somewhere.)?
Here is an example:
How from here (_LoginPartial.cshtml):
<section class="col-lg-4 col-md-5 col-xs-12">
<div class="esh-identity">
<section class="esh-identity-section">
<div class="esh-identity-item">
<a asp-area="" asp-controller="Account" asp-action="SignIn" class="esh-identity-name esh-identity-name--upper">
Login
</a>
</div>
</section>
</div>
</section>
We automaticaly have been redirected to (Identity.API.Controllers.AccountController):
[HttpGet]
public async Task<IActionResult> Login(string returnUrl)
{
var context = await _interaction.GetAuthorizationContextAsync(returnUrl);
if (context?.IdP != null)
{
throw new NotImplementedException("External login is not implemented!");
}
var vm = await BuildLoginViewModelAsync(returnUrl, context);
ViewData["ReturnUrl"] = returnUrl;
return View(vm);
}
For the rest of the services its clear (we do a simple HTTP call and Ocelot redirect us to corresponding API point).
Cheers!
Hi @andriyankrastevv, that's an interesting question 馃憤
This is what happens, from a very high level:
When the MVC app gets a request that requires authentication/authorization and the user hasn't logged in, it's redirected to the Identity.API microservice, for the user to log in.
After successfully logging in, the Identity.API microservice sends a token to the MVC app, that specifies what the user is authorized for. That makes the user logged in and authorized into the MVC app.
When the token expires the user is required to log in again.
You can get a nice detailed getting started guides here: https://identityserver4.readthedocs.io/en/latest/quickstarts/0_overview.html
Hope this helps.
Hi @mvelosop!
When the MVC app gets a request that requires authentication/authorization and the user hasn't logged in, it's redirected to the Identity.API microservice, for the user to log in.
I was looking for that relation between MVC app and Identity.API. I was wondering how MVC knows where Identity.API is it. As I suspect there is a configuration. When I checked the started guide I understood that that relation is defined right here:
Microsoft.eShopOnContainers.WebMVC.Startup.cs
options.Authority = identityUrl.ToString();
Thank you so much !!!
Cheers!
Great to know I could help.
I'm closing the issue now, but feel free to comment, will reopen if needed.
Most helpful comment
Hi @mvelosop!
I was looking for that relation between MVC app and Identity.API. I was wondering how MVC knows where Identity.API is it. As I suspect there is a configuration. When I checked the started guide I understood that that relation is defined right here:
Microsoft.eShopOnContainers.WebMVC.Startup.cs
options.Authority = identityUrl.ToString();Thank you so much !!!
Cheers!