dahlsailrunner / docker-fundamentals

49 stars 67 forks source link

ran with multiple project on startup and there seems to be some error with api and core #5

Closed kri-kan closed 3 years ago

kri-kan commented 3 years ago

{"Id":"ad0283ce-f362-424c-9b6d-1ab80144054b","Status":500,"Code":null,"Links":null,"Title":"Some kind of error occurred in the API. Please use the id and contact our support team if the problem persists.","Detail":null} image image

dahlsailrunner commented 3 years ago

Not sure what you're referring to -- have you checked logs? And this project / repo is actually the finished (end) result of the Pluralsight course "Fundamentals of Docker and Kubernetes for .NET Developers" -- so docker compose is the "right way" to run it. Part of the point of that course is that tools like Docker Compose make it much easier to run complex solutions that depend on databases / etc. This repo is meant to be used as an educational / learning / example -- is there something that you are trying to do? If you want to see it in action, I recommend using the docker compose version.

kri-kan commented 3 years ago

Yes I was following this course : Fundamentals of Docker and Kubernetes for .NET Developers. In the video you were able set 3 projects as startup and establish the interaction. But the api project is failing for me in local instead. Also there I found that there is no SQL script for GlobomanticsIdSrv DB and user creation, is that expected?

dahlsailrunner commented 3 years ago

Regarding the lack of SQL Script for GlobomanticsIdSrv, this is correct. It's controlled by Entity Framework migrations that get applied during startup of that project.

Regarding the API, if you're trying to run that on its own, the Program.cs file defines logging to the Console and a Seq container. Have you looked at the console to see if there are any clues there about the failures you're seeing? The startup class also defines JWT bearer authentication against the identity server, which won't work properly if you don't have that running against a specific url. You could comment out those blocks of code if you want to bypass that and just see it running.

kri-kan commented 3 years ago

all the 3 services started up. I took the code from the course materials. The sign in button has a URL /login which matches to error url in identityserver project. Does this error make any sense? image

dahlsailrunner commented 3 years ago

It's almost certainly an "invalid redirect uri". if you can review the logs from the identity server it should tell you what's amiss. look in the InitialConfiguration for the setting(s) that you may need to update.

kri-kan commented 3 years ago

Can you point me to the version/branch of code that works like it did in the video. I mean just the DB setup, F5 and Boom!! I'm hesitant to go for next video lessons, cause I'm worried what challenges I would have to face next.

dahlsailrunner commented 3 years ago

what part of the course are you in right now?


