aspnet / Security

[Archived] Middleware for security and authorization of web apps. Project moved to https://github.com/aspnet/AspNetCore
Apache License 2.0
1.27k stars 600 forks source link

No token validator was found for the given token WS-FED #1886

Closed amitsharma2912 closed 5 years ago

amitsharma2912 commented 5 years ago

System.Exception: An error was encountered while handling the remote login. ---> Microsoft.IdentityModel.Tokens.SecurityTokenException: No token validator was found for the given token. at Microsoft.AspNetCore.Authentication.WsFederation.WsFederationHandler.d9.MoveNext() --- End of inner exception stack trace --- at Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler`1.d12.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.d6.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.d7.MoveNext()

public void ConfigureServices(IServiceCollection services) { services.AddMvc(); services.AddAuthentication(options => { options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; options.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; options.DefaultChallengeScheme = WsFederationDefaults.AuthenticationScheme; }) .AddWsFederation(options => { options.MetadataAddress = "https://localhost/ConnectAuthentication/FederationMetadata/2007-06/FederationMetadata.xml"; options.RequireHttpsMetadata = true;

                        options.Wtrealm = "https://localhost/LogixPaidRight/";
                        options.CallbackPath = "/";
                        options.SkipUnrecognizedRequests = true;
                        options.Events.OnRedirectToIdentityProvider = ctx =>
                        {
                            ctx.ProtocolMessage.Wct = DateTimeOffset.UtcNow.ToString();
                            return Task.CompletedTask;
                        };
                    }).AddCookie();

    }

    public void Configure(IApplicationBuilder app, IHostingEnvironment env)
    {
        app.UseDeveloperExceptionPage();

        app.UseStaticFiles();
        app.UseAuthentication();
        app.UseMvcWithDefaultRoute();
    }
Tratcher commented 5 years ago

It doesn't like the token format. What software is providing you with the token? Can you share a Fiddler trace?

muratg commented 5 years ago

Hi. We're closing this issue as no response or updates have been provided in a timely manner and we have been unable to reproduce it. If you have more details and are encountering this issue please add a new reply and re-open the issue.