-
Notifications
You must be signed in to change notification settings - Fork 531
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support auth for ASP.NET Core 3 (#1491)
This creates a new package with specific support for ASP.NET Core 3. This has to be separate from the ASP.NET Core 2 package, due to different dependency requirements.
- Loading branch information
1 parent
c08e1a6
commit ec19e2a
Showing
35 changed files
with
732 additions
and
39 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
Backup* | ||
*.suo | ||
*.user | ||
launchSettings.json | ||
.vs | ||
project.lock.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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
28 changes: 0 additions & 28 deletions
28
Src/Support/Google.Apis.Auth.AspNetCore.IntegrationTests/Properties/launchSettings.json
This file was deleted.
Oops, something went wrong.
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
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
57 changes: 57 additions & 0 deletions
57
Src/Support/Google.Apis.Auth.AspNetCore3.IntegrationTests/ClientInfo.cs
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,57 @@ | ||
/* | ||
Copyright 2020 Google Inc | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
https://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
using Newtonsoft.Json.Linq; | ||
using System; | ||
using System.IO; | ||
using System.Text; | ||
|
||
namespace Google.Apis.Auth.AspNetCore3.IntegrationTests | ||
{ | ||
/// <summary> | ||
/// Client auth information, loaded from a Google user credential json file. | ||
/// Set the TEST_CLIENT_SECRET_FILENAME environment variable to point to the credential file. | ||
/// </summary> | ||
public class ClientInfo | ||
{ | ||
public static ClientInfo Load() | ||
{ | ||
const string ClientSecretFilenameVariable = "TEST_CLIENT_SECRET_FILENAME"; | ||
string clientSecretFilename = Environment.GetEnvironmentVariable(ClientSecretFilenameVariable); | ||
if (string.IsNullOrEmpty(clientSecretFilename)) | ||
{ | ||
throw new InvalidOperationException($"Please set the {ClientSecretFilenameVariable} environment variable before running tests."); | ||
} | ||
// This MUST be a "web" credential, not an "installed app" credential. | ||
var secrets = JObject.Parse(File.ReadAllText(clientSecretFilename))["web"]; | ||
var projectId = secrets["project_id"].Value<string>(); | ||
var clientId = secrets["client_id"].Value<string>(); | ||
var clientSecret = secrets["client_secret"].Value<string>(); | ||
return new ClientInfo(projectId, clientId, clientSecret); | ||
} | ||
|
||
private ClientInfo(string projectId, string clientId, string clientSecret) | ||
{ | ||
ProjectId = projectId; | ||
ClientId = clientId; | ||
ClientSecret = clientSecret; | ||
} | ||
|
||
public string ProjectId { get; } | ||
public string ClientId { get; } | ||
public string ClientSecret { get; } | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
Src/Support/Google.Apis.Auth.AspNetCore3.IntegrationTests/Controllers/AccountController.cs
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,30 @@ | ||
/* | ||
Copyright 2020 Google Inc | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
https://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
using Microsoft.AspNetCore.Authentication; | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace Google.Apis.Auth.AspNetCore3.IntegrationTests.Controllers | ||
{ | ||
public class AccountController : Controller | ||
{ | ||
public IActionResult Login(string returnUrl) | ||
{ | ||
var properties = new AuthenticationProperties { RedirectUri = returnUrl }; | ||
return Challenge(properties, GoogleOpenIdConnectDefaults.AuthenticationScheme); | ||
} | ||
} | ||
} |
Oops, something went wrong.