From: kri-kan @.> Sent: Friday, May 28, 2021 11:23 AM To: dahlsailrunner/docker-fundamentals @.> Cc: Erik Dahl @.>; Comment @.> Subject: Re: [dahlsailrunner/docker-fundamentals] ran with multiple project on startup and there seems to be some error with api and core (#5)

Can you point me to the version/branch of code that works like it did in the video. I mean just the DB setup, F5 and Boom!! I'm hesitant to go for next video lessons, cause I'm worried what challenges I would have to face next.

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fdahlsailrunner%2Fdocker-fundamentals%2Fissues%2F5%23issuecomment-850530468&data=04%7C01%7C%7Ca81d5123fa8d4fad47fb08d921f4e475%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637578157944054928%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=sN3tjLFntloTWJTYhNEiju3M3J%2FvxqJubVHuUO3%2B9iI%3D&reserved=0, or unsubscribehttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FACAAJ22ZOTZ3ZSDFHQQGGDTTP67PDANCNFSM45L4BYLQ&data=04%7C01%7C%7Ca81d5123fa8d4fad47fb08d921f4e475%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637578157944064924%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=XQ7EleqysTXUA7vDY7mjsdvOkTX%2FAcgwbiGwOq9VfP0%3D&reserved=0.

kri-kan commented 3 years ago

2nd section.

dahlsailrunner commented 3 years ago

I just downloaded the exercise files, extracted them, and then opened 02/demos/m1/docker-k8s-fundamentals/Globomantics.sln in Visual Studio, set all three projects as "Start with Debugging" in the solution, and the login page on identity server came up fine from the Globomantics UI project. Did you do something differently?

kri-kan commented 3 years ago

Jus re-did the steps and seeing same error. [attaching 4min vide on the steps (screen recording)]

https://user-images.githubusercontent.com/30158069/120019884-9bbb1d00-c006-11eb-8b29-eff35c67427e.mp4

Also here is the log from identity server - output console : [22:28:43 ERR] Invalid redirect_uri: https://localhost:44320/signin-oidc {"ClientId": "globo-core", "ClientName": "Globomantics Core UI (Code with PKCE)", "RedirectUri": null, "AllowedRedirectUris": ["https://www-local.globomantics.com:44395/signin-oidc"], "SubjectId": "anonymous", "ResponseType": null, "ResponseMode": null, "GrantType": null, "RequestedScopes": "", "State": null, "UiLocales": null, "Nonce": null, "AuthenticationContextReferenceClasses": null, "DisplayMode": null, "PromptMode": "", "MaxAge": null, "LoginHint": null, "SessionId": null, "Raw": {"client_id": "globo-core", "redirect_uri": "https://localhost:44320/signin-oidc", "response_type": "code", "scope": "openid profile glob_profile glob_api offline_access", "code_challenge": "pIttbQvl0T1xewwAwqa6K155DzuhrcG4OOYM-hWZSCM", "code_challenge_method": "S256", "response_mode": "form_post", "nonce": "637578179228776571.YzUzZDVlMDEtY2I4Ni00YjI1LThkZTQtODI5MmIyMThlNDIwYjI2ZjkxYWItNTUwYy00MzM2LTgwN2YtOWY1NDI1YzkzODhl", "state": "CfDJ8GWq8ToBewtKid0u8bk-Fant7sZtMvfqvcZDKStoWvWTBfJMD46vopmif3Bt1ccf9PbYSZh1ZUJDzuvMYRSEptuQV-cBG4KcOXV0rkLLPtfrzIobxidzjZ2MRNyJngBpabDvdKyr1hRM0qhPmtxkk88P2akwyqfnpuXZGq5E9b0U0EvMn2RnIx_XuRINsctQhPaOxqPY-kySujcvY2DvoHdzVPB-2beAbnsSK2bFSeriXv4HpWaLEWJ_whxPSO1uDNPAoNpDABfjJtRJwrOnJthk0R5ZALyMwI26SJVrDycC8g7nvY1guUb_cSzCqlvnAWW6EQ-OYY1OpoXetJ63qbzcMm7fgWASje-0VWX5ww3U1872vxjfj-R1DKE2dDXw", "x-client-SKU": "ID_NETSTANDARD2_0", "x-client-ver": "6.8.0.0"}, "$type": "AuthorizeRequestValidationLog"} [22:28:43 ERR] Request validation failed [22:28:43 INF] {"ClientId": "globo-core", "ClientName": "Globomantics Core UI (Code with PKCE)", "RedirectUri": null, "AllowedRedirectUris": ["https://www-local.globomantics.com:44395/signin-oidc"], "SubjectId": "anonymous", "ResponseType": null, "ResponseMode": null, "GrantType": null, "RequestedScopes": "", "State": null, "UiLocales": null, "Nonce": null, "AuthenticationContextReferenceClasses": null, "DisplayMode": null, "PromptMode": "", "MaxAge": null, "LoginHint": null, "SessionId": null, "Raw": {"client_id": "globo-core", "redirect_uri": "https://localhost:44320/signin-oidc", "response_type": "code", "scope": "openid profile glob_profile glob_api offline_access", "code_challenge": "pIttbQvl0T1xewwAwqa6K155DzuhrcG4OOYM-hWZSCM", "code_challenge_method": "S256", "response_mode": "form_post", "nonce": "637578179228776571.YzUzZDVlMDEtY2I4Ni00YjI1LThkZTQtODI5MmIyMThlNDIwYjI2ZjkxYWItNTUwYy00MzM2LTgwN2YtOWY1NDI1YzkzODhl", "state": "CfDJ8GWq8ToBewtKid0u8bk-Fant7sZtMvfqvcZDKStoWvWTBfJMD46vopmif3Bt1ccf9PbYSZh1ZUJDzuvMYRSEptuQV-cBG4KcOXV0rkLLPtfrzIobxidzjZ2MRNyJngBpabDvdKyr1hRM0qhPmtxkk88P2akwyqfnpuXZGq5E9b0U0EvMn2RnIx_XuRINsctQhPaOxqPY-kySujcvY2DvoHdzVPB-2beAbnsSK2bFSeriXv4HpWaLEWJ_whxPSO1uDNPAoNpDABfjJtRJwrOnJthk0R5ZALyMwI26SJVrDycC8g7nvY1guUb_cSzCqlvnAWW6EQ-OYY1OpoXetJ63qbzcMm7fgWASje-0VWX5ww3U1872vxjfj-R1DKE2dDXw", "x-client-SKU": "ID_NETSTANDARD2_0", "x-client-ver": "6.8.0.0"}, "$type": "AuthorizeRequestValidationLog"} [22:28:43 INF] {"ClientId": "globo-core", "ClientName": "Globomantics Core UI (Code with PKCE)", "RedirectUri": null, "Endpoint": "Authorize", "SubjectId": null, "Scopes": "", "GrantType": null, "Error": "invalid_request", "ErrorDescription": "Invalid redirect_uri", "Category": "Token", "Name": "Token Issued Failure", "EventType": "Failure", "Id": 2001, "Message": null, "ActivityId": "8000001b-0002-fe00-b63f-84710c7967bb", "TimeStamp": "2021-05-28T16:58:43.0000000Z", "ProcessId": 2864, "LocalIpAddress": "::1:44377", "RemoteIpAddress": "::1", "$type": "TokenIssuedFailureEvent"} [22:28:43 INF] HTTP GET /connect/authorize?client_id=globo-core&redirect_uri=https%3A%2F%2Flocalhost%3A44320%2Fsignin-oidc&response_type=code&scope=openid%20profile%20glob_profile%20glob_api%20offline_access&code_challenge=pIttbQvl0T1xewwAwqa6K155DzuhrcG4OOYM-hWZSCM&code_challenge_method=S256&response_mode=form_post&nonce=637578179228776571.YzUzZDVlMDEtY2I4Ni00YjI1LThkZTQtODI5MmIyMThlNDIwYjI2ZjkxYWItNTUwYy00MzM2LTgwN2YtOWY1NDI1YzkzODhl&state=CfDJ8GWq8ToBewtKid0u8bk-Fant7sZtMvfqvcZDKStoWvWTBfJMD46vopmif3Bt1ccf9PbYSZh1ZUJDzuvMYRSEptuQV-cBG4KcOXV0rkLLPtfrzIobxidzjZ2MRNyJngBpabDvdKyr1hRM0qhPmtxkk88P2akwyqfnpuXZGq5E9b0U0EvMn2RnIx_XuRINsctQhPaOxqPY-kySujcvY2DvoHdzVPB-2beAbnsSK2bFSeriXv4HpWaLEWJ_whxPSO1uDNPAoNpDABfjJtRJwrOnJthk0R5ZALyMwI26SJVrDycC8g7nvY1guUb_cSzCqlvnAWW6EQ-OYY1OpoXetJ63qbzcMm7fgWASje-0VWX5ww3U1872vxjfj-R1DKE2dDXw&x-client-SKU=ID_NETSTANDARD2_0&x-client-ver=6.8.0.0 responded 302 in 901.4079 ms [22:28:43 INF] Request finished HTTP/2 GET https://localhost:44377/connect/authorize?client_id=globo-core&redirect_uri=https%3A%2F%2Flocalhost%3A44320%2Fsignin-oidc&response_type=code&scope=openid%20profile%20glob_profile%20glob_api%20offline_access&code_challenge=pIttbQvl0T1xewwAwqa6K155DzuhrcG4OOYM-hWZSCM&code_challenge_method=S256&response_mode=form_post&nonce=637578179228776571.YzUzZDVlMDEtY2I4Ni00YjI1LThkZTQtODI5MmIyMThlNDIwYjI2ZjkxYWItNTUwYy00MzM2LTgwN2YtOWY1NDI1YzkzODhl&state=CfDJ8GWq8ToBewtKid0u8bk-Fant7sZtMvfqvcZDKStoWvWTBfJMD46vopmif3Bt1ccf9PbYSZh1ZUJDzuvMYRSEptuQV-cBG4KcOXV0rkLLPtfrzIobxidzjZ2MRNyJngBpabDvdKyr1hRM0qhPmtxkk88P2akwyqfnpuXZGq5E9b0U0EvMn2RnIx_XuRINsctQhPaOxqPY-kySujcvY2DvoHdzVPB-2beAbnsSK2bFSeriXv4HpWaLEWJ_whxPSO1uDNPAoNpDABfjJtRJwrOnJthk0R5ZALyMwI26SJVrDycC8g7nvY1guUb_cSzCqlvnAWW6EQ-OYY1OpoXetJ63qbzcMm7fgWASje-0VWX5ww3U1872vxjfj-R1DKE2dDXw&x-client-SKU=ID_NETSTANDARD2_0&x-client-ver=6.8.0.0 - - - 302 - - 902.9268ms [22:28:43 INF] Request starting HTTP/2 GET https://localhost:44377/home/error?errorId=CfDJ8GWq8ToBewtKid0u8bk-FamloHCQtoYeJQiiLzENAZICqdDEYUTyoyv8Wu5QxBxogH4X5sO31zqSwuKa8PkJ-TiJoXbOJwk7Ff5N-H_x6mS0PEx5v3zyBjJARgemGT9slqCRJGqZHSLLsjgjdopVoDVo85dJFHqgepu1li4zQ08VkYBlfdPf2slv3j_bBOKQ-q1kWtjrFUUPpJYcVXYlt8M_K3_oN0WcmCeTFiD6VyoePjHguZr0meFedzoXjUpNi3Er7jTSJUukWJMgTSINuT1KAiwfq18gN3_XSHh42s2fGMLdXf4xTR8MCfvYFuUGfa2j-gea0KK0qxTZ1FkT3YJt0LrnXmL8LixAonxA4WJs - - [22:28:43 INF] Executing endpoint 'IdentityServerHost.Quickstart.UI.HomeController.Error (Globomantics.IdentityServer)' [22:28:43 INF] Route matched with {action = "Error", controller = "Home", page = "", area = ""}. Executing controller action with signature System.Threading.Tasks.Task`1[Microsoft.AspNetCore.Mvc.IActionResult] Error(System.String) on controller IdentityServerHost.Quickstart.UI.HomeController (Globomantics.IdentityServer). [22:28:43 INF] Executing ViewResult, running view Error. [22:28:44 INF] Executed ViewResult - view Error executed in 103.8593ms. [22:28:44 INF] Executed action IdentityServerHost.Quickstart.UI.HomeController.Error (Globomantics.IdentityServer) in 162.1513ms [22:28:44 INF] Executed endpoint 'IdentityServerHost.Quickstart.UI.HomeController.Error (Globomantics.IdentityServer)' [22:28:44 INF] HTTP GET /home/error?errorId=CfDJ8GWq8ToBewtKid0u8bk-FamloHCQtoYeJQiiLzENAZICqdDEYUTyoyv8Wu5QxBxogH4X5sO31zqSwuKa8PkJ-TiJoXbOJwk7Ff5N-H_x6mS0PEx5v3zyBjJARgemGT9slqCRJGqZHSLLsjgjdopVoDVo85dJFHqgepu1li4zQ08VkYBlfdPf2slv3j_bBOKQ-q1kWtjrFUUPpJYcVXYlt8M_K3_oN0WcmCeTFiD6VyoePjHguZr0meFedzoXjUpNi3Er7jTSJUukWJMgTSINuT1KAiwfq18gN3_XSHh42s2fGMLdXf4xTR8MCfvYFuUGfa2j-gea0KK0qxTZ1FkT3YJt0LrnXmL8LixAonxA4WJs responded 200 in 232.8247 ms [22:28:44 INF] Request finished HTTP/2 GET https://localhost:44377/home/error?errorId=CfDJ8GWq8ToBewtKid0u8bk-FamloHCQtoYeJQiiLzENAZICqdDEYUTyoyv8Wu5QxBxogH4X5sO31zqSwuKa8PkJ-TiJoXbOJwk7Ff5N-H_x6mS0PEx5v3zyBjJARgemGT9slqCRJGqZHSLLsjgjdopVoDVo85dJFHqgepu1li4zQ08VkYBlfdPf2slv3j_bBOKQ-q1kWtjrFUUPpJYcVXYlt8M_K3_oN0WcmCeTFiD6VyoePjHguZr0meFedzoXjUpNi3Er7jTSJUukWJMgTSINuT1KAiwfq18gN3_XSHh42s2fGMLdXf4xTR8MCfvYFuUGfa2j-gea0KK0qxTZ1FkT3YJt0LrnXmL8LixAonxA4WJs - - - 200 - text/html;+charset=utf-8 237.3391ms [22:28:44 INF] Request starting HTTP/2 GET https://localhost:44377/icon.png - - [22:28:44 INF] Request starting HTTP/2 GET https://localhost:44377/lib/jquery/dist/jquery.slim.min.js - - [22:28:44 INF] HTTP GET /icon.png responded 404 in 0.5722 ms [22:28:44 INF] HTTP GET /lib/jquery/dist/jquery.slim.min.js responded 404 in 0.5714 ms [22:28:44 INF] Request finished HTTP/2 GET https://localhost:44377/lib/jquery/dist/jquery.slim.min.js - - - 404 - - 7.1329ms [22:28:44 INF] Request finished HTTP/2 GET https://localhost:44377/icon.png - - - 404 - - 7.4455ms

dahlsailrunner commented 3 years ago

I can't explain why you're seeing the error and i'm not, but it's because of the redirect uri. In the identityserver project, you need to have the following block in the Initialization/InitialConfiguration.cs file (the key is the redirect uri's):

new Client
{
    ClientId = "globo-core",
    ClientName = "Globomantics Core UI (Code with PKCE)",

    RedirectUris = { "https://localhost:44320/signin-oidc" },
    PostLogoutRedirectUris = { "https://notused" },

    ClientSecrets = { new Secret("secret".Sha256()) },

    AllowedGrantTypes = GrantTypes.CodeAndClientCredentials,
    AllowedScopes = { "openid", "profile", "glob_profile", "email", "glob_api" },
    AllowOfflineAccess = true,
    RefreshTokenUsage = TokenUsage.ReUse,
    RefreshTokenExpiration = TokenExpiration.Sliding
},

See if you can update the existing block and if that fixes things for you.

kri-kan commented 3 years ago

I have the section in my code as well!

Could this be "Works on my machine kind of issue" ? If that's so, I will go ahead verify in docker. coz that's one of the advantages in containers!

dahlsailrunner commented 3 years ago

I'm pretty sure I know what's happening. IdentityServer is using EntityFramework, which will create the GlobomanticsIdSrv database and schema on startup and insert the InitialConfiguration setup from the file mentioned above if the database is empty. I think you had previously tried from GitHub code, which created the database and put the startup information in the database for the docker style project. This would mean that the data in the code from the exercise files won't get applied.

Bottom line: Delete the GlobomanticsIdSrv database and run again. I bet it will work this time.