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

[ReleasePrep][2017.10.30]RI of dev into master #4928

Merged
merged 17 commits into from
Oct 31, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
f5ab583
Documentation parser and clamp fixes (#4853)
chenriksson Oct 23, 2017
a5115a8
Get rid of obsolete notifications on package details view (#4902)
xavierdecoster Oct 25, 2017
7e72e47
delete owner requests upon package hard delete (#4898)
Oct 25, 2017
5b32ce3
[Prefix] List reserved namespaces in the manage packages page (#4901)
shishirx34 Oct 25, 2017
d28063a
Update number shortener to maintain enough sig figs for distinction. …
ryuyu Oct 26, 2017
42ce453
Schema changes for Organization membership (#4904)
chenriksson Oct 26, 2017
5f88eec
Gallery constraints to prevent Organization authentication (#4915)
chenriksson Oct 26, 2017
4d8c2ec
Fix readme telemetry (#4905)
chenriksson Oct 27, 2017
e359ad6
Add support for building signed&unsigned nugetgallery.core packages (…
skofman1 Oct 27, 2017
0fca0c6
Slightly different way to initialize service bus topic client wrapper…
agr Oct 27, 2017
0366b89
Fix #4814 - do not consider unlisted prerelease versions when showing…
xavierdecoster Oct 27, 2017
e34a93e
Use PackagePermissionsService to determine actions a user can perform…
Oct 27, 2017
367dc1c
Pakage URL generation method and checks whether package file exists (…
agr Oct 30, 2017
7c087cf
Switch Organizations to use TPT inheritance (was fix for Organization…
chenriksson Oct 30, 2017
5c8184f
Add ability to reflow hard-deletes from Admin area (#4899)
Oct 30, 2017
74cd003
Merge pull request #4927 from NuGet/master
loic-sharma Oct 30, 2017
49833af
Fix permission-related renaming issue (#4929)
Oct 30, 2017
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
12 changes: 7 additions & 5 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ param (
[switch]$CleanCache,
[string]$SimpleVersion = '1.0.0',
[string]$SemanticVersion = '1.0.0-zlocal',
[string]$PackageSuffix,
[string]$Branch,
[string]$CommitSHA,
[string]$BuildBranch = '37ff6e758c38b3f513af39f881399ce85f4ff20b'
Expand Down Expand Up @@ -84,12 +85,13 @@ Invoke-BuildStep 'Building solution' {
Build-Solution $Configuration $BuildNumber -MSBuildVersion "15" $SolutionPath -SkipRestore:$SkipRestore -MSBuildProperties "/p:MvcBuildViews=true" `
} `
-ev +BuildErrors

Invoke-BuildStep 'Creating artifacts' {
New-Package (Join-Path $PSScriptRoot "src\NuGetGallery.Core\NuGetGallery.Core.csproj") -Configuration $Configuration -Symbols -BuildNumber $BuildNumber -Version $SemanticVersion `
-ev +BuildErrors
}

Invoke-BuildStep 'Creating artifacts' {
$packageId = 'NuGetGallery.Core'+$PackageSuffix
New-Package (Join-Path $PSScriptRoot "src\NuGetGallery.Core\NuGetGallery.Core.csproj") -Configuration $Configuration -Symbols -BuildNumber $BuildNumber -Version $SemanticVersion -PackageId $packageId `
-ev +BuildErrors
}

Trace-Log ('-' * 60)

## Calculating Build time
Expand Down
15 changes: 15 additions & 0 deletions src/Bootstrap/dist/css/bootstrap-theme.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Bootstrap/less/theme/base.less
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,11 @@ img.package-icon {
margin-right: auto;
}

img.reserved-indicator-icon {
margin-left: auto;
margin-right: auto;
}

.package-list {
margin-top: 8px;
margin-bottom: 8px;
Expand Down
9 changes: 9 additions & 0 deletions src/Bootstrap/less/theme/common-user-package-list.less
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
min-width: 20px;
}

.reserved-indicator-icon {
max-height: 2em;
min-width: 20px;
}

.align-middle {
vertical-align: middle;
}
Expand All @@ -13,6 +18,10 @@
.break-word;
}

.reserved-id {
.break-word;
}

.package-controls {
@media (min-width: @screen-sm-min) {
white-space: nowrap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,10 @@ public enum AuditedAuthenticatedOperationAction
/// Login failed, user exists but password is invalid
/// </summary>
FailedLoginInvalidPassword,

/// <summary>
/// Login failed, user is an organization and should not have credentials.
/// </summary>
FailedLoginUserIsOrganization
}
}
3 changes: 3 additions & 0 deletions src/NuGetGallery.Core/Auditing/AuditedPackageAction.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;

namespace NuGetGallery.Auditing
{
public enum AuditedPackageAction
Expand All @@ -11,6 +13,7 @@ public enum AuditedPackageAction
List,
Unlist,
Edit,
[Obsolete("Undo package edit functionality is being retired.")]
UndoEdit,
Verify
}
Expand Down
24 changes: 23 additions & 1 deletion src/NuGetGallery.Core/Entities/EntitiesContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,14 @@ public EntitiesContext(string connectionString, bool readOnly)
public IDbSet<PackageRegistration> PackageRegistrations { get; set; }
public IDbSet<Credential> Credentials { get; set; }
public IDbSet<Scope> Scopes { get; set; }
public IDbSet<User> Users { get; set; }
public IDbSet<UserSecurityPolicy> UserSecurityPolicies { get; set; }
public IDbSet<ReservedNamespace> ReservedNamespaces { get; set; }

/// <summary>
/// User or organization accounts.
/// </summary>
public IDbSet<User> Users { get; set; }

IDbSet<T> IEntitiesContext.Set<T>()
{
return base.Set<T>();
Expand Down Expand Up @@ -119,6 +123,24 @@ protected override void OnModelCreating(DbModelBuilder modelBuilder)
.MapLeftKey("UserKey")
.MapRightKey("RoleKey"));

modelBuilder.Entity<Organization>()
.ToTable("Organizations");

modelBuilder.Entity<Membership>()
.HasKey(m => new { m.OrganizationKey, m.MemberKey });

modelBuilder.Entity<User>()
.HasMany(u => u.Organizations)
.WithRequired(m => m.Member)
.HasForeignKey(m => m.MemberKey)
.WillCascadeOnDelete(true); // Membership will be deleted with the Member account.

modelBuilder.Entity<Organization>()
.HasMany(o => o.Members)
.WithRequired(m => m.Organization)
.HasForeignKey(m => m.OrganizationKey)
.WillCascadeOnDelete(true); // Memberships will be deleted with the Organization account.

modelBuilder.Entity<Role>()
.HasKey(u => u.Key);

Expand Down
45 changes: 45 additions & 0 deletions src/NuGetGallery.Core/Entities/Membership.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

namespace NuGetGallery
{
/// <summary>
/// Tracks membership of a User account in an Organization account.
/// </summary>
public class Membership
{
/// <summary>
/// Organization foreign key.
/// </summary>
public int OrganizationKey { get; set; }

/// <summary>
/// The <see cref="Organization"/> that contains members.
/// </summary>
public virtual Organization Organization { get; set; }

/// <summary>
/// Member (User) foreign key.
/// </summary>
public int MemberKey { get; set; }

/// <summary>
/// The <see cref="User"/> that is a member of the <see cref="Organization"/>.
///
/// Note that there is no database contraint preventing memberships of Organizations into other
/// Organizations. For now this is restricted by the Gallery, but could be considered in the
/// future if we want to support Organization teams.
/// </summary>
public virtual User Member { get; set; }

/// <summary>
/// Whether the <see cref="Member"/> is an administrator for the <see cref="Organization"/>.
///
/// Administrators have the following capabilities that collaborators don't:
/// - Organization management (e.g., settings, membership)
/// - Package owner management
/// - Pushing new package registrations
/// </summary>
public bool IsAdmin { get; set; }
}
}
31 changes: 31 additions & 0 deletions src/NuGetGallery.Core/Entities/Organization.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System.Collections.Generic;

namespace NuGetGallery
{
/// <summary>
/// Organization <see cref="NuGetGallery.User" /> account, based on TPT hierarchy.
///
/// With the addition of organizations, the users table effectively becomes an account table. Organizations accounts
/// are child types created using TPT inheritance. User accounts are not child types, but this could be done in the
/// future if we want to add constraints for user accounts or user-only settings.
/// </summary>
/// <see href="https://weblogs.asp.net/manavi/inheritance-mapping-strategies-with-entity-framework-code-first-ctp5-part-2-table-per-type-tpt" />
public class Organization : User
{
public Organization() : base()
{
}

public Organization(string name) : base(name)
{
}

/// <summary>
/// Organization Memberships to this organization.
/// </summary>
public virtual ICollection<Membership> Members { get; set; }
}
}
11 changes: 11 additions & 0 deletions src/NuGetGallery.Core/Entities/User.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@

namespace NuGetGallery
{
/// <summary>
/// With the addition of organizations, the users table effectively becomes an account table. Organizations accounts
/// are child types created using TPT inheritance. User accounts are not child types, but this could be done in the
/// future if we want to add constraints for user accounts or user-only settings.
/// </summary>
/// <see href="https://weblogs.asp.net/manavi/inheritance-mapping-strategies-with-entity-framework-code-first-ctp5-part-2-table-per-type-tpt" />
public class User : IEntity
{
public User() : this(null)
Expand All @@ -24,6 +30,11 @@ public User(string username)
Username = username;
}

/// <summary>
/// Organization memberships for a non-organization <see cref="User"/> account.
/// </summary>
public virtual ICollection<Membership> Organizations { get; set; }

[StringLength(256)]
public string EmailAddress { get; set; }

Expand Down
2 changes: 2 additions & 0 deletions src/NuGetGallery.Core/NuGetGallery.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@
<Compile Include="Entities\Credential.cs" />
<Compile Include="Entities\CuratedFeed.cs" />
<Compile Include="Entities\CuratedPackage.cs" />
<Compile Include="Entities\Membership.cs" />
<Compile Include="Entities\Organization.cs" />
<Compile Include="Entities\PackageDelete.cs" />
<Compile Include="Entities\EmailMessage.cs" />
<Compile Include="Entities\EntitiesConfiguration.cs" />
Expand Down
2 changes: 1 addition & 1 deletion src/NuGetGallery.Core/NuGetGallery.Core.nuspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<package >
<metadata>
<id>$id$</id>
<id>$PackageId$</id>
<version>$version$</version>
<title>$title$</title>
<authors>$author$</authors>
Expand Down
18 changes: 18 additions & 0 deletions src/NuGetGallery.Core/Services/CorePackageFileService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,18 @@ public Task<Stream> DownloadPackageFileAsync(Package package)
return _fileStorageService.GetFileAsync(CoreConstants.PackagesFolderName, fileName);
}

public Task<Uri> GetPackageReadUriAsync(Package package)
{
var fileName = BuildFileName(package, CoreConstants.PackageFileSavePathTemplate, CoreConstants.NuGetPackageFileExtension);
return _fileStorageService.GetFileReadUriAsync(CoreConstants.PackagesFolderName, fileName, endOfAccess: null);
}

public Task<bool> DoesPackageFileExistAsync(Package package)
{
var fileName = BuildFileName(package, CoreConstants.PackageFileSavePathTemplate, CoreConstants.NuGetPackageFileExtension);
return _fileStorageService.FileExistsAsync(CoreConstants.PackagesFolderName, fileName);
}

public Task SaveValidationPackageFileAsync(Package package, Stream packageFile)
{
if (packageFile == null)
Expand Down Expand Up @@ -110,6 +122,12 @@ public Task<Uri> GetValidationPackageReadUriAsync(Package package, DateTimeOffse
return _fileStorageService.GetFileReadUriAsync(CoreConstants.ValidationFolderName, fileName, endOfAccess);
}

public Task<bool> DoesValidationPackageFileExistAsync(Package package)
{
var fileName = BuildFileName(package, CoreConstants.PackageFileSavePathTemplate, CoreConstants.NuGetPackageFileExtension);
return _fileStorageService.FileExistsAsync(CoreConstants.ValidationFolderName, fileName);
}

protected static string BuildFileName(Package package, string format, string extension)
{
if (package == null)
Expand Down
25 changes: 25 additions & 0 deletions src/NuGetGallery.Core/Services/ICorePackageFileService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,24 @@ public interface ICorePackageFileService
/// </summary>
Task<Stream> DownloadPackageFileAsync(Package package);

/// <summary>
/// Generates the URL for the specified package in the public container for available packages.
/// </summary>
/// <param name="package">The package metadata.</param>
/// <returns>Package download URL</returns>
/// <remarks>
/// The returned URL is only intended to be used by the internal tooling and not for the user:
/// it might not make any sense to external users as it can be, for example, a file:/// URL.
/// </remarks>
Task<Uri> GetPackageReadUriAsync(Package package);

/// <summary>
/// Checks whether package file exists in the public container for available packages
/// </summary>
/// <param name="">The package metadata</param>
/// <returns>True if file exists, false otherwise</returns>
Task<bool> DoesPackageFileExistAsync(Package package);

/// <summary>
/// Saves the contents of the package to the private container for packages that are being validated. If the
/// file already exists, an exception will be thrown.
Expand All @@ -42,6 +60,13 @@ public interface ICorePackageFileService
/// <returns>Time limited (if implementation supports) URI for the validation package</returns>
Task<Uri> GetValidationPackageReadUriAsync(Package package, DateTimeOffset endOfAccess);

/// <summary>
/// Checks whether package file exists in the private validation container
/// </summary>
/// <param name="">The package metadata</param>
/// <returns>True if file exists, false otherwise</returns>
Task<bool> DoesValidationPackageFileExistAsync(Package package);

/// <summary>
/// Deletes the validating package from the file storage. If the file does not exist this method will not throw
/// any exception.
Expand Down
3 changes: 2 additions & 1 deletion src/NuGetGallery/App_Start/AppActivator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,8 @@ private static void BundlingPostStart()
BundleTable.Bundles.Add(homeScriptBundle);

var displayPackageScriptBundle = new ScriptBundle("~/Scripts/gallery/page-display-package.min.js")
.Include("~/Scripts/gallery/page-display-package.js");
.Include("~/Scripts/gallery/page-display-package.js")
.Include("~/Scripts/gallery/clamp.js");
BundleTable.Bundles.Add(displayPackageScriptBundle);

var managePackagesScriptBundle = new ScriptBundle("~/Scripts/gallery/page-manage-packages.min.js")
Expand Down
Loading