我需要在Azure辅助角色中嵌入一个小的Owin主机。 我需要提供一些静态文件,但子目录应该受密码保护。我无法通过身份验证在自托管应用上找到任何好的示例。
我正在尝试设置以下appBuilder:
Func<CookieValidateIdentityContext, Task> validate = async context =>
{
Logger.Trace("Access");
};
var authOptions = new CookieAuthenticationOptions
{
AuthenticationMode = AuthenticationMode.Active,
AuthenticationType =
DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/Login.html"),
Provider =
new CookieAuthenticationProvider
{
OnValidateIdentity
= validate,
OnApplyRedirect = redirect,
OnResponseSignIn = signIn
}
};
appBuilder.UseCookieAuthentication(authOptions);
appBuilder.UseStageMarker(PipelineStage.Authenticate);
var basePath = GetBasePath();
var webPath = Path.Combine(basePath, "Web");
var physicalFileSystem = new PhysicalFileSystem(webPath);
var options = new FileServerOptions
{
EnableDefaultFiles = true,
EnableDirectoryBrowsing = true,
FileSystem = physicalFileSystem
};
options.StaticFileOptions.FileSystem = physicalFileSystem;
options.StaticFileOptions.ServeUnknownFileTypes = true;
options.DefaultFilesOptions.DefaultFileNames = new[] { "index.html" };
appBuilder.UseFileServer(options);
我遇到两个问题: