FunctionMonkey icon indicating copy to clipboard operation
FunctionMonkey copied to clipboard

OpenAPI - Bearer Authentication

Open detroitpro opened this issue 6 years ago • 1 comments

I followed the excellent guide to configuration bearer auth and configured our functions to generate swagger documentation but the swagger UI does not allow setting the bearer token.

Here is our FunctionAppConfiguration, are we doing something incorrect or is enabling setting the token in the openapi UI not a feature (yet)?

 public void Build(IFunctionHostBuilder builder)
    {
      builder
          .Setup((serviceCollection, commandRegistry) =>
          {
            serviceCollection
                  .AddApplication(commandRegistry)
                  .AddAutoMapper(typeof(SubSystemRegistration));
          })
          .Authorization(authorization => authorization
               .AuthorizationDefault(AuthorizationTypeEnum.TokenValidation)
               .TokenValidator<BearerTokenValidator>())
          .OpenApiEndpoint(openApi => openApi
              .Title("Open API Spec").UserInterface().Version("1.0.0"))
          .Functions(functions => functions
               .HttpRoute("dashboard", route => route.HttpFunction<DashboardQuery>(HttpMethod.Get))
          );
    }

I checked the generated openapi.yaml and it seems to be missing the section related to auth as described here: https://swagger.io/docs/specification/authentication/bearer-authentication/ - I'm just not sure if I am doing something wrong or if we should send a PR :)

image

detroitpro avatar Aug 22 '19 18:08 detroitpro

A PR would be gratefully received :)

JamesRandall avatar Sep 12 '19 18:09 JamesRandall