Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Appended allowRemoteCacheManagement key into web.config to allow remote cache management (clear cache). #59

Merged
merged 18 commits into from
Sep 4, 2018
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/NuGet.Server/Controllers/PackagesODataController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ protected PackagesODataController(IServiceResolver serviceResolver)
// Exposed through ordinary Web API route. Bypasses OData pipeline.
public async Task<HttpResponseMessage> ClearCache(CancellationToken token)
{
if (RequestContext.IsLocal)
if (RequestContext.IsLocal || ServiceResolver.Current.Resolve<ISettingsProvider>().GetBoolSetting("allowRemoteCacheManagement", false))
{
await _serverRepository.ClearCacheAsync(token);
return CreateStringResponse(HttpStatusCode.OK, "Server cache has been cleared.");
Expand Down
5 changes: 5 additions & 0 deletions src/NuGet.Server/Core/DefaultServiceResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ public object Resolve(Type type)
return _packageAuthenticationService;
}

if (type == typeof(ISettingsProvider))
{
return _settingsProvider;
}

return null;
}

Expand Down
2 changes: 1 addition & 1 deletion src/NuGet.Server/Default.aspx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<% } %>
</fieldset>

<% if (Request.IsLocal) { %>
<% if (Request.IsLocal || ServiceResolver.Current.Resolve<NuGet.Server.Core.Infrastructure.ISettingsProvider>().GetBoolSetting("allowRemoteCacheManagement", false)) { %>
<fieldset style="width:800px">
<legend><strong>Adding packages</strong></legend>

Expand Down
11 changes: 1 addition & 10 deletions src/NuGet.Server/NuGet.Server.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -174,16 +174,7 @@
<VisualStudio>
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
<WebProjectProperties>
<UseIIS>True</UseIIS>
<AutoAssignPort>True</AutoAssignPort>
<DevelopmentServerPort>1425</DevelopmentServerPort>
<DevelopmentServerVPath>/</DevelopmentServerVPath>
<IISUrl>http://localhost:40221/</IISUrl>
<NTLMAuthentication>False</NTLMAuthentication>
<UseCustomServer>False</UseCustomServer>
<CustomServerUrl>
</CustomServerUrl>
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
<SaveServerSettingsInUserFile>True</SaveServerSettingsInUserFile>
</WebProjectProperties>
</FlavorProperties>
</VisualStudio>
Expand Down
2 changes: 2 additions & 0 deletions src/NuGet.Server/Web.config
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@
on a fixed 1-hour interval.
-->
<add key="enableFileSystemMonitoring" value="true" />
<!--Set allowRemoteCacheManagement to true to enable the "clear cache" and other cache operations initiated via requests originating from remote hosts.-->
<add key="allowRemoteCacheManagement" value="true" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would set default to false, to match the default in code and existing behavior.

</appSettings>
<!--
For a description of web.config changes see http://go.microsoft.com/fwlink/?LinkId=235367.
Expand Down