Identity 身份认证和授权终结点
This commit is contained in:
1 parent
2f79bf6b25
commit
e7cbd32a39
22 files changed
+1087
-167
No files matched your search
@@ -3,6 +3,7 @@
|
||||
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using Swashbuckle.AspNetCore.Swagger;
|
||||
using Swashbuckle.AspNetCore.SwaggerGen;
|
||||
using Swashbuckle.AspNetCore.SwaggerUI;
|
||||
@@ -22,6 +23,28 @@ namespace HelloShop.ServiceDefaults.Extensions
|
||||
services.AddEndpointsApiExplorer();
|
||||
services.AddSwaggerGen(configureOptions);
|
||||
|
||||
services.Configure<SwaggerGenOptions>(options =>
|
||||
{
|
||||
options.AddSecurityDefinition("bearerAuth", new OpenApiSecurityScheme
|
||||
{
|
||||
Type = SecuritySchemeType.Http,
|
||||
Scheme = "bearer",
|
||||
BearerFormat = "JWT",
|
||||
Description = "JWT Authorization header using the Bearer scheme."
|
||||
});
|
||||
|
||||
options.AddSecurityRequirement(new OpenApiSecurityRequirement
|
||||
{
|
||||
{
|
||||
new OpenApiSecurityScheme
|
||||
{
|
||||
Reference = new OpenApiReference { Type = ReferenceType.SecurityScheme, Id = "bearerAuth" }
|
||||
},
|
||||
Array.Empty<string>()
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user