This commit is contained in:
Yaqi Yang 2022-04-11 09:59:36 -07:00
Родитель 4b8dbd6247
Коммит dfe63d5257
7 изменённых файлов: 101 добавлений и 25 удалений

Просмотреть файл

@ -0,0 +1,76 @@
{
"host_id": "",
"host_name": "IIS Administration API",
"urls": "https://*:55539",
"security": {
"require_windows_authentication": true,
"users": {
"administrators": [
"mydomain\\myusername",
"myusername@mycompany.com",
"Owners"
],
"owners": [
"mydomain\\myusername",
"myusername@mycompany.com",
"IIS Administration API Owners"
]
},
"access_policy": {
"api": {
"users": "administrators",
"access_key": true
},
"api_keys": {
"users": "administrators",
"access_key": false
},
"system": {
"users": "owners",
"access_key": true
}
}
},
"logging": {
"enabled": true,
"min_level": "Debug",
"file_name": "log-{Date}.txt",
"LogLevel": {
"Default": "Error",
"System": "Error",
"Microsoft": "Error"
}
},
"auditing": {
"enabled": true,
"file_name": "audit-{Date}.txt"
},
"cors": {
"rules": [
{
"origin": "https://manage.iis.net",
"allow": true
}
]
},
"files": {
"locations": [
{
"alias": "inetpub",
"path": "C:\\inetpub",
"claims": [
"read",
"write"
]
},
{
"alias": "tests",
"path": "C:\\Repos\\iis-admin\\.test",
"claims": [
"read",
"write"
]
}
]
}
}

Просмотреть файл

@ -507,7 +507,6 @@ namespace System.Net.Http
{
try
{
//_ = request.Properties.TryGetValue(key, out value);
_ = request.Options.TryGetValue<T>(new HttpRequestOptionsKey<T>(key), out T value);
return value;
}

Просмотреть файл

@ -56,7 +56,6 @@ namespace Microsoft.IIS.Administration.WebApiCompatShim
// This allows us to pass the message through APIs defined in legacy code and then
// operate on the HttpContext inside.
//message.Properties[nameof(HttpContext)] = httpContext;
message.Options.Set<HttpContext>(new HttpRequestOptionsKey<HttpContext>(nameof(HttpContext)),
httpContext);

Просмотреть файл

@ -20,9 +20,9 @@ namespace Microsoft.IIS.Administration.WebServer.Sites
using Core.Http;
using System.Dynamic;
using Files;
using CentralCertificates;
using System.Reflection;
using CentralCertificates;
using System.Reflection;
public static class SiteHelper
{
private const string OIDServerAuth = "1.3.6.1.5.5.7.3.1";
@ -686,23 +686,24 @@ namespace Microsoft.IIS.Administration.WebServer.Sites
if (isHttp) {
string ipAddress = null;
int? port = null;
// When referencing binding.EndPoint, MissingMethodException
// 'System.Net.IPEndPoint Microsoft.Web.Administration.Binding.get_EndPoint()'.
// It is due to .Net version conflicts. This can be resolved
// when Microsoft.Web.Administration.dll moves to .Net 6.0 or later
int? port = null;
// When referencing binding.EndPoint, MissingMethodException is raised for
// 'System.Net.IPEndPoint Microsoft.Web.Administration.Binding.get_EndPoint()'.
// It is due to .Net version conflicts. This can be resolved
// when Microsoft.Web.Administration.dll moves to .Net 6.0 or later
// Now, use reflection to get the property as dynamic type
dynamic endPoint = GetBindingEndPoint(binding);
if (endPoint != null && endPoint.Address != null)
if (endPoint != null && endPoint.Address != null)
{
port = endPoint.Port;
if (endPoint.Address != null)
if (endPoint.Address != null)
{
// endPoint.Address.Equals(IPAddress.Any) does not work in most cases since it is dynamic type
ipAddress = endPoint.Address.Equals(IPAddress.Any) ||
string.Compare(endPoint.Address.ToString(), IPAddress.Any.ToString(), StringComparison.OrdinalIgnoreCase) == 0
? "*"
string.Compare(endPoint.Address.ToString(), IPAddress.Any.ToString(), StringComparison.OrdinalIgnoreCase) == 0
? "*"
: (string)endPoint.Address.ToString();
}
}
@ -753,12 +754,12 @@ namespace Microsoft.IIS.Administration.WebServer.Sites
return obj;
}
private static dynamic GetBindingEndPoint(Binding binding)
{
PropertyInfo propInfo = typeof(Binding).GetProperty("EndPoint");
return binding == null ? null : propInfo?.GetValue(binding);
}
private static dynamic GetBindingEndPoint(Binding binding)
{
PropertyInfo propInfo = typeof(Binding).GetProperty("EndPoint");
return binding == null ? null : propInfo?.GetValue(binding);
}
private static long FirstAvailableId()
{
ServerManager sm = ManagementUnit.ServerManager;

Просмотреть файл

@ -62,7 +62,7 @@ namespace Microsoft.IIS.Administration.Extensibility
var rootPaths = new List<string>();
rootPaths.Add(Path.Combine(_pluginDir, $"{assemblyName.Name}.{assemblyName.Version}"));
rootPaths.Add(_pluginDir);
// drop Microsoft.Web.Administration v10 (package v11.1) referenced assemblies here
// Load Microsoft.Web.Administration v10 (package v11.1) referenced assemblies here
rootPaths.Add(Path.Combine(_pluginDir, @"ms.web.admin.refs"));
foreach (var path in rootPaths)

Просмотреть файл

@ -12,7 +12,7 @@ namespace Microsoft.IIS.Administration
/****
This class is not being used.
AspNetCore.Mvc.Formatters.JsonOutputFormatter does not exist anymore. The closest
alternative is NewtonsoftJsonOutputFormatter. There is need to override it since it
alternative is NewtonsoftJsonOutputFormatter. There is no need to override it since it
does not have a CanWriteResult method
****/
class JsonOutputFormatter : AspNetCore.Mvc.Formatters.JsonOutputFormatter

Просмотреть файл

@ -86,8 +86,9 @@ namespace Microsoft.IIS.Administration {
{
o.Cookie.Name = HeaderNames.XSRF_TOKEN;
o.FormFieldName = HeaderNames.XSRF_TOKEN;
// must set header name. The server reads the XSRF token from httpContext.Request.Headers[_options.HeaderName] instead of
// FormFieldName in GetRequestTokensAsync(), DefaultAntiforgeryTokenStore.cs (ASP.Net Core)
// must set o.HeaderName to XSRF_TOKEN. ASP.Net reads the XSRF token from
// Context.Request.Headers[o.HeaderName] instead of o.FormFieldName in GetRequestTokensAsync()
// as in the previous local implementation of AntiForgeryTokenStore.
o.HeaderName = HeaderNames.XSRF_TOKEN;
});