simpleidserver / SimpleIdServer

OpenID, OAuth 2.0, SCIM2.0, UMA2.0, FAPI, CIBA & OPENBANKING Framework for ASP.NET Core
https://simpleidserver.com/
Apache License 2.0
708 stars 92 forks source link

Nested routes of not existing endpoints are not matched by DefaultController. #507

Closed IlyaAbramau closed 1 year ago

IlyaAbramau commented 1 year ago

Hi. The nested routes of not existing endpoints are not matched by DefaultController. For example host://lalala/lala will be not matched and the host://lalala will be matched. The 3.0.3 release had this modification of route attribute:

image

Why the "" was removed? If we will use the [Route("{url}", Order = 999)] all routes (include nested: host://lalala/lala) will be matched. Could you please check this moment and return the * symbol?

Thank you.

simpleidserver commented 1 year ago

Hello,

The "*" has been removed from the RouteAttribute after this discussion "https://github.com/simpleidserver/SimpleIdServer/discussions/469". When the app.UseRouting statement is removed from Startup.cs or Program.cs then the swagger endpoint is not working because the JS Files cannot be found. I'll take a look & find a better solution.

KR,

SID

IlyaAbramau commented 1 year ago

Hello,

Yeah, js files for the "https://github.com/simpleidserver/SimpleIdServer/discussions/469" are not found because of when swagger middleware returns index page (with empty routingPrefix), the index page tries to load necessary files by the route (for example host://swagger-js-bundle) and this route is matched by the DefaultController, so we get 404 and index page fails to load. However, this behavior seems to be working for both {url} and {*url}.

I guess, if we are using approach with DefaultController, adding app.UseRouting after app.UseSwaggerUI is okay. As documentation says: "If middleware should be run before route matching occurs, UseRouting should be called and the middleware should be placed before the call to UseRouting." (https://learn.microsoft.com/en-us/aspnet/core/fundamentals/minimal-apis/middleware?view=aspnetcore-7.0&viewFallbackFrom=aspnetcore-6.0#:~:text=If%20middleware%20should%20be%20run%20before%20route%20matching%20occurs%2C%20UseRouting%20should%20be%20called%20and%20the%20middleware%20should%20be%20placed%20before%20the%20call%20to%20UseRouting.)

Hope this information will be useful.

simpleidserver commented 1 year ago

Hello,

The RouteAttribute has been rolled back in the branch release\3.0.4.

[Route("{*url}", Order = 999)]

KR,

SID