升级到ASP.Net core 2.1之后,获得AuthenticationScheme:承载被挑战循环

时间:2018-06-25 16:30:12

标签: c# asp.net asp.net-core-2.1

我有一个用Angular5用ASP.Net Core 2.0编写的项目。我现在使用IdentityServer4.AccessTokenValidation 2.6.0的最新版本升级到Core 2.1。该应用程序使用IIS Express在Visual Studio 2017中生成并正常运行。但是,当我使用dotnet cli 2.1.301运行它时,应用程序登录正常,但是当我尝试访问API中的任何数据时,我得到:

    info: IdentityServer4.AccessTokenValidation.IdentityServerAuthenticationHandler[7]
      Bearer was not authenticated. Failure message: IDX10205: Issuer validation failed. Issuer: '[PII is hidden by default. Set the 'ShowPII' flag in IdentityModelEventSource.cs to true to reveal it.]'. Did not match: validationParameters.ValidIssuer: '[PII is hidden by default. Set the 'ShowPII' flag in IdentityModelEventSource.cs to true to reveal it.]' or validationParameters.ValidIssuers: '[PII is hidden by default. Set the 'ShowPII' flag in IdentityModelEventSource.cs to true to reveal it.]'.
info: IdentityServer4.AccessTokenValidation.IdentityServerAuthenticationHandler[12]
      AuthenticationScheme: Bearer was challenged.
info: IdentityServer4.AccessTokenValidation.IdentityServerAuthenticationHandler[12]
      AuthenticationScheme: Bearer was challenged.
dbug: IdentityServer4.Hosting.EndpointRouter[0]
      Request path /connect/token matched to endpoint type Token
dbug: IdentityServer4.Hosting.EndpointRouter[0]
      Endpoint enabled: Token, successfully created handler: IdentityServer4.Endpoints.TokenEndpoint
info: IdentityServer4.Hosting.IdentityServerMiddleware[0]
      Invoking IdentityServer endpoint: IdentityServer4.Endpoints.TokenEndpoint for /connect/token
dbug: IdentityServer4.Endpoints.TokenEndpoint[0]
      Start token request.
dbug: IdentityServer4.Validation.ClientSecretValidator[0]
      Start client validation
dbug: IdentityServer4.Validation.BasicAuthenticationSecretParser[0]
      Start parsing Basic Authentication secret
dbug: IdentityServer4.Validation.PostBodySecretParser[0]
      Start parsing for secret in post body
dbug: IdentityServer4.Validation.PostBodySecretParser[0]
      client id without secret found
dbug: IdentityServer4.Validation.SecretParser[0]
      Parser found secret: PostBodySecretParser
dbug: IdentityServer4.Validation.SecretParser[0]
      Secret id found: PinkCarServiceApp_spa
dbug: IdentityServer4.Stores.ValidatingClientStore[0]
      client configuration validation for client PinkCarServiceApp_spa succeeded.
dbug: IdentityServer4.Validation.ClientSecretValidator[0]
      Public Client - skipping secret validation success
dbug: IdentityServer4.Validation.ClientSecretValidator[0]
      Client validation success
dbug: IdentityServer4.Validation.TokenRequestValidator[0]
      Start token request validation
dbug: IdentityServer4.Validation.TokenRequestValidator[0]
      Start validation of refresh token request
info: IdentityServer4.AccessTokenValidation.IdentityServerAuthenticationHandler[7]
      Bearer was not authenticated. Failure message: IDX10205: Issuer validation failed. Issuer: '[PII is hidden by default. Set the 'ShowPII' flag in IdentityModelEventSource.cs to true to reveal it.]'. Did not match: validationParameters.ValidIssuer: '[PII is hidden by default. Set the 'ShowPII' flag in IdentityModelEventSource.cs to true to reveal it.]' or validationParameters.ValidIssuers: '[PII is hidden by default. Set the 'ShowPII' flag in IdentityModelEventSource.cs to true to reveal it.]'.
info: IdentityServer4.AccessTokenValidation.IdentityServerAuthenticationHandler[12]
      AuthenticationScheme: Bearer was challenged.
dbug: IdentityServer4.Validation.TokenValidator[0]
      Token validation success
{
        "ClientId": "ServiceApp_spa",
        "ValidateLifetime": false,
        "Claims": {
          "sub": "0acdcf55-facb-4bdb-84ab-f67511597c4b",
          "client_id": "ServiceApp_spa",
          "scope": [
            "email",
            "openid",
            "phone",
            "profile",
            "roles",
            "ServiceApp_api",
            "offline_access"
          ],
          "auth_time": 1529943152,
          "idp": "local",
          "amr": "pwd",
          "role": "administrator",
          "permission": [
            "users.view",
            "users.manage",
            "roles.view",
            "roles.manage",
            "roles.assign"
          ],
          "name": "admin",
          "email": "admin@example.com",
          "phone_number": "+1 (123) 000-0000",
          "fullname": "Inbuilt Administrator"
        }
      }
dbug: IdentityServer4.Validation.TokenRequestValidator[0]
      Validation of refresh token request success
info: IdentityServer4.Validation.TokenRequestValidator[0]
      Token request validation success
{
        "ClientId": "ServiceApp_spa",
        "GrantType": "refresh_token",
        "RefreshToken": "fb3dffe262455a1f281ev01c626a9335bfe9f188a84f0b69f2a2c58969d26dc3",
        "Raw": {
          "refresh_token": "fb3dffe262455a1f281ev01c626a9335bfe9f188a84f0b69f2a2c58969d26dc3",
          "client_id": "ServiceApp_spa",
          "grant_type": "refresh_token"
        }
      }
dbug: IdentityServer4.Services.DefaultRefreshTokenService[0]
      Updating refresh token
dbug: IdentityServer4.Services.DefaultRefreshTokenService[0]
      Token usage is one-time only. Generating new handle
dbug: IdentityServer4.Services.DefaultRefreshTokenService[0]
      Refresh token expiration is sliding - extending lifetime
dbug: IdentityServer4.Services.DefaultRefreshTokenService[0]
      Current lifetime: 25
dbug: IdentityServer4.Services.DefaultRefreshTokenService[0]
      New lifetime: 1296025
dbug: IdentityServer4.Services.DefaultRefreshTokenService[0]
      Created refresh token in store
dbug: IdentityServer4.Services.DefaultClaimsService[0]
      Getting claims for identity token for subject: 0acdcf55-facb-4bdb-84ab-f67511597c4b and client: PinkCarServiceApp_spa
dbug: IdentityServer4.Services.DefaultClaimsService[0]
      In addition to an id_token, an access_token was requested. No claims other than sub are included in the id_token. To obtain more user claims, either use the user info endpoint or set AlwaysIncludeUserClaimsInIdToken on the client configuration.
dbug: IdentityServer4.Endpoints.TokenEndpoint[0]
      Token request success.
info: IdentityServer4.AccessTokenValidation.IdentityServerAuthenticationHandler[7]
      Bearer was not authenticated. Failure message: IDX10205: Issuer validation failed. Issuer: '[PII is hidden by default. Set the 'ShowPII' flag in IdentityModelEventSource.cs to true to reveal it.]'. Did not match: validationParameters.ValidIssuer: '[PII is hidden by default. Set the 'ShowPII' flag in IdentityModelEventSource.cs to true to reveal it.]' or validationParameters.ValidIssuers: '[PII is hidden by default. Set the 'ShowPII' flag in IdentityModelEventSource.cs to true to reveal it.]'.
info: IdentityServer4.AccessTokenValidation.IdentityServerAuthenticationHandler[12]

0 个答案:

没有答案