-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Login workflow does not work from mvc app to identity.api #1050
Comments
Please take a look at this comment: #686 (comment) You can connect to the containerized SQL Server this way: Where:
BTW, you can also look at the logs in http://localhost:5340 Hope this helps. |
Closing this issue now, but feel free to comment. Will reopen if needed. |
Hi @mvelosop thank you for your collaboration. But my problem has nothing to do with database access. It is working fine. As I said before, I cannot access the mvc client url from within the identity.api (when i try to proceed with the login). In the comment you mentioned (#686) @eiximenis explains how mvc client tries to access the identity.api. and when I execute the command "curl http://localhost:5100" inside Identity.Api it gives me a "CONNECTION REFUSED" response. So I really appreciate if you guys could help me to make it works. maybe a docker configuration is missing or something like that... |
Hi @mvelosop could you please reopen this post? thanks |
Thanks @mvelosop. I've checked that table (ClientRedirectUris) before. My problem is when the Identity.Api Container tries to access http://localhost:5100 it gets a "connection refused" message. My firewall is disabled... |
Ok @raimundoteixeira, let's try this: The client urls for identity.api are take from the identity.api:
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_URLS=http://0.0.0.0:80
- SpaClient=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5104
- XamarinCallback=http://${ESHOP_PROD_EXTERNAL_DNS_NAME_OR_IP}:5105/xamarincallback #localhost do not work for UWP login, so we have to use "external" IP always
- ConnectionString=${ESHOP_AZURE_IDENTITY_DB:-Server=sql.data;Database=Microsoft.eShopOnContainers.Service.IdentityDb;User Id=sa;Password=Pass@word}
- MvcClient=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5100 #Local: You need to open your local dev-machine firewall at range 5100-5110.
- LocationApiClient=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5109
- MarketingApiClient=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5110
- BasketApiClient=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5103
- OrderingApiClient=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5102
- MobileShoppingAggClient=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5120
- WebShoppingAggClient=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5121
- WebhooksApiClient=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5113
- WebhooksWebClient=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5114
- UseCustomizationData=True
- ApplicationInsights__InstrumentationKey=${INSTRUMENTATION_KEY}
- OrchestratorType=${ORCHESTRATOR_TYPE}
ports:
- "5105:80" and the ESHOP_EXTERNAL_DNS_NAME_OR_IP=localhost It'd be good to check the logs, if you go to http://10.0.75.1:5340 you should be able to get something like this response from identity.api upon a successful login: Hope this helps. |
Hi @mvelosop! thanks I'm gonna try this right now! Thanks man. |
This is the result of env in the identity.api container: And this is the result for If you are working within a corporate VPN you might need to run this power shell command (from an admin prompt) every time you power up your machine, to allow access from DockerNAT network: Get-NetConnectionProfile | Where-Object { $_.InterfaceAlias -match "(DockerNAT)" } | ForEach-Object { Set-NetConnectionProfile -InterfaceIndex $_.InterfaceIndex -NetworkCategory Private } Hope this gets us closer to the solution 😅 |
Yes it is closer! You clarified many things now. But the identity.Api container doesn't access http://localhost:5100 as it should. As you shown in the earlier post (about the log service on port 5340). the Identity.Api checks the returnUrl (callbak from mvc client). but im my case, it gets a "connection refused" (when it tries to check if http://localhost:5100/signin-oidc exists) and doesn't shows the login page. All the env vars are correct like yours. I can access the client mvc on browser normally. the communication between apis works fine (the communication into docker's network). the only thing that doesn't go is that process when the identity container tries to check something in the host's network. So... I realized i really have a network issue. something missing in docker setup or whatever... I will look for more details in that network configuration related with my win10pro, firewall, etc... I only installed docker desktop for windows (latest). thanks man! could you please close this thread. Just tell me if you typed "curl" inside the container or in your host's powershell. I really appreciate your help |
I ran curl from my computer's command prompt, not from the container's. BTW, that's the way it should be, because that's a "redirect" address. That means it's not really a callback from identity.api to the webmvc microservice. Let's go through the login process as seen with Fiddler (and use this to document the process later in the wiki 😉):
You'd see this if JS were disabled:
So it's a pretty complex flow, but, as you can see, the sign in is done from the browser, in steps 5-6. Just to be 100% sure, I added a SerilogLoggingMiddleware to the request pipeline, and the events correlate perfectly with the above: Hope this helps. |
Thanks @mvelosop ! I'm gonna check this out |
@mvelosop Thanks for the detailed fiddler workflow, its making more sense now. But i seem to have hit a snag, on visual studio with debugging turned on, I set a break point on the Account/Signin controller, for some strange reasons its not being hit. a look at the ClientRedirectUris table shows the entry is correct. any help please? |
i'm experiencing some network weird issues... when I try to make a login, through the docker network 10.0.75.1:5105, the initial process seems to works fine (it doesnt work if forced by "localhost" or the container's name). checking the log, it finds the client id but an exception occurs when it tries to check the returnUrl. An exception is thrown by "AuthorizeRequestValidator".
LOG --------
IdentityServer4.EntityFramework.Stores.ClientStore:Debug: mvc found in database: True
�[41m�[30mfail�[39m�[22m�[49m: IdentityServer4.Validation.AuthorizeRequestValidator[0]
Invalid redirect_uri: http://localhost:5100/signin-oidc
END LOG -----------
It seems like when running into local dev-machine, the MVC app with address localhost:5100 can access the Identity.api by 10.0.75.1:5105 but when it try to proceed checking within AuthorizeRequestValidator it cannot reach the returnURL http://localhost:5100/signin-oidc produced during this process... seems like the container network cannot access this address
I already freed all ports in firewall as well as disabled the firewall...
The text was updated successfully, but these errors were encountered: