Skip to content

Commit 9f578da

Browse files
Merge pull request #6859 from NuGet/dev
[ReleasePrep][2019.01.28]RI of dev into master for NuGetGallery
2 parents 7a0ed71 + f87f32b commit 9f578da

156 files changed

Lines changed: 6405 additions & 1916 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

NuGetGallery.sln

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "4. Tools", "4. Tools", "{22
2828
EndProject
2929
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GalleryTools", "src\GalleryTools\GalleryTools.csproj", "{C5849063-8CDC-4561-BA5C-7D97BD905DC3}"
3030
EndProject
31+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NuGet.Services.Entities", "src\NuGet.Services.Entities\NuGet.Services.Entities.csproj", "{6262F4FC-29BE-4226-B676-DB391C89D396}"
32+
EndProject
33+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NuGet.Services.Entities.Tests", "tests\NuGet.Services.Entities.Tests\NuGet.Services.Entities.Tests.csproj", "{79C831E9-7C88-4B98-B084-4DE940C73FC7}"
34+
EndProject
3135
Global
3236
GlobalSection(SolutionConfigurationPlatforms) = preSolution
3337
Debug|Any CPU = Debug|Any CPU
@@ -58,6 +62,14 @@ Global
5862
{C5849063-8CDC-4561-BA5C-7D97BD905DC3}.Debug|Any CPU.Build.0 = Debug|Any CPU
5963
{C5849063-8CDC-4561-BA5C-7D97BD905DC3}.Release|Any CPU.ActiveCfg = Release|Any CPU
6064
{C5849063-8CDC-4561-BA5C-7D97BD905DC3}.Release|Any CPU.Build.0 = Release|Any CPU
65+
{6262F4FC-29BE-4226-B676-DB391C89D396}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
66+
{6262F4FC-29BE-4226-B676-DB391C89D396}.Debug|Any CPU.Build.0 = Debug|Any CPU
67+
{6262F4FC-29BE-4226-B676-DB391C89D396}.Release|Any CPU.ActiveCfg = Release|Any CPU
68+
{6262F4FC-29BE-4226-B676-DB391C89D396}.Release|Any CPU.Build.0 = Release|Any CPU
69+
{79C831E9-7C88-4B98-B084-4DE940C73FC7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
70+
{79C831E9-7C88-4B98-B084-4DE940C73FC7}.Debug|Any CPU.Build.0 = Debug|Any CPU
71+
{79C831E9-7C88-4B98-B084-4DE940C73FC7}.Release|Any CPU.ActiveCfg = Release|Any CPU
72+
{79C831E9-7C88-4B98-B084-4DE940C73FC7}.Release|Any CPU.Build.0 = Release|Any CPU
6173
EndGlobalSection
6274
GlobalSection(SolutionProperties) = preSolution
6375
HideSolutionNode = FALSE
@@ -69,6 +81,8 @@ Global
6981
{8AC9E39E-366C-47E5-80AE-38E71CD31386} = {39E54EC3-CBAA-453A-BE64-748FE1559A58}
7082
{6931C2EE-E081-4518-9798-D34D83B35BF6} = {05998089-58F5-4A84-8C11-C5C6244A6F89}
7183
{C5849063-8CDC-4561-BA5C-7D97BD905DC3} = {2204C510-A559-4ED7-9590-FDC09093575B}
84+
{6262F4FC-29BE-4226-B676-DB391C89D396} = {155100FF-524B-4CAF-93C6-A57478B3DBAD}
85+
{79C831E9-7C88-4B98-B084-4DE940C73FC7} = {39E54EC3-CBAA-453A-BE64-748FE1559A58}
7286
EndGlobalSection
7387
GlobalSection(ExtensibilityGlobals) = postSolution
7488
SolutionGuid = {064A3BDE-5203-4AD6-A6C9-5CF08301EC8F}

build.ps1

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -76,27 +76,28 @@ Invoke-BuildStep 'Restoring solution packages' { `
7676
-ev +BuildErrors
7777

7878
Invoke-BuildStep 'Set version metadata in AssemblyInfo.cs' {
79-
$Paths = `
80-
(Join-Path $PSScriptRoot "src\NuGetGallery\Properties\AssemblyInfo.g.cs"), `
81-
(Join-Path $PSScriptRoot "src\NuGetGallery.Core\Properties\AssemblyInfo.g.cs")
82-
83-
Foreach ($Path in $Paths) {
84-
Set-VersionInfo -Path $Path -Version $SimpleVersion -Branch $Branch -Commit $CommitSHA
85-
}
86-
} `
87-
-ev +BuildErrors
79+
$Paths = `
80+
(Join-Path $PSScriptRoot "src\NuGetGallery\Properties\AssemblyInfo.g.cs"), `
81+
(Join-Path $PSScriptRoot "src\NuGetGallery.Core\Properties\AssemblyInfo.g.cs"), `
82+
(Join-Path $PSScriptRoot "src\NuGet.Services.Entities\Properties\AssemblyInfo.g.cs")
8883

89-
Invoke-BuildStep 'Building solution' {
90-
$SolutionPath = Join-Path $PSScriptRoot "NuGetGallery.sln"
91-
Build-Solution $Configuration $BuildNumber -MSBuildVersion "15" $SolutionPath -SkipRestore:$SkipRestore -MSBuildProperties "/p:MvcBuildViews=true" `
92-
} `
93-
-ev +BuildErrors
84+
Foreach ($Path in $Paths) {
85+
Set-VersionInfo -Path $Path -Version $SimpleVersion -Branch $Branch -Commit $CommitSHA
86+
}
87+
} `
88+
-ev +BuildErrors
9489

95-
Invoke-BuildStep 'Creating artifacts' {
96-
$packageId = 'NuGetGallery.Core'+$PackageSuffix
97-
New-ProjectPackage (Join-Path $PSScriptRoot "src\NuGetGallery.Core\NuGetGallery.Core.csproj") -Configuration $Configuration -Symbols -BuildNumber $BuildNumber -Version $SemanticVersion -PackageId $packageId `
98-
-ev +BuildErrors
99-
}
90+
Invoke-BuildStep 'Building solution' {
91+
$SolutionPath = Join-Path $PSScriptRoot "NuGetGallery.sln"
92+
Build-Solution $Configuration $BuildNumber -MSBuildVersion "15" $SolutionPath -SkipRestore:$SkipRestore -MSBuildProperties "/p:MvcBuildViews=true" `
93+
} `
94+
-ev +BuildErrors
95+
96+
Invoke-BuildStep 'Creating artifacts' { `
97+
New-ProjectPackage (Join-Path $PSScriptRoot "src\NuGetGallery.Core\NuGetGallery.Core.csproj") -Configuration $Configuration -Symbols -BuildNumber $BuildNumber -Version $SemanticVersion -PackageId "NuGetGallery.Core$PackageSuffix"
98+
New-ProjectPackage (Join-Path $PSScriptRoot "src\NuGet.Services.Entities\NuGet.Services.Entities.csproj") -Configuration $Configuration -Symbols -BuildNumber $BuildNumber -Version $SemanticVersion
99+
} `
100+
-ev +BuildErrors
100101

101102
Trace-Log ('-' * 60)
102103

src/Bootstrap/dist/css/bootstrap-theme.css

Lines changed: 17 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Bootstrap/less/theme/common-list-packages.less

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020
width: 20px;
2121
}
2222

23+
.edit-button {
24+
vertical-align: text-bottom;
25+
margin-left: 10px;
26+
}
27+
2328
.package-by {
2429
margin-left: @padding-small-horizontal;
2530
color: @text-color;

src/Bootstrap/less/theme/page-delete-package.less

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
.page-delete-package {
2-
h1 {
3-
margin-bottom: 0;
2+
b {
3+
margin-top: 40px;
4+
margin-bottom: 15px;
5+
display: inline-block;
46
}
57

68
#show-delete-package {

src/Bootstrap/less/theme/page-edit-package.less

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
.page-edit-package {
2+
.readme-tabs {
3+
margin-top: 40px;
4+
}
5+
26
.readonly {
37
display: none;
48
}

src/Bootstrap/less/theme/page-manage-owners.less

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,12 @@
11
.page-manage-owners {
2-
h2 {
3-
.ms-Icon {
4-
font-size: 0.6em;
5-
position: relative;
6-
top: -2px;
7-
}
8-
9-
a {
10-
color: @text-color;
11-
text-decoration: none;
12-
}
2+
b {
3+
margin-top: 40px;
4+
margin-bottom: 15px;
5+
display: inline-block;
6+
}
137

14-
a:hover {
15-
text-decoration: none;
16-
}
8+
b:first-of-type {
9+
margin-top: 0;
1710
}
1811

1912
.current-owner {
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
// Copyright (c) .NET Foundation. All rights reserved.
2+
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3+
4+
using System;
5+
using System.Collections.Generic;
6+
using System.IO;
7+
using System.Linq;
8+
using System.Threading.Tasks;
9+
using Autofac;
10+
using Microsoft.Extensions.CommandLineUtils;
11+
using NuGet.Services.Entities;
12+
using NuGetGallery;
13+
using NuGetGallery.Security;
14+
15+
namespace GalleryTools.Commands
16+
{
17+
public static class ApplyTenantPolicyCommand
18+
{
19+
private const string UserListOption = "--path";
20+
private const string TenantIdOption = "--tenant";
21+
22+
public static void Configure(CommandLineApplication config)
23+
{
24+
config.Description = "Apply organization tenant policy";
25+
config.HelpOption("-? | -h | --help");
26+
27+
var userListOption = config.Option(
28+
$"-p | {UserListOption}",
29+
"A path to a list of organizations, one username per line.",
30+
CommandOptionType.SingleValue);
31+
32+
var tenantIdOption = config.Option(
33+
$"-t | {TenantIdOption}",
34+
"The tenant ID to restrict membership of each organization on the list to.",
35+
CommandOptionType.SingleValue);
36+
37+
config.OnExecute(() =>
38+
{
39+
return ExecuteAsync(userListOption, tenantIdOption).GetAwaiter().GetResult();
40+
});
41+
}
42+
43+
private static async Task<int> ExecuteAsync(
44+
CommandOption userListOption,
45+
CommandOption tenantIdOption)
46+
{
47+
if (!userListOption.HasValue())
48+
{
49+
Console.WriteLine($"The '{UserListOption}' parameter is required.");
50+
return 1;
51+
}
52+
53+
if (!tenantIdOption.HasValue())
54+
{
55+
Console.WriteLine($"The '{TenantIdOption}' parameter is required.");
56+
return 1;
57+
}
58+
59+
var builder = new ContainerBuilder();
60+
builder.RegisterAssemblyModules(typeof(DefaultDependenciesModule).Assembly);
61+
var container = builder.Build();
62+
var securityPolicyService = container.Resolve<SecurityPolicyService>();
63+
var userService = container.Resolve<UserService>();
64+
65+
var userListPath = userListOption.Value();
66+
Console.WriteLine($"Reading user list from {userListPath}");
67+
var usernames = ReadUserList(userListPath);
68+
Console.WriteLine($"Finished reading user list. Found {usernames.Count()} users");
69+
70+
var tenantId = tenantIdOption.Value();
71+
Console.WriteLine($"Restricting organization membership to tenant ID {tenantId}");
72+
73+
foreach (var username in usernames)
74+
{
75+
var user = userService.FindByUsername(username);
76+
if (user == null)
77+
{
78+
Console.WriteLine($"Could not find user with name {username}... skipping");
79+
continue;
80+
}
81+
82+
var organization = user as Organization;
83+
if (organization == null)
84+
{
85+
Console.WriteLine($"User with name {username} is not an organization...skipping");
86+
continue;
87+
}
88+
89+
Console.WriteLine($"Applying AAD tenant policy to organization with name {username}");
90+
try
91+
{
92+
var tenantPolicy = RequireOrganizationTenantPolicy.Create(tenantId);
93+
if (await securityPolicyService.SubscribeAsync(organization, tenantPolicy))
94+
{
95+
Console.WriteLine($"Successfully applied AAD tenant policy to organization with name {username}");
96+
}
97+
else
98+
{
99+
Console.WriteLine($"Organization with name {username} already has AAD tenant policy.");
100+
}
101+
}
102+
catch (Exception e)
103+
{
104+
Console.WriteLine($"Failed to apply AAD tenant policy to organization with name {username}: {e}");
105+
}
106+
}
107+
108+
return 0;
109+
}
110+
111+
private static IEnumerable<string> ReadUserList(string path)
112+
{
113+
var usernames = new HashSet<string>();
114+
using (var fileStream = new FileStream(path, FileMode.Open, FileAccess.Read))
115+
using (var reader = new StreamReader(fileStream))
116+
{
117+
string line;
118+
while ((line = reader.ReadLine()) != null)
119+
{
120+
if (usernames.Add(line))
121+
{
122+
// Each username in the list should be distinct, but we should also respect the ordering of the file.
123+
yield return line;
124+
}
125+
}
126+
}
127+
}
128+
}
129+
}

src/GalleryTools/Commands/ReflowCommand.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ public static class ReflowCommand
1818
{
1919
private const int DefaultBatch = 1;
2020
private const int DefaultSleepMultiplier = 60;
21-
private const string PackageListShortOption = "-p";
21+
private const string PackageListOption = "--path";
2222

2323
public static void Configure(CommandLineApplication config)
2424
{
2525
config.Description = "Bulk reflow many packages";
2626
config.HelpOption("-? | -h | --help");
2727

2828
var packageListOption = config.Option(
29-
$"{PackageListShortOption} | --path",
29+
$"-p | {PackageListOption}",
3030
"A path to a list of packages, one ID and version per line with a space in between.",
3131
CommandOptionType.SingleValue);
3232

@@ -53,7 +53,7 @@ private static async Task<int> ExecuteAsync(
5353
{
5454
if (!packageListOption.HasValue())
5555
{
56-
Console.WriteLine($"The '{PackageListShortOption}' parameter is required.");
56+
Console.WriteLine($"The '{PackageListOption}' parameter is required.");
5757
return 1;
5858
}
5959

src/GalleryTools/GalleryTools.csproj

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@
4040
<Reference Include="System.Data.DataSetExtensions" />
4141
<Reference Include="Microsoft.CSharp" />
4242
<Reference Include="System.Data" />
43-
<Reference Include="System.Net.Http" />
4443
<Reference Include="System.Xml" />
4544
</ItemGroup>
4645
<ItemGroup>
4746
<Compile Include="Commands\BackfillRepositoryMetadataCommand.cs" />
4847
<Compile Include="Commands\HashCommand.cs" />
48+
<Compile Include="Commands\ApplyTenantPolicyCommand.cs" />
4949
<Compile Include="Commands\ReflowCommand.cs" />
5050
<Compile Include="Commands\UpdateIsLatestCommand.cs" />
5151
<Compile Include="Commands\VerifyApiKeyCommand.cs" />
@@ -60,6 +60,10 @@
6060
<Project>{6931C2EE-E081-4518-9798-D34D83B35BF6}</Project>
6161
<Name>NuGet.Services.Search.Client</Name>
6262
</ProjectReference>
63+
<ProjectReference Include="..\NuGet.Services.Entities\NuGet.Services.Entities.csproj">
64+
<Project>{6262f4fc-29be-4226-b676-db391c89d396}</Project>
65+
<Name>NuGet.Services.Entities</Name>
66+
</ProjectReference>
6367
<ProjectReference Include="..\NuGetGallery.Core\NuGetGallery.Core.csproj">
6468
<Project>{097b2cdd-9623-4c34-93c2-d373d51f5b4e}</Project>
6569
<Name>NuGetGallery.Core</Name>

0 commit comments

Comments
 (0)