Skip to content

Commit c1ccf24

Browse files
authored
Merge pull request #9345 from NuGet/dev
[ReleasePrep][2023.01.01]RI of dev into main
2 parents f3d98cf + ced00b4 commit c1ccf24

24 files changed

Lines changed: 136 additions & 56 deletions

File tree

.github/ISSUE_TEMPLATE/NUGETORG_ISSUE.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ body:
1010
1111
The more detail you provide, the more likely it will be for us to be able to identify what is going on and how to solve it!
1212
13-
### For issues connecting to NuGet.org, please refer to [this guide](https://docs.microsoft.com/en-us/nuget/nuget-org/nuget-org-faq#nuget.org-not-accessible).
13+
### For issues connecting to NuGet.org, please refer to [this guide](https://docs.microsoft.com/nuget/nuget-org/nuget-org-faq#nuget.org-not-accessible).
1414
15-
### For issues regarding your NuGet.org account, please refer to [this guide](https://docs.microsoft.com/en-us/nuget/nuget-org/nuget-org-faq#nuget.org-account-management).
15+
### For issues regarding your NuGet.org account, please refer to [this guide](https://docs.microsoft.com/nuget/nuget-org/nuget-org-faq#nuget.org-account-management).
1616
- type: dropdown
1717
id: impact
1818
attributes:

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,26 @@ Now run the NuGet Gallery:
2727
Refer to [our documentation](./docs/) for information on how to develop the frontend, use AAD, and more.
2828

2929
## Deploy
30+
### Deploy to Azure
3031

