-
Notifications
You must be signed in to change notification settings - Fork 644
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5898 from NuGet/dev
Dev to Master
- Loading branch information
Showing
33 changed files
with
382 additions
and
198 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
src/NuGetGallery/App_Data/Files/Content/Certificates-Configuration.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"isUIEnabledByDefault": false, | ||
"alwaysEnabledForDomains": [ | ||
], | ||
"alwaysEnabledForEmailAddresses": [ | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// 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; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Newtonsoft.Json; | ||
|
||
namespace NuGetGallery.Services | ||
{ | ||
public sealed class CertificatesConfiguration : ICertificatesConfiguration | ||
{ | ||
public bool IsUIEnabledByDefault { get; } | ||
public HashSet<string> AlwaysEnabledForEmailAddresses { get; } | ||
public HashSet<string> AlwaysEnabledForDomains { get; } | ||
|
||
public CertificatesConfiguration() | ||
: this(isUIEnabledByDefault: false, | ||
alwaysEnabledForDomains: Enumerable.Empty<string>(), | ||
alwaysEnabledForEmailAddresses: Enumerable.Empty<string>()) | ||
{ | ||
} | ||
|
||
[JsonConstructor] | ||
public CertificatesConfiguration( | ||
bool isUIEnabledByDefault, | ||
IEnumerable<string> alwaysEnabledForDomains, | ||
IEnumerable<string> alwaysEnabledForEmailAddresses) | ||
{ | ||
if (alwaysEnabledForDomains == null) | ||
{ | ||
throw new ArgumentNullException(nameof(alwaysEnabledForDomains)); | ||
} | ||
|
||
if (alwaysEnabledForEmailAddresses == null) | ||
{ | ||
throw new ArgumentNullException(nameof(alwaysEnabledForEmailAddresses)); | ||
} | ||
|
||
IsUIEnabledByDefault = isUIEnabledByDefault; | ||
AlwaysEnabledForDomains = new HashSet<string>(alwaysEnabledForDomains, StringComparer.OrdinalIgnoreCase); | ||
AlwaysEnabledForEmailAddresses = new HashSet<string>(alwaysEnabledForEmailAddresses, StringComparer.OrdinalIgnoreCase); | ||
} | ||
|
||
public bool IsUIEnabledForUser(User user) | ||
{ | ||
if (user == null) | ||
{ | ||
return false; | ||
} | ||
|
||
var email = user.ToMailAddress(); | ||
|
||
return IsUIEnabledByDefault || | ||
AlwaysEnabledForDomains.Contains(email.Host) || | ||
AlwaysEnabledForEmailAddresses.Contains(email.Address); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// 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.Services | ||
{ | ||
public interface ICertificatesConfiguration | ||
{ | ||
bool IsUIEnabledForUser(User user); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.