From 1629cab8feab65e52cb7ee47489fbfb11a43242f Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Tue, 19 Sep 2023 12:02:02 +0100 Subject: [PATCH] chore: Remove the Google.Apis.Auth.Mvc package We won't delist this, but we won't publish new versions of it. We don't have any tests for it; it's unclear whether it's actually useful; it target net45 which we'd like to remove support for. (We'll remove the fairly-minimal documentation we have for it, but as the package is still present it does no harm anyway.) If customers request that we reinstate it, we can do so. --- .../Google.Apis.Auth.Mvc.csproj | 33 ------ .../OAuth2/Mvc/AuthorizationCodeMvcApp.cs | 67 ----------- .../Mvc/Controllers/AuthCallbackController.cs | 105 ------------------ .../OAuth2/Mvc/Filters/AuthActionFilter.cs | 56 ---------- .../OAuth2/Mvc/FlowMetadata.cs | 49 -------- Src/Support/GoogleApisClient.sln | 10 +- 6 files changed, 2 insertions(+), 318 deletions(-) delete mode 100644 Src/Support/Google.Apis.Auth.Mvc/Google.Apis.Auth.Mvc.csproj delete mode 100644 Src/Support/Google.Apis.Auth.Mvc/OAuth2/Mvc/AuthorizationCodeMvcApp.cs delete mode 100644 Src/Support/Google.Apis.Auth.Mvc/OAuth2/Mvc/Controllers/AuthCallbackController.cs delete mode 100644 Src/Support/Google.Apis.Auth.Mvc/OAuth2/Mvc/Filters/AuthActionFilter.cs delete mode 100644 Src/Support/Google.Apis.Auth.Mvc/OAuth2/Mvc/FlowMetadata.cs diff --git a/Src/Support/Google.Apis.Auth.Mvc/Google.Apis.Auth.Mvc.csproj b/Src/Support/Google.Apis.Auth.Mvc/Google.Apis.Auth.Mvc.csproj deleted file mode 100644 index 46e35144cd8..00000000000 --- a/Src/Support/Google.Apis.Auth.Mvc/Google.Apis.Auth.Mvc.csproj +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - net45 - - - - - Google APIs Auth MVC Extensions - -The Google APIs Client Library is a runtime client for working with Google Services. - -The ASP.NET MVC extension library contains an auth controller and an authorization code MVC App to make the OAuth2 "dance" easier. - -Supported Platforms: -- .NET Framework 4.5+ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Src/Support/Google.Apis.Auth.Mvc/OAuth2/Mvc/AuthorizationCodeMvcApp.cs b/Src/Support/Google.Apis.Auth.Mvc/OAuth2/Mvc/AuthorizationCodeMvcApp.cs deleted file mode 100644 index 29f390656b0..00000000000 --- a/Src/Support/Google.Apis.Auth.Mvc/OAuth2/Mvc/AuthorizationCodeMvcApp.cs +++ /dev/null @@ -1,67 +0,0 @@ -/* -Copyright 2013 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 - - http://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 System; -using System.Threading; -using System.Threading.Tasks; -using System.Web.Mvc; - -using Google.Apis.Auth.OAuth2.Web; - -namespace Google.Apis.Auth.OAuth2.Mvc -{ - /// - /// Thread-safe OAuth 2.0 authorization code flow for a MVC web application that persists end-user credentials. - /// - public class AuthorizationCodeMvcApp : AuthorizationCodeWebApp - { - // TODO(peleyal): we should also follow the MVC framework Authorize attribute - - private readonly Controller controller; - private readonly FlowMetadata flowData; - - /// Gets the controller which is the owner of this authorization code MVC app instance. - public Controller Controller { get { return controller; } } - - /// Gets the object. - public FlowMetadata FlowData { get { return flowData; } } - - /// Constructs a new authorization code MVC app using the given controller and flow data. - public AuthorizationCodeMvcApp(Controller controller, FlowMetadata flowData) - : base( - flowData.Flow, - new Uri(controller.Request.Url.GetLeftPart(UriPartial.Authority) + flowData.AuthCallback).ToString(), - controller.Request.Url.ToString()) - { - this.controller = controller; - this.flowData = flowData; - } - - /// - /// Asynchronously authorizes the installed application to access user's protected data. It gets the user - /// identifier by calling to and then calls to - /// . - /// - /// Cancellation token to cancel an operation - /// - /// Auth result object which contains the user's credential or redirect URI for the authorization server - /// - public Task AuthorizeAsync(CancellationToken taskCancellationToken) - { - return base.AuthorizeAsync(FlowData.GetUserId(Controller), taskCancellationToken); - } - } -} diff --git a/Src/Support/Google.Apis.Auth.Mvc/OAuth2/Mvc/Controllers/AuthCallbackController.cs b/Src/Support/Google.Apis.Auth.Mvc/OAuth2/Mvc/Controllers/AuthCallbackController.cs deleted file mode 100644 index c78d344b878..00000000000 --- a/Src/Support/Google.Apis.Auth.Mvc/OAuth2/Mvc/Controllers/AuthCallbackController.cs +++ /dev/null @@ -1,105 +0,0 @@ -/* -Copyright 2013 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 - - http://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 System; -using System.Threading; -using System.Threading.Tasks; -using System.Web.Mvc; - -using Google.Apis.Auth.OAuth2; -using Google.Apis.Auth.OAuth2.Flows; -using Google.Apis.Auth.OAuth2.Mvc.Filters; -using Google.Apis.Auth.OAuth2.Responses; -using Google.Apis.Auth.OAuth2.Web; -using Google.Apis.Logging; - -namespace Google.Apis.Auth.OAuth2.Mvc.Controllers -{ - /// - /// Auth callback to process the authorization code or error response from the authorization redirect page. - /// - [AuthorizationCodeActionFilter] - public abstract class AuthCallbackController : Controller - { - /// Logger for this class. - protected static readonly ILogger Logger = ApplicationContext.Logger.ForType(); - - /// Gets the authorization code flow. - protected IAuthorizationCodeFlow Flow { get { return FlowData.Flow; } } - - /// - /// Gets the user identifier. Potential logic is to use session variables to retrieve that information. - /// - protected string UserId { get { return FlowData.GetUserId(this); } } - - #region Abstract and Virtual Members - - /// Gets the flow data which contains - protected abstract FlowMetadata FlowData { get; } - - /// - /// A callback which gets the error when this controller didn't receive an authorization code. The default - /// implementation throws a . - /// - protected virtual ActionResult OnTokenError(TokenErrorResponse errorResponse) - { - throw new TokenResponseException(errorResponse); - } - - /// - /// The authorization callback which receives an authorization code which contains an error or a code. - /// If a code is available the method exchange the coed with an access token and redirect back to the original - /// page which initialized the auth process (using the state parameter). - /// - /// The current timeout is set to 10 seconds. You can change the default behavior by setting - /// with a different value on your controller. - /// - /// - /// Authorization code response which contains the code or an error. - /// Cancellation token to cancel operation. - /// - /// Redirect action to the state parameter or in case of an error. - /// - [AsyncTimeout(10000)] - public async virtual Task IndexAsync(AuthorizationCodeResponseUrl authorizationCode, - CancellationToken taskCancellationToken) - { - if (string.IsNullOrEmpty(authorizationCode.Code)) - { - var errorResponse = new TokenErrorResponse(authorizationCode); - Logger.Info("Received an error. The response is: {0}", errorResponse); - - return OnTokenError(errorResponse); - } - - Logger.Debug("Received \"{0}\" code", authorizationCode.Code); - - var returnUrl = Request.Url.ToString(); - returnUrl = returnUrl.Substring(0, returnUrl.IndexOf("?")); - - var token = await Flow.ExchangeCodeForTokenAsync(UserId, authorizationCode.Code, returnUrl, - taskCancellationToken).ConfigureAwait(false); - - // Extract the right state. - var oauthState = await AuthWebUtility.ExtracRedirectFromState(Flow.DataStore, UserId, - authorizationCode.State).ConfigureAwait(false); - - return new RedirectResult(oauthState); - } - - #endregion - } -} diff --git a/Src/Support/Google.Apis.Auth.Mvc/OAuth2/Mvc/Filters/AuthActionFilter.cs b/Src/Support/Google.Apis.Auth.Mvc/OAuth2/Mvc/Filters/AuthActionFilter.cs deleted file mode 100644 index b5dd9f8fd6e..00000000000 --- a/Src/Support/Google.Apis.Auth.Mvc/OAuth2/Mvc/Filters/AuthActionFilter.cs +++ /dev/null @@ -1,56 +0,0 @@ -/* -Copyright 2013 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 - - http://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 System.Web; -using System.Web.Mvc; - -using Google.Apis.Auth.OAuth2.Responses; - -namespace Google.Apis.Auth.OAuth2.Mvc.Filters -{ - /// - /// An action filter which parses the query parameters into - /// . - /// - public class AuthorizationCodeActionFilter : ActionFilterAttribute, IActionFilter - { - /// - /// Parses the request into . - /// - public override void OnActionExecuting(ActionExecutingContext actionContext) - { - (actionContext.ActionParameters["authorizationCode"] as AuthorizationCodeResponseUrl) - .ParseRequest(actionContext.RequestContext.HttpContext.Request); - - base.OnActionExecuting(actionContext); - } - } - - /// Auth extensions methods. - public static class AuthExtensions - { - /// Parses the HTTP request query parameters into the Authorization code response. - internal static void ParseRequest(this AuthorizationCodeResponseUrl authorizationCode, HttpRequestBase request) - { - var queryDic = HttpUtility.ParseQueryString(request.Url.Query); - authorizationCode.Code = queryDic["code"]; - authorizationCode.Error = queryDic["error"]; - authorizationCode.ErrorDescription = queryDic["error_description"]; - authorizationCode.ErrorUri = queryDic["error_uri"]; - authorizationCode.State = queryDic["state"]; - } - } -} diff --git a/Src/Support/Google.Apis.Auth.Mvc/OAuth2/Mvc/FlowMetadata.cs b/Src/Support/Google.Apis.Auth.Mvc/OAuth2/Mvc/FlowMetadata.cs deleted file mode 100644 index 67de43a195b..00000000000 --- a/Src/Support/Google.Apis.Auth.Mvc/OAuth2/Mvc/FlowMetadata.cs +++ /dev/null @@ -1,49 +0,0 @@ -/* -Copyright 2013 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 - - http://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 System.Web.Mvc; - -using Google.Apis.Auth.OAuth2.Flows; - -namespace Google.Apis.Auth.OAuth2.Mvc -{ - /// - /// Flow metadata abstract class which contains the reference to the - /// and - /// method to get the user identifier. - /// - public abstract class FlowMetadata - { - /// - /// Gets the user identifier. - /// - /// The controller - /// User identifier - public abstract string GetUserId(Controller controller); - - /// Gets the authorization code flow. - public abstract IAuthorizationCodeFlow Flow { get; } - - /// - /// Gets the authorization application's call back. That relative URL will handle the authorization code - /// response. - /// - public virtual string AuthCallback - { - get { return @"/AuthCallback/IndexAsync"; } - } - } -} diff --git a/Src/Support/GoogleApisClient.sln b/Src/Support/GoogleApisClient.sln index e1f2f1c9901..19661cd0a0e 100644 --- a/Src/Support/GoogleApisClient.sln +++ b/Src/Support/GoogleApisClient.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.29613.14 +# Visual Studio Version 17 +VisualStudioVersion = 17.7.34031.279 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Google.Apis.Core", "Google.Apis.Core\Google.Apis.Core.csproj", "{556BEB88-1F3B-4EFA-B912-828C90AC3BEB}" EndProject @@ -19,8 +19,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Google.Apis.Auth.Tests", "G EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IntegrationTests", "IntegrationTests\IntegrationTests.csproj", "{AB7DA6CF-0100-4941-BD4B-BEE1AA80C6AE}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Google.Apis.Auth.Mvc", "Google.Apis.Auth.Mvc\Google.Apis.Auth.Mvc.csproj", "{22ED8B87-9A8E-4330-8011-318A85F545DD}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Google.Apis.Auth.AspNetCore", "Google.Apis.Auth.AspNetCore\Google.Apis.Auth.AspNetCore.csproj", "{2BCEF725-9F15-4A6B-BD43-D8E7457AB429}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Google.Apis.Auth.AspNetCore.IntegrationTests", "Google.Apis.Auth.AspNetCore.IntegrationTests\Google.Apis.Auth.AspNetCore.IntegrationTests.csproj", "{A88DC5FE-4697-4D1F-A374-D620E77A5383}" @@ -67,10 +65,6 @@ Global {AB7DA6CF-0100-4941-BD4B-BEE1AA80C6AE}.Debug|Any CPU.Build.0 = Debug|Any CPU {AB7DA6CF-0100-4941-BD4B-BEE1AA80C6AE}.Release|Any CPU.ActiveCfg = Release|Any CPU {AB7DA6CF-0100-4941-BD4B-BEE1AA80C6AE}.Release|Any CPU.Build.0 = Release|Any CPU - {22ED8B87-9A8E-4330-8011-318A85F545DD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {22ED8B87-9A8E-4330-8011-318A85F545DD}.Debug|Any CPU.Build.0 = Debug|Any CPU - {22ED8B87-9A8E-4330-8011-318A85F545DD}.Release|Any CPU.ActiveCfg = Release|Any CPU - {22ED8B87-9A8E-4330-8011-318A85F545DD}.Release|Any CPU.Build.0 = Release|Any CPU {2BCEF725-9F15-4A6B-BD43-D8E7457AB429}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2BCEF725-9F15-4A6B-BD43-D8E7457AB429}.Debug|Any CPU.Build.0 = Debug|Any CPU {2BCEF725-9F15-4A6B-BD43-D8E7457AB429}.Release|Any CPU.ActiveCfg = Release|Any CPU