3132
You will find instructions on how to deploy the Gallery to Azure [here](https://github.com/NuGet/NuGetGallery/blob/master/docs/Deploying/README.md).
3233

34+
### Deploy locally
35+
After you succeed in running the NuGet Gallery, you can create a publish profile to deploy locally (such as your local Windows computer).
36+
37+
The steps are:
38+
1. Select the `NuGetGallery` project in Solution Explore of Visual Studio.
39+
2. Right click the project, and then click `Publish` in the pop-up menu. Create a publish profile and make sure the Target is set to `Folder`.
40+
3. Copy the contents of the `Target Location` to any folder you want. For the following example, assume the folder is `C:\ContosoSoftware\NuGetGallery`.
41+
4. Execute the command below to start the web app (note that the parameter `/path` of iisexpress.exe only supports absolute paths on Windows).
42+
```cmd
43+
"C:\Program Files\IIS Express\iisexpress.exe" /path:C:\ContosoSoftware\NuGetGallery
44+
```
45+
46+
Now you can access the local website with a web browser. The URL is `https://localhost`.
47+
48+
After you deploy it, you don't need using Visual Studio to run it anymore.
49+
3350
## Contribute
3451
3552
If you find a bug with the gallery, please visit the [Issue tracker](https://github.com/NuGet/NuGetGallery/issues) and

src/NuGetGallery.Core/Frameworks/SupportedFrameworks.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public static class SupportedFrameworks
2525
public static readonly NuGetFramework MonoTouch = new NuGetFramework(FrameworkIdentifiers.MonoTouch, EmptyVersion);
2626
public static readonly NuGetFramework MonoMac = new NuGetFramework(FrameworkIdentifiers.MonoMac, EmptyVersion);
2727
public static readonly NuGetFramework Net48 = new NuGetFramework(FrameworkIdentifiers.Net, new Version(4, 8, 0, 0));
28+
public static readonly NuGetFramework Net481 = new NuGetFramework(FrameworkIdentifiers.Net, new Version(4, 8, 1, 0));
2829
public static readonly NuGetFramework Net50Windows = new NuGetFramework(FrameworkIdentifiers.NetCoreApp, Version5, "windows", EmptyVersion);
2930
public static readonly NuGetFramework Net60Android = new NuGetFramework(FrameworkIdentifiers.NetCoreApp, Version6, "android", EmptyVersion);
3031
public static readonly NuGetFramework Net60Ios = new NuGetFramework(FrameworkIdentifiers.NetCoreApp, Version6, "ios", EmptyVersion);
@@ -57,7 +58,7 @@ static SupportedFrameworks()
5758
{
5859
MonoAndroid, MonoMac, MonoTouch,
5960
Native,
60-
Net11, Net2, Net35, Net4, Net403, Net45, Net451, Net452, Net46, Net461, Net462, Net463, Net47, Net471, Net472, Net48,
61+
Net11, Net2, Net35, Net4, Net403, Net45, Net451, Net452, Net46, Net461, Net462, Net463, Net47, Net471, Net472, Net48, Net481,
6162
Net50, Net50Windows,
6263
Net60, Net60Android, Net60Ios, Net60MacCatalyst, Net60MacOs, Net60TvOs, Net60Windows,
6364
Net70, Net70Android, Net70Ios, Net70MacCatalyst, Net70MacOs, Net70TvOs, Net70Windows,

src/NuGetGallery.Services/Authentication/AuthenticationService.cs

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,9 @@ public virtual async Task ReplaceCredential(User user, Credential credential)
473473
{
474474
await ReplaceCredentialInternal(user, credential);
475475
await Entities.SaveChangesAsync();
476+
477+
await Auditing.SaveAuditRecordAsync(new UserAuditRecord(
478+
user, AuditedUserAction.AddCredential, credential));
476479
}
477480

478481
public virtual async Task<Credential> ResetPasswordWithToken(string username, string token, string newPassword)
@@ -501,6 +504,10 @@ public virtual async Task<Credential> ResetPasswordWithToken(string username, st
501504
user.FailedLoginCount = 0;
502505
user.LastFailedLoginUtc = null;
503506
await Entities.SaveChangesAsync();
507+
508+
await Auditing.SaveAuditRecordAsync(new UserAuditRecord(
509+
user, AuditedUserAction.AddCredential, cred));
510+
504511
return cred;
505512
}
506513

@@ -590,6 +597,10 @@ public virtual async Task<bool> ChangePassword(User user, string oldPassword, st
590597

591598
// Save changes
592599
await Entities.SaveChangesAsync();
600+
601+
await Auditing.SaveAuditRecordAsync(new UserAuditRecord(
602+
user, AuditedUserAction.AddCredential, passwordCredential));
603+
593604
return true;
594605
}
595606

@@ -623,10 +634,10 @@ public virtual async Task AddCredential(User user, Credential credential)
623634
throw new InvalidOperationException(ServicesStrings.OrganizationsCannotCreateCredentials);
624635
}
625636

626-
await Auditing.SaveAuditRecordAsync(new UserAuditRecord(user, AuditedUserAction.AddCredential, credential));
627637
user.Credentials.Add(credential);
628638
await Entities.SaveChangesAsync();
629639

640+
await Auditing.SaveAuditRecordAsync(new UserAuditRecord(user, AuditedUserAction.AddCredential, credential));
630641
_telemetryService.TrackNewCredentialCreated(user, credential);
631642
}
632643

@@ -838,9 +849,6 @@ await Auditing.SaveAuditRecordAsync(new UserAuditRecord(
838849
}
839850

840851
user.Credentials.Add(credential);
841-
842-
await Auditing.SaveAuditRecordAsync(new UserAuditRecord(
843-
user, AuditedUserAction.AddCredential, credential));
844852
}
845853

846854
private static CredentialKind GetCredentialKind(string type)
@@ -1024,15 +1032,20 @@ private async Task MigrateCredentials(User user, List<Credential> creds, string
10241032
await Auditing.SaveAuditRecordAsync(new UserAuditRecord(user, AuditedUserAction.RemoveCredential, toRemove));
10251033

10261034
// Now add one if there are no credentials left
1035+
Credential newCred = null;
10271036
if (creds.Count == 0)
10281037
{
1029-
var newCred = _credentialBuilder.CreatePasswordCredential(password);
1030-
await Auditing.SaveAuditRecordAsync(new UserAuditRecord(user, AuditedUserAction.AddCredential, newCred));
1038+
newCred = _credentialBuilder.CreatePasswordCredential(password);
10311039
user.Credentials.Add(newCred);
10321040
}
10331041

10341042
// Save changes, if any
10351043
await Entities.SaveChangesAsync();
1044+
1045+
if (newCred != null)
1046+
{
1047+
await Auditing.SaveAuditRecordAsync(new UserAuditRecord(user, AuditedUserAction.AddCredential, newCred));
1048+
}
10361049
}
10371050
}
10381051
}

src/NuGetGallery.Services/Authentication/Providers/AzureActiveDirectoryV2/AzureActiveDirectoryV2Authenticator.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,13 @@ protected override void AttachToOwinApp(IGalleryConfigurationService config, IAp
101101
RedirectUri = siteRoot + _callbackPath,
102102
PostLogoutRedirectUri = siteRoot,
103103
Scope = OpenIdConnectScope.OpenIdProfile + " email",
104-
ResponseType = OpenIdConnectResponseType.CodeIdToken,
104+
ResponseType = OpenIdConnectResponseType.IdToken,
105105
TokenValidationParameters = new Microsoft.IdentityModel.Tokens.TokenValidationParameters() { ValidateIssuer = false },
106106
Notifications = new OpenIdConnectAuthenticationNotifications
107107
{
108108
AuthenticationFailed = AuthenticationFailed,
109-
RedirectToIdentityProvider = RedirectToIdentityProvider
109+
RedirectToIdentityProvider = RedirectToIdentityProvider,
110+
AuthorizationCodeReceived = AuthorizationCodeReceived,
110111
}
111112
};
112113

@@ -257,7 +258,7 @@ private Task RedirectToIdentityProvider(RedirectToIdentityProviderNotification<O
257258
// Set the redirect_uri token for the alternate domains of same gallery instance
258259
if (_alternateSiteRootList != null && _alternateSiteRootList.Contains(notification.Request.Uri.Host))
259260
{
260-
notification.ProtocolMessage.RedirectUri = "https://" + notification.Request.Uri.Host + "/" + _callbackPath ;
261+
notification.ProtocolMessage.RedirectUri = "https://" + notification.Request.Uri.Host + "/" + _callbackPath;
261262
}
262263

263264
// We always want to show the options to select account when signing in and while changing account.
@@ -271,5 +272,13 @@ private AuthenticationProperties GetAuthenticationPropertiesFromProtocolMessage(
271272
var authenticationPropertiesEncodedString = message.State.Split('=');
272273
return options.StateDataFormat.Unprotect(authenticationPropertiesEncodedString[1]);
273274
}
275+
276+
private Task AuthorizationCodeReceived(AuthorizationCodeReceivedNotification context)
277+
{
278+
// Explicitly set the access_token to null. The access_token is used for authorized requests to AAD on
279+
// behalf of the end user. We do not use this feature. We only use the id_token.
280+
context.HandleCodeRedemption(accessToken: null, idToken: context.JwtSecurityToken.RawData);
281+
return Task.CompletedTask;
282+
}
274283
}
275284
}

src/NuGetGallery.Services/Authentication/Providers/AzureActiveDirectoryV2/AzureActiveDirectoryV2AuthenticatorConfiguration.cs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ namespace NuGetGallery.Authentication.Providers.AzureActiveDirectoryV2
1212
public class AzureActiveDirectoryV2AuthenticatorConfiguration : AuthenticatorConfiguration
1313
{
1414
public string ClientId { get; set; }
15-
public string ClientSecret { get; set; }
1615

1716
public AzureActiveDirectoryV2AuthenticatorConfiguration()
1817
{
@@ -31,7 +30,7 @@ public override void ApplyToOwinSecurityOptions(AuthenticationOptions options)
3130
// the auth flow.
3231
openIdOptions.AuthenticationMode = AuthenticationMode.Passive;
3332

34-
// Make sure ClientId and ClientSecret is configured
33+
// Make sure ClientId is configured
3534
if (String.IsNullOrEmpty(ClientId))
3635
{
3736
throw new ConfigurationErrorsException(String.Format(
@@ -40,16 +39,7 @@ public override void ApplyToOwinSecurityOptions(AuthenticationOptions options)
4039
"Auth.CommonAuth.ClientId"));
4140
}
4241

43-
if (String.IsNullOrEmpty(ClientSecret))
44-
{
45-
throw new ConfigurationErrorsException(String.Format(
46-
CultureInfo.CurrentCulture,
47-
ServicesStrings.MissingRequiredConfigurationValue,
48-
"Auth.CommonAuth.ClientSecret"));
49-
}
50-
5142
openIdOptions.ClientId = ClientId;
52-
openIdOptions.ClientSecret = ClientSecret;
5343
openIdOptions.Authority = String.Format(CultureInfo.InvariantCulture, AzureActiveDirectoryV2Authenticator.Authority, AzureActiveDirectoryV2Authenticator.V2CommonTenant);
5444
}
5545
}

src/NuGetGallery.Services/ServicesStrings.resx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<root>
33
<!--
44
Microsoft ResX Schema
@@ -897,7 +897,7 @@ If you would like to update the linked Microsoft account you can do so from the
897897
Policy violations: {0}</value>
898898
</data>
899899
<data name="SecurityPolicy_RequirePackagePrefixReserved" xml:space="preserve">
900-
<value>You have not published a package with this prefix in the past. This means other users may be able to push packages starting with the same prefix. Contact [email protected] to reserve the prefix. Go to https://docs.microsoft.com/en-us/nuget/reference/id-prefix-reservation to learn more about Package ID prefix reservation.</value>
900+
<value>You have not published a package with this prefix in the past. This means other users may be able to push packages starting with the same prefix. Contact [email protected] to reserve the prefix. Go to https://docs.microsoft.com/nuget/reference/id-prefix-reservation to learn more about Package ID prefix reservation.</value>
901901
</data>
902902
<data name="SecurityPolicy_CopyrightNotCompliant" xml:space="preserve">
903903
<value>The package metadata contains a non-compliant copyright element.</value>

src/NuGetGallery/App_Code/ViewHelpers.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@
120120
<p class="error-action">Get me out of here! <a href="@url.Home()">Go home</a></p>
121121
<p class="error-action">Wondering if NuGet is down? <a href="https://status.nuget.org/">Check our status</a></p>
122122
<p class="error-action">Looking for a package? <a href="@url.PackageList()">Try searching</a></p>
123-
<p class="error-action">Package you're looking for doesn't exist? <a href="https://docs.microsoft.com/en-us/nuget/quickstart/create-and-publish-a-package">Make one</a></p>
123+
<p class="error-action">Package you're looking for doesn't exist? <a href="https://docs.microsoft.com/nuget/quickstart/create-and-publish-a-package">Make one</a></p>
124124
<p class="error-action">Pretty sure we messed up? <a href="https://github.com/NuGet/NuGetGallery/issues">File a bug</a></p>
125125
<p class="error-action">Can't get enough NuGet? <a href="https://twitter.com/nuget">Follow us</a></p>
126126
</div>

src/NuGetGallery/App_Data/Files/Content/Trusted-Image-Domains.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"codefactor.io",
2424
"coveralls.io",
2525
"dev.azure.com",
26+
"flat.badgen.net",
2627
"gitlab.com",
2728
"img.shields.io",
2829
"i.imgur.com",

src/NuGetGallery/Scripts/gallery/common.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@
462462

463463
nuget.setPopovers = function () {
464464
var popoverElement = $(this);
465-
var popoverElementDom = popoverElement.get(0);
465+
var popoverElementDom = this;
466466
var originalLabel = popoverElementDom.ariaLabel;
467467
var popoverHideTimeMS = 2000;
468468
var popoverFadeTimeMS = 200;

0 commit comments

Comments
 (0)