IdentityServer / IdentityServer4.AccessTokenValidation

IdentityServer Access Token Validation for ASP.NET Core
Apache License 2.0
544 stars 214 forks source link

If neither AddMvc or AddIdentity in services config, app.UseIdentityServerAuthentication will throw exception #57

Closed cokkiy closed 7 years ago

cokkiy commented 7 years ago

If neither services.AddMvc or services.AddIdentity called in services config, app.UseIdentityServerAuthentication will throw the following exceptions: System.InvalidOperationException: Unable to resolve service for type 'System.Text.Encodings.Web.UrlEncoder' while attempting to activate 'IdentityModel.AspNetCore.OAuth2Introspection.OAuth2IntrospectionMiddleware'. [1] Microsoft.Extensions.Internal.ActivatorUtilities.ConstructorMatcher.CreateInstance(IServiceProvider provider) [1] Microsoft.Extensions.Internal.ActivatorUtilities.CreateInstance(IServiceProvider provider, Type instanceType, Object[] parameters) [1] Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>cDisplayClass3_0.b0(RequestDelegate next) [1] Microsoft.AspNetCore.Builder.Internal.ApplicationBuilder.Build() [1] IdentityServer4.AccessTokenValidation.IdentityServerAuthenticationMiddleware..ctor(RequestDelegate next, IApplicationBuilder app, CombinedAuthenticationOptions options, ILogger`1 logger) [1] [1] Microsoft.Extensions.Internal.ActivatorUtilities.ConstructorMatcher.CreateInstance(IServiceProvider provider) [1] Microsoft.Extensions.Internal.ActivatorUtilities.CreateInstance(IServiceProvider provider, Type instanceType, Object[] parameters) [1] Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>cDisplayClass3_0.b0(RequestDelegate next) [1] Microsoft.AspNetCore.Builder.Internal.ApplicationBuilder.Build() [1] Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication() [1] Microsoft.AspNetCore.Hosting.WebHostBuilder.Build() [1] SourceTraceWeb.Program.Main(String[] args)

brockallen commented 7 years ago

wrong repo, but this sounds like a bug that we don't register those.

leastprivilege commented 7 years ago

That's actually how it works - you would get the same result for the Microsoft authentication middleware.

you need to manually do

services.AddAuthentication in ConfigureServices.