abpframework / abp

Open-source web application framework for ASP.NET Core! Offers an opinionated architecture to build enterprise software solutions with best practices on top of the .NET. Provides the fundamental infrastructure, cross-cutting-concern implementations, startup templates, application modules, UI themes, tooling and documentation.
https://abp.io
GNU Lesser General Public License v3.0
12.76k stars 3.41k forks source link

IDX10204: Unable to validate issuer. validationParameters.ValidIssuer is null or whitespace AND validationParameters.ValidIssuers is null or empty. #20034

Closed wangyue20075 closed 3 months ago

wangyue20075 commented 3 months ago

Is there an existing issue for this?

Description

abp version is 8.1.4. when i user localhost to access ,it's success. but when i use the IP to access, it doesn't work properly. failed to validate the token. IDX10204: Unable to validate issuer. validationParameters.ValidIssuer is null or whitespace AND validationParameters.ValidIssuers is null or empty.

2024-06-13_193101 2024-06-13_193335

Version

8.1.4

User Interface

Common (Default)

maliming commented 3 months ago

See https://github.com/abpframework/abp/issues/15379#issuecomment-1377129014

wangyue20075 commented 3 months ago

It's success.

context.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) .AddJwtBearer(options => {

    options.Authority = configuration["AuthServer:Authority"];
    options.RequireHttpsMetadata = configuration.GetValue<bool>("AuthServer:RequireHttpsMetadata");
    options.MetadataAddress = configuration["AuthServer:Authority"]!;
    options.Audience = "Admin";

    // IDX10204: Unable to validate issuer on K8s if not set
    options.TokenValidationParameters = new TokenValidationParameters()
    {
        ValidIssuers = new[] { "https://192.168.1.61:44325/" },
        // IDX10500: Signature validation failed. No security keys were provided to validate the signature on K8s
        SignatureValidator = delegate (string token, TokenValidationParameters parameters)
        {
            var jwt = new Microsoft.IdentityModel.JsonWebTokens.JsonWebToken(token);
            return jwt;
        }
    };
});
wangyue20075 commented 3 months ago

SignatureValidator = delegate (string token, TokenValidationParameters parameters) { var jwt = new Microsoft.IdentityModel.JsonWebTokens.JsonWebToken(token); return jwt; }