Browse Source

Merge pull request #1227 from colinin/account-login-model

feat(account): 重命名登录模型
pull/1238/head
yx lin 1 year ago
committed by GitHub
parent
commit
b3d746e11f
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 14
      aspnet-core/LINGYUN.MicroService.SingleProject.sln
  2. 62
      aspnet-core/migrations/LY.MicroService.Applications.Single.EntityFrameworkCore/DataSeeder/ClientDataSeederContributor.cs
  3. 34
      aspnet-core/modules/account/LINGYUN.Abp.Account.Web.IdentityServer/Pages/Account/IdentityServerLoginModel.cs
  4. 13
      aspnet-core/modules/account/LINGYUN.Abp.Account.Web.OpenIddict/Pages/Account/OpenIddictLoginModel.cs

14
aspnet-core/LINGYUN.MicroService.SingleProject.sln

@ -688,6 +688,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.Quartz.SqlInsta
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.UI.Navigation.VueVbenAdmin5", "modules\platform\LINGYUN.Abp.UI.Navigation.VueVbenAdmin5\LINGYUN.Abp.UI.Navigation.VueVbenAdmin5.csproj", "{113167DA-602A-4EBE-9357-D83C090DBA3F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.Account.Web.OAuth", "modules\account\LINGYUN.Abp.Account.Web.OAuth\LINGYUN.Abp.Account.Web.OAuth.csproj", "{2379F502-BBBD-4BF2-91F7-D0E5C61E91B7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.Account.OAuth", "modules\account\LINGYUN.Abp.Account.OAuth\LINGYUN.Abp.Account.OAuth.csproj", "{2E4C437A-989D-68D9-C5FB-1AE085B2CBC8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -1830,6 +1834,14 @@ Global
{113167DA-602A-4EBE-9357-D83C090DBA3F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{113167DA-602A-4EBE-9357-D83C090DBA3F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{113167DA-602A-4EBE-9357-D83C090DBA3F}.Release|Any CPU.Build.0 = Release|Any CPU
{2379F502-BBBD-4BF2-91F7-D0E5C61E91B7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2379F502-BBBD-4BF2-91F7-D0E5C61E91B7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2379F502-BBBD-4BF2-91F7-D0E5C61E91B7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2379F502-BBBD-4BF2-91F7-D0E5C61E91B7}.Release|Any CPU.Build.0 = Release|Any CPU
{2E4C437A-989D-68D9-C5FB-1AE085B2CBC8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2E4C437A-989D-68D9-C5FB-1AE085B2CBC8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2E4C437A-989D-68D9-C5FB-1AE085B2CBC8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2E4C437A-989D-68D9-C5FB-1AE085B2CBC8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -2165,6 +2177,8 @@ Global
{B8D0DCBD-8D03-E450-0258-D0660A356BF0} = {22295ECE-A973-43F0-A6F2-982F7DB02F4E}
{A8586A5A-A213-4C66-819C-E692187B1F39} = {91EE5D5B-B6DF-43F1-BC09-1A982719A34B}
{113167DA-602A-4EBE-9357-D83C090DBA3F} = {F3449D35-8671-4BF6-8D1B-EFBB8AFD61DD}
{2379F502-BBBD-4BF2-91F7-D0E5C61E91B7} = {4F837B81-EA7D-472A-8482-3D5A730DF810}
{2E4C437A-989D-68D9-C5FB-1AE085B2CBC8} = {4F837B81-EA7D-472A-8482-3D5A730DF810}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {711A43C0-A2F8-4E5C-9B9F-F2551E4B3FF1}

62
aspnet-core/migrations/LY.MicroService.Applications.Single.EntityFrameworkCore/DataSeeder/ClientDataSeederContributor.cs

@ -204,6 +204,68 @@ public class ClientDataSeederContributor : IDataSeedContributor, ITransientDepen
await _permissionDataSeeder.SeedAsync(ClientPermissionValueProvider.ProviderName, internalServiceClientId, internalServicePermissions);
}
}
var oauthClientId = configurationSection["OAuthClient:ClientId"];
if (!oauthClientId.IsNullOrWhiteSpace())
{
var oauthClientRootUrl = configurationSection["OAuthClient:RootUrl"].EnsureEndsWith('/');
if (await _applicationRepository.FindByClientIdAsync(oauthClientId) == null)
{
await _applicationManager.CreateAsync(new OpenIddictApplicationDescriptor
{
ClientId = oauthClientId,
ClientSecret = null,
ApplicationType = OpenIddictConstants.ApplicationTypes.Web,
ConsentType = OpenIddictConstants.ConsentTypes.Implicit,
DisplayName = "OAuth Client",
PostLogoutRedirectUris =
{
new Uri(oauthClientRootUrl + "signout-callback"),
new Uri(oauthClientRootUrl)
},
RedirectUris =
{
new Uri(oauthClientRootUrl + "/signin-callback"),
new Uri(oauthClientRootUrl)
},
Permissions =
{
OpenIddictConstants.Permissions.Endpoints.Authorization,
OpenIddictConstants.Permissions.Endpoints.Token,
OpenIddictConstants.Permissions.Endpoints.DeviceAuthorization,
OpenIddictConstants.Permissions.Endpoints.Introspection,
OpenIddictConstants.Permissions.Endpoints.Revocation,
OpenIddictConstants.Permissions.Endpoints.EndSession,
OpenIddictConstants.Permissions.GrantTypes.AuthorizationCode,
OpenIddictConstants.Permissions.GrantTypes.RefreshToken,
OpenIddictConstants.Permissions.ResponseTypes.Code,
OpenIddictConstants.Permissions.ResponseTypes.CodeIdToken,
OpenIddictConstants.Permissions.ResponseTypes.CodeIdTokenToken,
OpenIddictConstants.Permissions.ResponseTypes.CodeToken,
OpenIddictConstants.Permissions.ResponseTypes.IdToken,
OpenIddictConstants.Permissions.ResponseTypes.IdTokenToken,
OpenIddictConstants.Permissions.ResponseTypes.None,
OpenIddictConstants.Permissions.ResponseTypes.Token,
OpenIddictConstants.Permissions.Scopes.Roles,
OpenIddictConstants.Permissions.Scopes.Profile,
OpenIddictConstants.Permissions.Scopes.Email,
OpenIddictConstants.Permissions.Scopes.Address,
OpenIddictConstants.Permissions.Scopes.Phone,
OpenIddictConstants.Permissions.Prefixes.Scope + scope
}
});
var oauthClientPermissions = new string[1]
{
"AbpIdentity.UserLookup"
};
await _permissionDataSeeder.SeedAsync(ClientPermissionValueProvider.ProviderName, oauthClientId, oauthClientPermissions);
}
}
}
#endregion

34
aspnet-core/modules/account/LINGYUN.Abp.Account.Web.IdentityServer/Pages/Account/TwoFactorSupportedLoginModel.cs → aspnet-core/modules/account/LINGYUN.Abp.Account.Web.IdentityServer/Pages/Account/IdentityServerLoginModel.cs

@ -2,11 +2,12 @@
using IdentityServer4.Models;
using IdentityServer4.Services;
using IdentityServer4.Stores;
using LINGYUN.Abp.Account.Web.ExternalProviders;
using LINGYUN.Abp.Account.Web.Models;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
@ -18,6 +19,7 @@ using Volo.Abp.Identity;
using Volo.Abp.IdentityServer.AspNetIdentity;
using Volo.Abp.MultiTenancy;
using Volo.Abp.Settings;
using static Volo.Abp.Account.Web.Pages.Account.LoginModel;
using IdentityOptions = Microsoft.AspNetCore.Identity.IdentityOptions;
namespace LINGYUN.Abp.Account.Web.IdentityServer.Pages.Account
@ -29,12 +31,13 @@ namespace LINGYUN.Abp.Account.Web.IdentityServer.Pages.Account
[ExposeServices(
typeof(LINGYUN.Abp.Account.Web.Pages.Account.LoginModel),
typeof(IdentityServerSupportedLoginModel))]
public class TwoFactorSupportedLoginModel : LINGYUN.Abp.Account.Web.Pages.Account.LoginModel
public class IdentityServerLoginModel : LINGYUN.Abp.Account.Web.Pages.Account.LoginModel
{
protected IIdentityServerInteractionService Interaction { get; }
protected IEventService IdentityServerEvents { get; }
protected IClientStore ClientStore { get; }
public TwoFactorSupportedLoginModel(
public IdentityServerLoginModel(
IExternalProviderService externalProviderService,
IAuthenticationSchemeProvider schemeProvider,
IOptions<AbpAccountOptions> accountOptions,
IOptions<IdentityOptions> identityOptions,
@ -42,7 +45,7 @@ namespace LINGYUN.Abp.Account.Web.IdentityServer.Pages.Account
IIdentityServerInteractionService interaction,
IEventService identityServerEvents,
IClientStore clientStore)
: base(schemeProvider, accountOptions, identityOptions, identityDynamicClaimsPrincipalContributorCache)
: base(externalProviderService, schemeProvider, accountOptions, identityOptions, identityDynamicClaimsPrincipalContributorCache)
{
Interaction = interaction;
ClientStore = clientStore;
@ -74,7 +77,7 @@ namespace LINGYUN.Abp.Account.Web.IdentityServer.Pages.Account
if (context?.IdP != null)
{
LoginInput.UserNameOrEmailAddress = context.LoginHint;
ExternalProviders = new[] { new ExternalProviderModel { AuthenticationScheme = context.IdP } };
ExternalProviders = new[] { new ExternalLoginProviderModel { AuthenticationScheme = context.IdP } };
return Page();
}
@ -182,26 +185,5 @@ namespace LINGYUN.Abp.Account.Web.IdentityServer.Pages.Account
return await RedirectSafelyAsync(ReturnUrl, ReturnUrlHash);
}
protected async override Task<List<ExternalProviderModel>> GetExternalProviders()
{
var providers = await base.GetExternalProviders();
foreach (var provider in providers)
{
var localizedDisplayName = L[provider.DisplayName];
if (localizedDisplayName.ResourceNotFound)
{
localizedDisplayName = L["AuthenticationScheme:" + provider.DisplayName];
}
if (!localizedDisplayName.ResourceNotFound)
{
provider.DisplayName = localizedDisplayName.Value;
}
}
return providers;
}
}
}

13
aspnet-core/modules/account/LINGYUN.Abp.Account.Web.OpenIddict/Pages/Account/TwoFactorSupportedLoginModel.cs → aspnet-core/modules/account/LINGYUN.Abp.Account.Web.OpenIddict/Pages/Account/OpenIddictLoginModel.cs

@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Authentication;
using LINGYUN.Abp.Account.Web.ExternalProviders;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
using System;
@ -8,6 +9,7 @@ using Volo.Abp.DependencyInjection;
using Volo.Abp.Identity;
using Volo.Abp.MultiTenancy;
using Volo.Abp.OpenIddict;
using static Volo.Abp.Account.Web.Pages.Account.LoginModel;
using IdentityOptions = Microsoft.AspNetCore.Identity.IdentityOptions;
namespace LINGYUN.Abp.Account.Web.OpenIddict.Pages.Account
@ -15,17 +17,18 @@ namespace LINGYUN.Abp.Account.Web.OpenIddict.Pages.Account
[Dependency(ReplaceServices = true)]
[ExposeServices(
typeof(LINGYUN.Abp.Account.Web.Pages.Account.LoginModel),
typeof(TwoFactorSupportedLoginModel))]
public class TwoFactorSupportedLoginModel : LINGYUN.Abp.Account.Web.Pages.Account.LoginModel
typeof(OpenIddictLoginModel))]
public class OpenIddictLoginModel : LINGYUN.Abp.Account.Web.Pages.Account.LoginModel
{
protected AbpOpenIddictRequestHelper OpenIddictRequestHelper { get; }
public TwoFactorSupportedLoginModel(
public OpenIddictLoginModel(
IExternalProviderService externalProviderService,
IAuthenticationSchemeProvider schemeProvider,
IOptions<AbpAccountOptions> accountOptions,
IOptions<IdentityOptions> identityOptions,
IdentityDynamicClaimsPrincipalContributorCache identityDynamicClaimsPrincipalContributorCache,
AbpOpenIddictRequestHelper openIddictRequestHelper)
: base(schemeProvider, accountOptions, identityOptions, identityDynamicClaimsPrincipalContributorCache)
: base(externalProviderService, schemeProvider, accountOptions, identityOptions, identityDynamicClaimsPrincipalContributorCache)
{
OpenIddictRequestHelper = openIddictRequestHelper;
}
Loading…
Cancel
Save