Sustainsys / Saml2

Saml2 Authentication services for ASP.NET
Other
952 stars 600 forks source link

Getting Not implemented exception from middleware when trying to route to a page using aspnetcore mvc #1245

Closed georgemckibbin closed 3 years ago

georgemckibbin commented 3 years ago

Trying to implement using the Saml2 handler in an aspnetcore 2.1 web app using MVC default routing

It goes through the authenticaiton (Using Okta in my case) but getting this exception when it tries to go to a page after authenticating.

I'm assuming this is something to do with the way the middleware is getting in the way of the default routing but can't figure out what to do.

Any links to sample code for full aspnetcore web apps using saml in addition to their existing identity stuff would be very much appreciated.

NotImplementedException: The method or operation is not implemented. Sustainsys.Saml2.AspNetCore2.Saml2Handler.ForbidAsync(AuthenticationProperties properties) Microsoft.AspNetCore.Authentication.AuthenticationService.ForbidAsync(HttpContext context, string scheme, AuthenticationProperties properties) Microsoft.AspNetCore.Mvc.ForbidResult.ExecuteResultAsync(ActionContext context) Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeResultAsync(IActionResult result) Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeAlwaysRunResultFilters() Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeFilterPipelineAsync() Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeAsync() Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext) Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext) Microsoft.AspNetCore.Cors.Infrastructure.CorsMiddleware.Invoke(HttpContext context) Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

georgemckibbin commented 3 years ago

Not sure what my problem was here but I completely redid how I was handling everything. I think I was making the Saml authenticator try to handle my normal cookies. Not a problem now.

AndersAbel commented 3 years ago

For future reference: The Asp.Net Core authentication pipeline is very flexible in the setup with how the schemes interact and using the Saml2 handler in unexpected ways often result in a not implemented exception.