Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swashbuckle issue with OpenID

I've configured Swashbuckle (5.0.0-rc2) on ASP.NET Core to work with my OpenID server (Openiddict) but Swagger doesn't show any available authorization. Only an empty modal.

This is the snippet where I set OpenID on swagger

services.AddSwaggerGen(c =>
{
    //... omitted for brevity
    //baseAccountsUrl is "https://localhost:5401"

    c.AddSecurityDefinition("AccountsOpenID", new OpenApiSecurityScheme
    {
        Type = SecuritySchemeType.OpenIdConnect,
        OpenIdConnectUrl = new Uri($"{baseAccountsUrl}/.well-known/openid-configuration")
    });
}

If I login before getting here every action works fine, otherwise every method will be redirected to login and shown in server response.

If I use OAuth2 instead of OpenID with password flow (it's configured this way on Openiddict) and not logged-in in browser it's not successful either.

What am I doing wrong?

like image 818
Matteo Bruni Avatar asked Oct 28 '22 14:10

Matteo Bruni


1 Answers

Support for OpenID Connect Discovery was added in Swagger UI v. 3.38.0. Swashbuckle needs to update the bundled Swagger UI to the latest version:
https://github.com/domaindrivendev/Swashbuckle.AspNetCore/issues/1241

like image 111
Borisgr04 Avatar answered Nov 15 '22 06:11

Borisgr04