Repository navigation
Split ExternalAuthenticationService into a Business result and a Web sign-in - #944
Merged
Merged
Conversation
…sign-in ExternalAuthenticationService.Authenticate returns ExternalAuthResult instead of IActionResult and no longer signs in. The new ExternalSignInService in Web.Common signs the customer in and maps the result to the same redirects as before. IGrandAuthenticationService has no Business user left and moves to Web.Common.
- Redirect to the home page when returnUrl is not a local URL - Map every ExternalAuthStatus explicitly and throw on an unknown one - Translate the already-assigned and registration-disabled messages in Web (new resources in DefaultLanguage.xml and Upgrade/en_250.xml) - Expose ExternalAuthResult.Errors as IReadOnlyList and drop the unreachable registration error branch - Document that callers of IExternalAuthenticationService.Authenticate must sign in a LoggedIn or Registered customer
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of the work on keeping ASP.NET Core out of Business (after #943)
Type: feature
Issue
ExternalAuthenticationServicewas the onlyGrand.Business.*user ofIGrandAuthenticationService, and it andIExternalAuthenticationServicereturnedIActionResult(using Microsoft.AspNetCore.MvcinGrand.Business.Core). Signing in through a cookie and picking a redirect are HTTP concerns, so the domain part (find the associated customer, associate the account, register, raise the events) could not be used without MVC.Reproduce:
grep -rln -E 'IGrandAuthenticationService|Microsoft.AspNetCore.Mvc' src/Business --include=*.cslistsExternalAuthenticationService.cs,IExternalAuthenticationService.csandIGrandAuthenticationService.cs.Solution
IExternalAuthenticationService.Authenticate(parameters, customer, store, language)returnsExternalAuthResult(Grand.Business.Core.Utilities.Authentication, same shape asOidcLoginResult):Status,Customer,Errors. Statuses:LoggedIn,Registered,Associated(the account is, or now is, linked to the customer already signed in),AwaitingApproval,AlreadyAssigned,RegistrationDisabled,Error. The service no longer signs in and no longer takesreturnUrl;CustomerLoggedInEvent/CustomerRegisteredEventare still published there.IExternalSignInService/ExternalSignInServiceinGrand.Web.Common.Security.Authentication: calls the Business service, signs in onLoggedIn/Registered(after the event, as before) and maps the result to the same redirects as before (HomePageorreturnUrl,RegisterResultStandard / AdminApproval,Common/ExternalAuthenticationErrorwith the errors). ItsAuthenticatekeeps the old signature.IGrandAuthenticationServicehas no Business user left and moves toGrand.Web.Common.Security.Authentication, next toCookieAuthenticationService. Call sites change only theirusing.IExternalSignInService.Authenticate; they still useIExternalAuthenticationServiceforAuthenticationProviderIsAvailable.The grep above now returns nothing.
Grand.Business.Authenticationstill depends on ASP.NET Core through itsStartupApplicationand the JWT services; that is a separate step.Breaking changes
IExternalAuthenticationService.AuthenticatereturnsTask<ExternalAuthResult>instead ofTask<IActionResult>and has noreturnUrlparameter. External login plugins callIExternalSignInService.Authenticate(same arguments as the old method) instead.ExternalAuthenticationService: the constructor no longer takesIGrandAuthenticationService; the protected virtual helpers returnExternalAuthResultand lostreturnUrl;Error(...)moved toExternalSignInService.IGrandAuthenticationService:Grand.Business.Core.Interfaces.Authentication→Grand.Web.Common.Security.Authentication, assemblyGrand.Web.Common.Testing
Automated: the solution builds.
Grand.Business.Authentication.Tests(299),Grand.Web.Common.Tests(545),Grand.Web.Tests(152),Grand.Web.Admin.Tests(1578) andGrand.Modules.Tests(379) pass. New tests cover everyExternalAuthStatusin the Business service and the sign-in / redirect mapping inExternalSignInServiceTests.Manual (not run yet), with the Google or Facebook login plugin configured:
returnUrlor the home page, guest cart merged.