Added the ability to install/uninstall Windows Authentication and Url Authorization now that the IIS Administration API does not depend on them.
This commit is contained in:
Родитель
6636816b4b
Коммит
0d977a3dd1
|
@ -11,7 +11,7 @@ namespace Microsoft.IIS.Administration.WebServer.Authentication
|
|||
using Web.Administration;
|
||||
using Core.Http;
|
||||
using Core;
|
||||
|
||||
using System.Threading.Tasks;
|
||||
|
||||
[RequireWebServer]
|
||||
public class WinAuthController : ApiBaseController
|
||||
|
@ -65,9 +65,24 @@ namespace Microsoft.IIS.Administration.WebServer.Authentication
|
|||
return WindowsAuthenticationHelper.ToJsonModel(site, winAuthId.Path);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Audit]
|
||||
[ResourceInfo(Name = Defines.WindowsAuthenticationName)]
|
||||
public async Task<object> Post()
|
||||
{
|
||||
if (WindowsAuthenticationHelper.IsFeatureEnabled()) {
|
||||
throw new AlreadyExistsException(WindowsAuthenticationHelper.FEATURE_NAME);
|
||||
}
|
||||
|
||||
await WindowsAuthenticationHelper.SetFeatureEnabled(true);
|
||||
|
||||
dynamic auth = WindowsAuthenticationHelper.ToJsonModel(null, null);
|
||||
return Created(WindowsAuthenticationHelper.GetLocation(auth.id), auth);
|
||||
}
|
||||
|
||||
[HttpDelete]
|
||||
[Audit]
|
||||
public void Delete(string id)
|
||||
public async Task Delete(string id)
|
||||
{
|
||||
WinAuthId winAuthId = new WinAuthId(id);
|
||||
|
||||
|
@ -79,6 +94,10 @@ namespace Microsoft.IIS.Administration.WebServer.Authentication
|
|||
WindowsAuthenticationHelper.GetSection(site, winAuthId.Path, ManagementUnit.ResolveConfigScope()).RevertToParent();
|
||||
ManagementUnit.Current.Commit();
|
||||
}
|
||||
|
||||
if (winAuthId.SiteId == null && WindowsAuthenticationHelper.IsFeatureEnabled()) {
|
||||
await WindowsAuthenticationHelper.SetFeatureEnabled(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ namespace Microsoft.IIS.Administration.WebServer.Authorization
|
|||
using Core.Http;
|
||||
using Sites;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using Web.Administration;
|
||||
|
||||
|
||||
|
@ -72,9 +73,24 @@ namespace Microsoft.IIS.Administration.WebServer.Authorization
|
|||
return authorization;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Audit]
|
||||
[ResourceInfo(Name = Defines.AuthorizationName)]
|
||||
public async Task<object> Post()
|
||||
{
|
||||
if (AuthorizationHelper.IsFeatureEnabled()) {
|
||||
throw new AlreadyExistsException(AuthorizationHelper.FEATURE_NAME);
|
||||
}
|
||||
|
||||
await AuthorizationHelper.SetFeatureEnabled(true);
|
||||
|
||||
dynamic auth = AuthorizationHelper.ToJsonModel(null, null);
|
||||
return Created(AuthorizationHelper.GetLocation(auth.id), auth);
|
||||
}
|
||||
|
||||
[HttpDelete]
|
||||
[Audit]
|
||||
public void Delete(string id)
|
||||
public async Task Delete(string id)
|
||||
{
|
||||
AuthorizationId authId = new AuthorizationId(id);
|
||||
|
||||
|
@ -87,6 +103,10 @@ namespace Microsoft.IIS.Administration.WebServer.Authorization
|
|||
section.RevertToParent();
|
||||
ManagementUnit.Current.Commit();
|
||||
}
|
||||
|
||||
if (authId.SiteId == null && AuthorizationHelper.IsFeatureEnabled()) {
|
||||
await AuthorizationHelper.SetFeatureEnabled(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,8 @@ namespace Microsoft.IIS.Administration.Tests
|
|||
//[InlineData("/api/webserver/http-request-tracing")]
|
||||
//[InlineData("/api/webserver/authentication/basic-authentication")]
|
||||
//[InlineData("/api/webserver/authentication/digest-authentication")]
|
||||
//[InlineData("/api/webserver/authentication/windows-authentication")]
|
||||
//[InlineData("/api/webserver/authorization")]
|
||||
//[InlineData("/api/webserver/ip-restrictions")]
|
||||
//[InlineData("/api/webserver/logging")]
|
||||
//[InlineData("/api/webserver/http-request-tracing")]
|
||||
|
|
Загрузка…
Ссылка в новой задаче