Skip to content

Issues when connecting to local IdentityServer4Demo #21

@jontycool

Description

@jontycool

First, I tried this project with the demo.identityserver.io url that was pre-defined. Everything worked as expected.

The next step that I did was to download the IdentityServerDemo code from github and run it in my local. But in this scenario, this project is not able to login. Whenever I enter "bob" as username & password, I get redirected back to the login page.

From the identity server logs, I can see a success response from the identity server, but I am not able to figure out why it is redirecting me back to the login screen again & again.

Identity Server Logs generated from clicking on "Login" button after entering the username & password:
[17:14:48 Debug] IdentityServer4.Hosting.CorsPolicyProvider CORS request made for path: /.well-known/openid-configuration from origin: http://localhost:4200 [17:14:48 Debug] IdentityServer4.Hosting.CorsPolicyProvider CorsPolicyService allowed origin: http://localhost:4200 [17:14:48 Debug] IdentityServer4.Hosting.EndpointRouter Request path /.well-known/openid-configuration matched to endpoint type Discovery [17:14:48 Debug] IdentityServer4.Hosting.EndpointRouter Endpoint enabled: Discovery, successfully created handler: IdentityServer4.Endpoints.DiscoveryEndpoint [17:14:48 Information] IdentityServer4.Hosting.IdentityServerMiddleware Invoking IdentityServer endpoint: IdentityServer4.Endpoints.DiscoveryEndpoint for /.well-known/openid-configuration [17:14:48 Debug] IdentityServer4.Endpoints.DiscoveryEndpoint Start discovery request [17:14:48 Information] Serilog.AspNetCore.RequestLoggingMiddleware HTTP GET /.well-known/openid-configuration responded 200 in 9.9460 ms [17:14:48 Debug] IdentityServer4.Hosting.EndpointRouter Request path /connect/authorize matched to endpoint type Authorize [17:14:48 Debug] IdentityServer4.Hosting.EndpointRouter Endpoint enabled: Authorize, successfully created handler: IdentityServer4.Endpoints.AuthorizeEndpoint [17:14:48 Information] IdentityServer4.Hosting.IdentityServerMiddleware Invoking IdentityServer endpoint: IdentityServer4.Endpoints.AuthorizeEndpoint for /connect/authorize [17:14:48 Debug] IdentityServer4.Endpoints.AuthorizeEndpoint Start authorize request [17:14:48 Debug] IdentityServer4.Endpoints.AuthorizeEndpoint No user present in authorize request [17:14:48 Debug] IdentityServer4.Validation.AuthorizeRequestValidator Start authorize request protocol validation [17:14:48 Debug] IdentityServer4.Stores.ValidatingClientStore client configuration validation for client interactive.public succeeded. [17:14:48 Debug] IdentityServer4.Validation.AuthorizeRequestValidator Checking for PKCE parameters [17:14:48 Debug] IdentityServer4.Validation.AuthorizeRequestValidator Calling into custom validator: IdentityServer4.Validation.DefaultCustomAuthorizeRequestValidator [17:14:48 Debug] IdentityServer4.Endpoints.AuthorizeEndpoint ValidatedAuthorizeRequest {"ClientId": "interactive.public", "ClientName": "Interactive client (Code with PKCE)", "RedirectUri": "http://localhost:4200/signin-callback.html", "AllowedRedirectUris": ["http://localhost:4200/signin-callback.html", "http://localhost:4200/silent-renew.html"], "SubjectId": "anonymous", "ResponseType": "code", "ResponseMode": "query", "GrantType": "authorization_code", "RequestedScopes": "openid profile email api", "State": "a59eb16fa603441bb6fdcc08e220785a", "UiLocales": null, "Nonce": null, "AuthenticationContextReferenceClasses": null, "DisplayMode": null, "PromptMode": "", "MaxAge": null, "LoginHint": null, "SessionId": "", "Raw": {"client_id": "interactive.public", "redirect_uri": "http://localhost:4200/signin-callback.html", "response_type": "code", "scope": "openid profile email api", "state": "a59eb16fa603441bb6fdcc08e220785a", "code_challenge": "Attokt1Mbjq9wZQuOmDG1gvUORWrujqHidVrvKIShek", "code_challenge_method": "S256", "response_mode": "query"}, "$type": "AuthorizeRequestValidationLog"} [17:14:48 Information] IdentityServer4.ResponseHandling.AuthorizeInteractionResponseGenerator Showing login: User is not authenticated [17:14:48 Information] Serilog.AspNetCore.RequestLoggingMiddleware HTTP GET /connect/authorize?client_id=interactive.public&redirect_uri=http%3A%2F%2Flocalhost%3A4200%2Fsignin-callback.html&response_type=code&scope=openid%20profile%20email%20api&state=a59eb16fa603441bb6fdcc08e220785a&code_challenge=Attokt1Mbjq9wZQuOmDG1gvUORWrujqHidVrvKIShek&code_challenge_method=S256&response_mode=query responded 302 in 4.7417 ms [17:14:48 Debug] IdentityServer4.Validation.AuthorizeRequestValidator Start authorize request protocol validation [17:14:48 Debug] IdentityServer4.Stores.ValidatingClientStore client configuration validation for client interactive.public succeeded. [17:14:48 Debug] IdentityServer4.Validation.AuthorizeRequestValidator Checking for PKCE parameters [17:14:48 Debug] IdentityServer4.Validation.AuthorizeRequestValidator Calling into custom validator: IdentityServer4.Validation.DefaultCustomAuthorizeRequestValidator [17:14:48 Debug] IdentityServer4.Stores.ValidatingClientStore client configuration validation for client interactive.public succeeded. [17:14:48 Information] Serilog.AspNetCore.RequestLoggingMiddleware HTTP GET /Account/Login?ReturnUrl=%2Fconnect%2Fauthorize%2Fcallback%3Fclient_id%3Dinteractive.public%26redirect_uri%3Dhttp%253A%252F%252Flocalhost%253A4200%252Fsignin-callback.html%26response_type%3Dcode%26scope%3Dopenid%2520profile%2520email%2520api%26state%3Da59eb16fa603441bb6fdcc08e220785a%26code_challenge%3DAttokt1Mbjq9wZQuOmDG1gvUORWrujqHidVrvKIShek%26code_challenge_method%3DS256%26response_mode%3Dquery responded 200 in 67.0657 ms [17:14:49 Information] Serilog.AspNetCore.RequestLoggingMiddleware HTTP GET /lib/bootstrap/dist/css/bootstrap.min.css.map responded 200 in 170.0680 ms [17:14:49 Information] Serilog.AspNetCore.RequestLoggingMiddleware HTTP GET /lib/bootstrap/dist/js/bootstrap.bundle.min.js.map responded 200 in 152.6321 ms [17:18:21 Debug] IdentityServer4.Hosting.CorsPolicyProvider CORS request made for path: /Account/Login from origin: null but was ignored because path was not for an allowed IdentityServer CORS endpoint [17:18:24 Debug] IdentityServer4.Validation.AuthorizeRequestValidator Start authorize request protocol validation [17:18:24 Debug] IdentityServer4.Stores.ValidatingClientStore client configuration validation for client interactive.public succeeded. [17:18:24 Debug] IdentityServer4.Validation.AuthorizeRequestValidator Checking for PKCE parameters [17:18:24 Debug] IdentityServer4.Validation.AuthorizeRequestValidator Calling into custom validator: IdentityServer4.Validation.DefaultCustomAuthorizeRequestValidator [17:18:25 Information] IdentityServer4.Events.DefaultEventService {"Username": "bob", "Provider": null, "ProviderUserId": null, "SubjectId": "11", "DisplayName": "bob", "Endpoint": "UI", "ClientId": "interactive.public", "Category": "Authentication", "Name": "User Login Success", "EventType": "Success", "Id": 1000, "Message": null, "ActivityId": "80000402-0002-fe00-b63f-84710c7967bb", "TimeStamp": "2021-09-13T11:48:25.0000000Z", "ProcessId": 6348, "LocalIpAddress": "::1:24997", "RemoteIpAddress": "::1", "$type": "UserLoginSuccessEvent"} [17:18:25 Debug] IdentityServer4.Hosting.IdentityServerAuthenticationService Augmenting SignInContext [17:18:25 Debug] IdentityServer4.Hosting.IdentityServerAuthenticationService Adding idp claim with value: local [17:18:25 Debug] IdentityServer4.Hosting.IdentityServerAuthenticationService Adding amr claim with value: pwd [17:18:25 Debug] IdentityServer4.Hosting.IdentityServerAuthenticationService Adding auth_time claim with value: 1631533705 [17:18:25 Information] Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationHandler AuthenticationScheme: idsrv signed in. [17:18:25 Information] Serilog.AspNetCore.RequestLoggingMiddleware HTTP POST /Account/Login?ReturnUrl=%2Fconnect%2Fauthorize%2Fcallback%3Fclient_id%3Dinteractive.public%26redirect_uri%3Dhttp%253A%252F%252Flocalhost%253A4200%252Fsignin-callback.html%26response_type%3Dcode%26scope%3Dopenid%2520profile%2520email%2520api%26state%3Da59eb16fa603441bb6fdcc08e220785a%26code_challenge%3DAttokt1Mbjq9wZQuOmDG1gvUORWrujqHidVrvKIShek%26code_challenge_method%3DS256%26response_mode%3Dquery responded 302 in 3758.8502 ms [17:18:25 Debug] IdentityServer4.Hosting.EndpointRouter Request path /connect/authorize/callback matched to endpoint type Authorize [17:18:25 Debug] IdentityServer4.Hosting.EndpointRouter Endpoint enabled: Authorize, successfully created handler: IdentityServer4.Endpoints.AuthorizeCallbackEndpoint [17:18:25 Information] IdentityServer4.Hosting.IdentityServerMiddleware Invoking IdentityServer endpoint: IdentityServer4.Endpoints.AuthorizeCallbackEndpoint for /connect/authorize/callback [17:18:25 Debug] IdentityServer4.Endpoints.AuthorizeCallbackEndpoint Start authorize callback request [17:18:25 Debug] IdentityServer4.Endpoints.AuthorizeCallbackEndpoint No user present in authorize request [17:18:25 Debug] IdentityServer4.Validation.AuthorizeRequestValidator Start authorize request protocol validation [17:18:25 Debug] IdentityServer4.Stores.ValidatingClientStore client configuration validation for client interactive.public succeeded. [17:18:25 Debug] IdentityServer4.Validation.AuthorizeRequestValidator Checking for PKCE parameters [17:18:25 Debug] IdentityServer4.Validation.AuthorizeRequestValidator Calling into custom validator: IdentityServer4.Validation.DefaultCustomAuthorizeRequestValidator [17:18:25 Debug] IdentityServer4.Endpoints.AuthorizeCallbackEndpoint ValidatedAuthorizeRequest {"ClientId": "interactive.public", "ClientName": "Interactive client (Code with PKCE)", "RedirectUri": "http://localhost:4200/signin-callback.html", "AllowedRedirectUris": ["http://localhost:4200/signin-callback.html", "http://localhost:4200/silent-renew.html"], "SubjectId": "anonymous", "ResponseType": "code", "ResponseMode": "query", "GrantType": "authorization_code", "RequestedScopes": "openid profile email api", "State": "a59eb16fa603441bb6fdcc08e220785a", "UiLocales": null, "Nonce": null, "AuthenticationContextReferenceClasses": null, "DisplayMode": null, "PromptMode": "", "MaxAge": null, "LoginHint": null, "SessionId": "", "Raw": {"client_id": "interactive.public", "redirect_uri": "http://localhost:4200/signin-callback.html", "response_type": "code", "scope": "openid profile email api", "state": "a59eb16fa603441bb6fdcc08e220785a", "code_challenge": "Attokt1Mbjq9wZQuOmDG1gvUORWrujqHidVrvKIShek", "code_challenge_method": "S256", "response_mode": "query"}, "$type": "AuthorizeRequestValidationLog"} [17:18:25 Information] IdentityServer4.ResponseHandling.AuthorizeInteractionResponseGenerator Showing login: User is not authenticated [17:18:25 Information] Serilog.AspNetCore.RequestLoggingMiddleware HTTP GET /connect/authorize/callback?client_id=interactive.public&redirect_uri=http%3A%2F%2Flocalhost%3A4200%2Fsignin-callback.html&response_type=code&scope=openid%20profile%20email%20api&state=a59eb16fa603441bb6fdcc08e220785a&code_challenge=Attokt1Mbjq9wZQuOmDG1gvUORWrujqHidVrvKIShek&code_challenge_method=S256&response_mode=query responded 302 in 18.5326 ms [17:18:25 Debug] IdentityServer4.Validation.AuthorizeRequestValidator Start authorize request protocol validation [17:18:25 Debug] IdentityServer4.Stores.ValidatingClientStore client configuration validation for client interactive.public succeeded. [17:18:25 Debug] IdentityServer4.Validation.AuthorizeRequestValidator Checking for PKCE parameters [17:18:25 Debug] IdentityServer4.Validation.AuthorizeRequestValidator Calling into custom validator: IdentityServer4.Validation.DefaultCustomAuthorizeRequestValidator [17:18:25 Debug] IdentityServer4.Stores.ValidatingClientStore client configuration validation for client interactive.public succeeded. [17:18:25 Information] Serilog.AspNetCore.RequestLoggingMiddleware HTTP GET /Account/Login?ReturnUrl=%2Fconnect%2Fauthorize%2Fcallback%3Fclient_id%3Dinteractive.public%26redirect_uri%3Dhttp%253A%252F%252Flocalhost%253A4200%252Fsignin-callback.html%26response_type%3Dcode%26scope%3Dopenid%2520profile%2520email%2520api%26state%3Da59eb16fa603441bb6fdcc08e220785a%26code_challenge%3DAttokt1Mbjq9wZQuOmDG1gvUORWrujqHidVrvKIShek%26code_challenge_method%3DS256%26response_mode%3Dquery responded 200 in 66.1630 ms [17:18:26 Information] Serilog.AspNetCore.RequestLoggingMiddleware HTTP GET /lib/bootstrap/dist/css/bootstrap.min.css.map responded 200 in 38.8507 ms [17:18:26 Information] Serilog.AspNetCore.RequestLoggingMiddleware HTTP GET /lib/bootstrap/dist/js/bootstrap.bundle.min.js.map responded 200 in 55.0953 ms

Project Constants:

public static stsAuthority = 'http://localhost:24997/';
public static clientId = 'interactive.public';
public static clientRoot = 'http://localhost:4200/';
public static clientScope = 'openid profile email api';
public static apiRoot = 'http://localhost:24997/api/test';

Any help on this issue would be very helpful and apprecieated !

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions