Skip to content

Commit 1bd5845

Browse files
authored
Merge pull request #6735 from aspnet/johluo/merge22
Johluo/merge22
2 parents 8119c57 + e1c4d15 commit 1bd5845

File tree

10 files changed

+414
-531
lines changed

10 files changed

+414
-531
lines changed

build/AzureIntegration.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@
2828
<Copy SourceFiles="@(AzureIntegrationArtifacts)" DestinationFolder="$(ProductPackageOutputPath)" />
2929
</Target>
3030

31-
</Project>
31+
</Project>

eng/PatchConfig.props

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ Later on, this will be checked using this condition:
1919
</PropertyGroup>
2020
<PropertyGroup Condition=" '$(VersionPrefix)' == '2.2.2' ">
2121
<PackagesInPatch>
22+
@aspnet/signalr;
23+
Microsoft.AspNetCore.Authentication.Google;
24+
Microsoft.AspNetCore.Http;
2225
</PackagesInPatch>
2326
</PropertyGroup>
2427

eng/scripts/CodeCheck.ps1

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ finally {
9090
Write-Host ""
9191

9292
foreach ($err in $errors) {
93-
9493
Write-Host -f Red "error : $err"
9594
}
9695

src/Mvc/Mvc.sln

Lines changed: 357 additions & 340 deletions
Large diffs are not rendered by default.

src/Security/Authentication/Google/src/GoogleDefaults.cs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

4+
using System;
5+
46
namespace Microsoft.AspNetCore.Authentication.Google
57
{
68
/// <summary>
@@ -17,7 +19,23 @@ public static class GoogleDefaults
1719

1820
public static readonly string TokenEndpoint = "https://www.googleapis.com/oauth2/v4/token";
1921

20-
// https://developers.google.com/+/web/people/
21-
public static readonly string UserInformationEndpoint = "https://www.googleapis.com/plus/v1/people/me";
22+
public static readonly string UserInformationEndpoint;
23+
24+
private const string UseGooglePlusSwitch = "Switch.Microsoft.AspNetCore.Authentication.Google.UsePlus";
25+
26+
internal static readonly bool UseGooglePlus;
27+
28+
static GoogleDefaults()
29+
{
30+
if (AppContext.TryGetSwitch(UseGooglePlusSwitch, out UseGooglePlus) && UseGooglePlus)
31+
{
32+
// https://developers.google.com/+/web/people/
33+
UserInformationEndpoint = "https://www.googleapis.com/plus/v1/people/me";
34+
}
35+
else
36+
{
37+
UserInformationEndpoint = "https://www.googleapis.com/oauth2/v2/userinfo";
38+
}
39+
}
2240
}
2341
}

src/Security/Authentication/Google/src/GoogleOptions.cs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

44
using System.Security.Claims;
5-
using Microsoft.AspNetCore.Authentication;
65
using Microsoft.AspNetCore.Authentication.OAuth;
76
using Microsoft.AspNetCore.Http;
87

@@ -27,16 +26,27 @@ public GoogleOptions()
2726
Scope.Add("email");
2827

2928
ClaimActions.MapJsonKey(ClaimTypes.NameIdentifier, "id");
30-
ClaimActions.MapJsonKey(ClaimTypes.Name, "displayName");
31-
ClaimActions.MapJsonSubKey(ClaimTypes.GivenName, "name", "givenName");
32-
ClaimActions.MapJsonSubKey(ClaimTypes.Surname, "name", "familyName");
33-
ClaimActions.MapJsonKey("urn:google:profile", "url");
34-
ClaimActions.MapCustomJson(ClaimTypes.Email, GoogleHelper.GetEmail);
29+
if (GoogleDefaults.UseGooglePlus)
30+
{
31+
ClaimActions.MapJsonKey(ClaimTypes.Name, "displayName");
32+
ClaimActions.MapJsonSubKey(ClaimTypes.GivenName, "name", "givenName");
33+
ClaimActions.MapJsonSubKey(ClaimTypes.Surname, "name", "familyName");
34+
ClaimActions.MapJsonKey("urn:google:profile", "url");
35+
ClaimActions.MapCustomJson(ClaimTypes.Email, GoogleHelper.GetEmail);
36+
}
37+
else
38+
{
39+
ClaimActions.MapJsonKey(ClaimTypes.Name, "name");
40+
ClaimActions.MapJsonKey(ClaimTypes.GivenName, "given_name");
41+
ClaimActions.MapJsonKey(ClaimTypes.Surname, "family_name");
42+
ClaimActions.MapJsonKey("urn:google:profile", "link");
43+
ClaimActions.MapJsonKey(ClaimTypes.Email, "email");
44+
}
3545
}
3646

3747
/// <summary>
3848
/// access_type. Set to 'offline' to request a refresh token.
3949
/// </summary>
4050
public string AccessType { get; set; }
4151
}
42-
}
52+
}

src/Security/Authentication/test/GoogleTests.cs

Lines changed: 12 additions & 176 deletions
Original file line numberDiff line numberDiff line change
@@ -472,45 +472,7 @@ public async Task ReplyPathWillAuthenticateValidAuthorizeCodeAndState(string cla
472472
{
473473
o.ClaimsIssuer = claimsIssuer;
474474
}
475-
o.BackchannelHttpHandler = new TestHttpMessageHandler
476-
{
477-
Sender = req =>
478-
{
479-
if (req.RequestUri.AbsoluteUri == "https://www.googleapis.com/oauth2/v4/token")
480-
{
481-
return ReturnJsonResponse(new
482-
{
483-
access_token = "Test Access Token",
484-
expires_in = 3600,
485-
token_type = "Bearer"
486-
});
487-
}
488-
else if (req.RequestUri.GetComponents(UriComponents.SchemeAndServer | UriComponents.Path, UriFormat.UriEscaped) == "https://www.googleapis.com/plus/v1/people/me")
489-
{
490-
return ReturnJsonResponse(new
491-
{
492-
id = "Test User ID",
493-
displayName = "Test Name",
494-
name = new
495-
{
496-
familyName = "Test Family Name",
497-
givenName = "Test Given Name"
498-
},
499-
url = "Profile link",
500-
emails = new[]
501-
{
502-
new
503-
{
504-
value = "Test email",
505-
type = "account"
506-
}
507-
}
508-
});
509-
}
510-
511-
throw new NotImplementedException(req.RequestUri.AbsoluteUri);
512-
}
513-
};
475+
o.BackchannelHttpHandler = CreateBackchannel();
514476
});
515477

516478
var properties = new AuthenticationProperties();
@@ -662,46 +624,7 @@ public async Task AuthenticatedEventCanGetRefreshToken()
662624
o.ClientId = "Test Id";
663625
o.ClientSecret = "Test Secret";
664626
o.StateDataFormat = stateFormat;
665-
o.BackchannelHttpHandler = new TestHttpMessageHandler
666-
{
667-
Sender = req =>
668-
{
669-
if (req.RequestUri.AbsoluteUri == "https://www.googleapis.com/oauth2/v4/token")
670-
{
671-
return ReturnJsonResponse(new
672-
{
673-
access_token = "Test Access Token",
674-
expires_in = 3600,
675-
token_type = "Bearer",
676-
refresh_token = "Test Refresh Token"
677-
});
678-
}
679-
else if (req.RequestUri.GetComponents(UriComponents.SchemeAndServer | UriComponents.Path, UriFormat.UriEscaped) == "https://www.googleapis.com/plus/v1/people/me")
680-
{
681-
return ReturnJsonResponse(new
682-
{
683-
id = "Test User ID",
684-
displayName = "Test Name",
685-
name = new
686-
{
687-
familyName = "Test Family Name",
688-
givenName = "Test Given Name"
689-
},
690-
url = "Profile link",
691-
emails = new[]
692-
{
693-
new
694-
{
695-
value = "Test email",
696-
type = "account"
697-
}
698-
}
699-
});
700-
}
701-
702-
throw new NotImplementedException(req.RequestUri.AbsoluteUri);
703-
}
704-
};
627+
o.BackchannelHttpHandler = CreateBackchannel();
705628
o.Events = new OAuthEvents
706629
{
707630
OnCreatingTicket = context =>
@@ -742,46 +665,7 @@ public async Task NullRedirectUriWillRedirectToSlash()
742665
o.ClientId = "Test Id";
743666
o.ClientSecret = "Test Secret";
744667
o.StateDataFormat = stateFormat;
745-
o.BackchannelHttpHandler = new TestHttpMessageHandler
746-
{
747-
Sender = req =>
748-
{
749-
if (req.RequestUri.AbsoluteUri == "https://www.googleapis.com/oauth2/v4/token")
750-
{
751-
return ReturnJsonResponse(new
752-
{
753-
access_token = "Test Access Token",
754-
expires_in = 3600,
755-
token_type = "Bearer",
756-
refresh_token = "Test Refresh Token"
757-
});
758-
}
759-
else if (req.RequestUri.GetComponents(UriComponents.SchemeAndServer | UriComponents.Path, UriFormat.UriEscaped) == "https://www.googleapis.com/plus/v1/people/me")
760-
{
761-
return ReturnJsonResponse(new
762-
{
763-
id = "Test User ID",
764-
displayName = "Test Name",
765-
name = new
766-
{
767-
familyName = "Test Family Name",
768-
givenName = "Test Given Name"
769-
},
770-
url = "Profile link",
771-
emails = new[]
772-
{
773-
new
774-
{
775-
value = "Test email",
776-
type = "account"
777-
}
778-
}
779-
});
780-
}
781-
782-
throw new NotImplementedException(req.RequestUri.AbsoluteUri);
783-
}
784-
};
668+
o.BackchannelHttpHandler = CreateBackchannel();
785669
o.Events = new OAuthEvents
786670
{
787671
OnTicketReceived = context =>
@@ -832,46 +716,7 @@ public async Task ValidateAuthenticatedContext()
832716
return Task.FromResult(0);
833717
}
834718
};
835-
o.BackchannelHttpHandler = new TestHttpMessageHandler
836-
{
837-
Sender = req =>
838-
{
839-
if (req.RequestUri.AbsoluteUri == "https://www.googleapis.com/oauth2/v4/token")
840-
{
841-
return ReturnJsonResponse(new
842-
{
843-
access_token = "Test Access Token",
844-
expires_in = 3600,
845-
token_type = "Bearer",
846-
refresh_token = "Test Refresh Token"
847-
});
848-
}
849-
else if (req.RequestUri.GetComponents(UriComponents.SchemeAndServer | UriComponents.Path, UriFormat.UriEscaped) == "https://www.googleapis.com/plus/v1/people/me")
850-
{
851-
return ReturnJsonResponse(new
852-
{
853-
id = "Test User ID",
854-
displayName = "Test Name",
855-
name = new
856-
{
857-
familyName = "Test Family Name",
858-
givenName = "Test Given Name"
859-
},
860-
url = "Profile link",
861-
emails = new[]
862-
{
863-
new
864-
{
865-
value = "Test email",
866-
type = "account"
867-
}
868-
}
869-
});
870-
}
871-
872-
throw new NotImplementedException(req.RequestUri.AbsoluteUri);
873-
}
874-
};
719+
o.BackchannelHttpHandler = CreateBackchannel();
875720
});
876721

877722
var properties = new AuthenticationProperties();
@@ -1102,29 +947,20 @@ private HttpMessageHandler CreateBackchannel()
1102947
{
1103948
access_token = "Test Access Token",
1104949
expires_in = 3600,
1105-
token_type = "Bearer"
950+
token_type = "Bearer",
951+
refresh_token = "Test Refresh Token"
1106952
});
1107953
}
1108-
else if (req.RequestUri.GetComponents(UriComponents.SchemeAndServer | UriComponents.Path, UriFormat.UriEscaped) == "https://www.googleapis.com/plus/v1/people/me")
954+
else if (req.RequestUri.GetComponents(UriComponents.SchemeAndServer | UriComponents.Path, UriFormat.UriEscaped) == "https://www.googleapis.com/oauth2/v2/userinfo")
1109955
{
1110956
return ReturnJsonResponse(new
1111957
{
1112958
id = "Test User ID",
1113-
displayName = "Test Name",
1114-
name = new
1115-
{
1116-
familyName = "Test Family Name",
1117-
givenName = "Test Given Name"
1118-
},
1119-
url = "Profile link",
1120-
emails = new[]
1121-
{
1122-
new
1123-
{
1124-
value = "Test email",
1125-
type = "account"
1126-
}
1127-
}
959+
name = "Test Name",
960+
given_name = "Test Given Name",
961+
family_name = "Test Family Name",
962+
link = "Profile link",
963+
email = "Test email",
1128964
});
1129965
}
1130966

src/SignalR/clients/ts/signalr-protocol-msgpack/src/MessagePackHubProtocol.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export class MessagePackHubProtocol implements IHubProtocol {
3131

3232
/** Creates an array of HubMessage objects from the specified serialized representation.
3333
*
34-
* @param {ArrayBuffer | Buffer} input An ArrayBuffer containing the serialized representation.
34+
* @param {ArrayBuffer | Buffer} input An ArrayBuffer or Buffer containing the serialized representation.
3535
* @param {ILogger} logger A logger that will be used to log messages that occur during parsing.
3636
*/
3737
public parseMessages(input: ArrayBuffer | Buffer, logger: ILogger): HubMessage[] {

src/SignalR/clients/ts/signalr/src/IHubProtocol.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,10 @@ export interface IHubProtocol {
154154
*
155155
* If {@link @aspnet/signalr.IHubProtocol.transferFormat} is 'Text', the `input` parameter must be a string, otherwise it must be an ArrayBuffer.
156156
*
157-
* @param {string | ArrayBuffer} input A string, or ArrayBuffer containing the serialized representation.
157+
* @param {string | ArrayBuffer | Buffer} input A string, ArrayBuffer, or Buffer containing the serialized representation.
158158
* @param {ILogger} logger A logger that will be used to log messages that occur during parsing.
159159
*/
160-
parseMessages(input: string | ArrayBuffer, logger: ILogger): HubMessage[];
160+
parseMessages(input: string | ArrayBuffer | Buffer, logger: ILogger): HubMessage[];
161161

162162
/** Writes the specified {@link @aspnet/signalr.HubMessage} to a string or ArrayBuffer and returns it.
163163
*

src/SiteExtensions/LoggingBranch/LoggingBranch.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
<SkipGetTargetFrameworkProperties>true</SkipGetTargetFrameworkProperties>
3636
</ProjectReference>
3737

38-
<ProjectReference Include="..\..\Framework\src\Microsoft.AspNetCore.App.shfxproj">
38+
<ProjectReference Include="..\..\Framework\src\Microsoft.AspNetCore.App.shfxproj">
3939
<Targets>Pack</Targets>
4040
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
4141
<SkipGetTargetFrameworkProperties>true</SkipGetTargetFrameworkProperties>

0 commit comments

Comments
 (0)