Hello fellow developers,
I have implemented a server with multiple endpoints and integrated the Swashbuckle Swagger UI middleware. This middleware is accessable for everyone without habing to login at the server. I am using Bearer tokens to autenticate my requests.
Is there any possibility to prevent accessing the Swagger UI without having logged in to my server?
Here is how I registered swagger in my Startup.cs:
app.UseSwagger();
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
});
And to generate the swagger json file:
// Register Swagger generator
services.AddSwaggerGen();
PS: I noticed that even if I am logged in and got a JWT, in the swagger request no Authentication Header is sent. If I could add/force this Header, I could check it in another middleware.
Thx in advance.