The error message is same.
The same code deployed on Stagging and Production server. The staging is working fine but having issue on production server.
public override void PreConfigureServices(ServiceConfigurationContext context)
{
var hostingEnvironment = context.Services.GetHostingEnvironment();
var configuration = context.Services.GetConfiguration();
PreConfigure< OpenIddictBuilder >(builder =>
{
builder.AddValidation(options =>
{
options.AddAudiences("AccountService");
options.UseLocalServer();
options.UseAspNetCore();
});
});
if (!hostingEnvironment.IsDevelopment())
{
PreConfigure< AbpOpenIddictAspNetCoreOptions >(options =>
{
options.AddDevelopmentEncryptionAndSigningCertificate = false;
});
PreConfigure< OpenIddictServerBuilder >(builder =>
{
builder.AddSigningCertificate(GetSigningCertificate(hostingEnvironment, configuration));
builder.AddEncryptionCertificate(GetSigningCertificate(hostingEnvironment, configuration));
builder.SetIssuer(new Uri(configuration["App:SelfUrl"]));
builder.SetAuthorizationEndpointUris($"{new Uri(configuration["App:SelfUrl"])}connect/authorize");
builder.SetLogoutEndpointUris($"{new Uri(configuration["App:SelfUrl"])}connect/logout");
builder.SetDeviceEndpointUris($"{new Uri(configuration["App:SelfUrl"])}device");
builder.SetUserinfoEndpointUris($"{new Uri(configuration["App:SelfUrl"])}connect/userinfo");
builder.SetTokenEndpointUris($"{new Uri(configuration["App:SelfUrl"])}connect/token");
builder.SetRevocationEndpointUris($"{new Uri(configuration["App:SelfUrl"])}connect/revocat");
builder.SetIntrospectionEndpointUris($"{new Uri(configuration["App:SelfUrl"])}connect/introspect");
builder.SetCryptographyEndpointUris($"{new Uri(configuration["App:SelfUrl"])}.well-known/jwks");
});
}
PreConfigure< IdentityBuilder >(builder =>
{
builder.AddClaimsPrincipalFactory<UserClaimsPrincipalFactory>();
});
}
It is already set to true.
[11:19:29 INF] Executed action Volo.Abp.OpenIddict.Controllers.AuthorizeController.HandleAsync (Volo.Abp.OpenIddict.AspNetCore) in 68.4013ms
[11:19:29 INF] Executed endpoint 'Volo.Abp.OpenIddict.Controllers.AuthorizeController.HandleAsync (Volo.Abp.OpenIddict.AspNetCore)'
[11:19:32 INF] CORS policy execution successful.
[11:19:32 INF] CORS policy execution successful.
[11:19:32 INF] The request URI matched a server endpoint: Configuration.
[11:19:32 INF] The configuration request was successfully extracted: {}.
[11:19:32 INF] The configuration request was successfully validated.
[11:19:32 INF] The response was successfully returned as a JSON document: {
"issuer": "https://auth.domain.com/",
"authorization_endpoint": "https://auth.domain.com/connect/authorize",
"token_endpoint": "https://auth.domain.com/connect/token",
"introspection_endpoint": "https://auth.domain.com/connect/introspect",
"end_session_endpoint": "https://auth.domain.com/connect/logout",
"revocation_endpoint": "https://auth.domain.com/connect/revocat",
"userinfo_endpoint": "https://auth.domain.com/connect/userinfo",
"device_authorization_endpoint": "https://auth.domain.com/device",
"jwks_uri": "https://auth.domain.com/.well-known/jwks",
"grant_types_supported": [
"authorization_code",
"implicit",
"password",
"client_credentials",
"refresh_token",
"urn:ietf:params:oauth:grant-type:device_code",
"LinkLogin",
"Impersonation"
],
Administration Logs
[11:19:34 INF] CORS policy execution successful.
[11:19:34 INF] Failed to validate the token.
Microsoft.IdentityModel.Tokens.SecurityTokenInvalidIssuerException: IDX10204: Unable to validate issuer. validationParameters.ValidIssuer is null or whitespace AND validationParameters.ValidIssuers is null or empty.
at Microsoft.IdentityModel.Tokens.Validators.ValidateIssuerAsync(String issuer, SecurityToken securityToken, TokenValidationParameters validationParameters, BaseConfiguration configuration)
at Microsoft.IdentityModel.Tokens.Validators.ValidateIssuer(String issuer, SecurityToken securityToken, TokenValidationParameters validationParameters, BaseConfiguration configuration)
at Microsoft.IdentityModel.Tokens.InternalValidators.ValidateAfterSignatureFailed(SecurityToken securityToken, Nullable`1 notBefore, Nullable`1 expires, IEnumerable`1 audiences, TokenValidationParameters validationParameters, BaseConfiguration configuration)
at Microsoft.IdentityModel.JsonWebTokens.JsonWebTokenHandler.ValidateSignature(JsonWebToken jwtToken, TokenValidationParameters validationParameters, BaseConfiguration configuration)
at Microsoft.IdentityModel.JsonWebTokens.JsonWebTokenHandler.ValidateSignatureAndIssuerSecurityKey(JsonWebToken jsonWebToken, TokenValidationParameters validationParameters, BaseConfiguration configuration)
at Microsoft.IdentityModel.JsonWebTokens.JsonWebTokenHandler.ValidateJWSAsync(JsonWebToken jsonWebToken, TokenValidationParameters validationParameters, BaseConfiguration configuration)
[11:19:34 INF] Bearer was not authenticated. Failure message: IDX10204: Unable to validate issuer. validationParameters.ValidIssuer is null or whitespace AND validationParameters.ValidIssuers is null or empty.
[11:19:34 INF] Executing endpoint 'Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.AbpApplicationLocalizationController.GetAsync (Volo.Abp.AspNetCore.Mvc)'
[11:19:34 INF] Route matched with {area = "abp", action = "Get", controller = "AbpApplicationLocalization", page = ""}. Executing controller action with signature System.Threading.Tasks.Task`1[Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ApplicationLocalizationDto] GetAsync(Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ApplicationLocalizationRequestDto) on controller Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.AbpApplicationLocalizationController (Volo.Abp.AspNetCore.Mvc).
[11:19:34 INF] Executing ObjectResult, writing value of type 'Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ApplicationLocalizationDto'.
[11:19:34 INF] Executed action Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.AbpApplicationLocalizationController.GetAsync (Volo.Abp.AspNetCore.Mvc) in 8.0414ms
[11:19:34 INF] Executed endpoint 'Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.AbpApplicationLocalizationController.GetAsync (Volo.Abp.AspNetCore.Mvc)'
That is a different error. I have exception code IDX10204. The issuer is there but it unable to validate.
I have microservice architecture. I have deployed the application on the sever. When I click to login, it redirects to auth server and successfully logged in and redirected back to angular application but authentication is not working. The token api and openid-configuration api is fine. The token is also generated. I checked the logs of auth server and token is successfully validated.
I checked the administration service logs.
[08:47:56 INF] Failed to validate the token. Microsoft.IdentityModel.Tokens.SecurityTokenInvalidIssuerException: IDX10204: Unable to validate issuer. validationParameters.ValidIssuer is null or whitespace AND validationParameters.ValidIssuers is null or empty. at Microsoft.IdentityModel.Tokens.Validators.ValidateIssuerAsync(String issuer, SecurityToken securityToken, TokenValidationParameters validationParameters, BaseConfiguration configuration) at Microsoft.IdentityModel.Tokens.Validators.ValidateIssuer(String issuer, SecurityToken securityToken, TokenValidationParameters validationParameters, BaseConfiguration configuration) at Microsoft.IdentityModel.JsonWebTokens.JsonWebTokenHandler.ValidateSignature(JsonWebToken jwtToken, TokenValidationParameters validationParameters, BaseConfiguration configuration) at Microsoft.IdentityModel.JsonWebTokens.JsonWebTokenHandler.ValidateSignatureAndIssuerSecurityKey(JsonWebToken jsonWebToken, TokenValidationParameters validationParameters, BaseConfiguration configuration) at Microsoft.IdentityModel.JsonWebTokens.JsonWebTokenHandler.ValidateJWSAsync(JsonWebToken jsonWebToken, TokenValidationParameters validationParameters, BaseConfiguration configuration)
Its working now. Thank You
I have sent email.
Sure, I will share with you on Monday.
Yes I checked and the exception code is being executed ..
I have Microservice architecture. I have added Custom exception filter in NxP.Shared.Hosting.Microservices.
namespace NxP.Shared.Hosting.Microservices
{
[Dependency(ReplaceServices = true)]
[ExposeServices(typeof(AbpExceptionFilter), typeof(IAsyncExceptionFilter))]
public class GlobalExceptionFilter : AbpExceptionFilter, ITransientDependency
{
private readonly IDistributedEventBus _distributedEventBus;
private readonly ILogger< GlobalExceptionFilter > _logger;
public GlobalExceptionFilter(IDistributedEventBus distributedEventBus, ILogger< GlobalExceptionFilter > logger)
{
_distributedEventBus = distributedEventBus;
_logger = logger;
}
public override async Task OnExceptionAsync(ExceptionContext context)
{
var exception = context.Exception;
var actionDescriptor = context.ActionDescriptor;
var exceptionLogEto = new ExceptionLogEto
{
Message = exception.Message,
Type = exception.GetType().Name,
StackTrace = exception.InnerException?.Message ?? exception.StackTrace,
Source = exception.Source,
ControllerName = actionDescriptor.RouteValues["controller"],
ActionName = actionDescriptor.RouteValues["action"],
};
await _distributedEventBus.PublishAsync(exceptionLogEto);
_logger.LogInformation("Exception handled by GlobalExceptionFilter.");
//await base.OnExceptionAsync(context);
// throw exception;
//context.ExceptionHandled = true;
}
}
}
I have added filters in services in NxPSharedHostingMicroservicesModule
context.Services.AddTransient< GlobalExceptionFilter >();
context.Services.AddControllers(options =>
{
options.Filters.AddService< GlobalExceptionFilter >();
}).AddControllersAsServices();
I have handler in LoggingService to receive exception data and storing in database, but the event is not receiving in LoggingService. There is no exception and event data is not publishing. I have also checked the sample console application.
Handler in logging microservice.
public class ExceptionLogHandler : IDistributedEventHandler< ExceptionLogEto >, ITransientDependency
{
private readonly ILogger< ExceptionLogHandler > _logger;
private readonly IExceptionLogRepository _exceptionLogRepository;
public ExceptionLogHandler(ILogger< ExceptionLogHandler > logger
, IExceptionLogRepository exceptionLogRepository
)
{
_logger = logger;
_exceptionLogRepository = exceptionLogRepository;
_logger.LogInformation("ExceptionLogHandler initialized.");
}
[UnitOfWork]
public async Task HandleEventAsync(ExceptionLogEto eventData)
{
_logger.LogInformation("Handling exception log...");
ExceptionLog exceptionLog = new ExceptionLog(
Guid.NewGuid(),
eventData.Message,
eventData.Type,
eventData.StackTrace,
eventData.Source,
eventData.ControllerName,
eventData.ActionName,
DateTime.Now
);
_logger.LogInformation(Newtonsoft.Json.JsonConvert.SerializeObject(exceptionLog));
await _exceptionLogRepository.InsertAsync(exceptionLog);
}
}