.net core azure功能的大摇大摆UI更改和授权
我已经使用FunctionStartup的启动文件为azure函数应用程序实现了swagger,该启动文件具有用于配置的覆盖方法.net core azure功能的大摇大摆UI更改和授权,.net-core,swagger,azure-functions,swashbuckle,swashbuckle.aspnetcore,.net Core,Swagger,Azure Functions,Swashbuckle,Swashbuckle.aspnetcore,我已经使用FunctionStartup的启动文件为azure函数应用程序实现了swagger,该启动文件具有用于配置的覆盖方法 public override void Configure(IFunctionsHostBuilder builder) { builder.AddSwashBuckle(Assembly.GetExecutingAssembly(), opts => {
public override void Configure(IFunctionsHostBuilder builder)
{
builder.AddSwashBuckle(Assembly.GetExecutingAssembly(), opts =>
{
opts.SpecVersion = OpenApiSpecVersion.OpenApi3_0;
opts.AddCodeParameter = true;
opts.PrependOperationWithRoutePrefix = true;
opts.Documents = new[]
{
new SwaggerDocument
{
Name = "v1",
Title = "Swagger document",
Description = "Swagger test document",
Version = "v2"
}
};
opts.Title = "Swagger Test";
//opts.OverridenPathToSwaggerJson = new Uri("http://localhost:7071/api/Swagger/json");
opts.ConfigureSwaggerGen = (x =>
{
x.CustomOperationIds(apiDesc =>
{
return apiDesc.TryGetMethodInfo(out MethodInfo methodInfo)
? methodInfo.Name
: new Guid().ToString();
});
});
});
ConfigureServices(builder.Services);
}
我正试图实现一个不同的css的网页和授权,这是不工作的
public void ConfigureServices(IServiceCollection services)
{
services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddJwtBearer(opts =>
{
opts.Authority = $"auth-url";
opts.Audience = "key";
});
// see docs for more config options for AddJwtBearer
// Add security definition and scopes to document
services.AddOpenApiDocument(document =>
{
document.AddSecurity("bearer", Enumerable.Empty<string>(), new OpenApiSecurityScheme
{
Type = OpenApiSecuritySchemeType.OAuth2,
Description = "B2C authentication",
Flow = OpenApiOAuth2Flow.Implicit,
Flows = new OpenApiOAuthFlows()
{
Implicit = new OpenApiOAuthFlow()
{
Scopes = new Dictionary<string, string>
{
{ "auth", "Access the api as the signed-in user" },
{ "auth", "Read access to the API"},
{ "auth", "Let's find out together!"}
},
AuthorizationUrl = "auth",
TokenUrl = "auth"
},
}
});
document.OperationProcessors.Add(new AspNetCoreOperationSecurityScopeProcessor("bearer"));
});
}
public void配置服务(IServiceCollection服务)
{
services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddJwtBearer(选项=>
{
opts.Authority=$“auth url”;
opts.academy=“key”;
});
//有关AddJWTBear的更多配置选项,请参阅文档
//向文档中添加安全定义和范围
services.AddOpenApiDocument(document=>
{
document.AddSecurity(“bearer”,Enumerable.Empty(),新OpenApiSecurityScheme
{
Type=OpenApiSecuritySchemeType.OAuth2,
Description=“B2C身份验证”,
Flow=openapiouth2flow.Implicit,
Flows=新的openapiouthflows()
{
隐式=新的openapiouthflow()
{
范围=新字典
{
{“auth”,“以登录用户身份访问api”},
{“auth”,“对API的读取访问”},
{“auth”,“让我们一起找出答案!”
},
AuthorizationUrl=“auth”,
TokenUrl=“auth”
},
}
});
document.OperationProcessors.Add(新的AspNetCoreOperationSecurityScopeProcessor(“持票人”);
});
}
我收到授权错误,即Microsoft.AspNetCore.Authentication.Core:未为方案“webjobsathlevel”注册任何身份验证处理程序。
我不确定如何注入css,目前不支持此功能-