diff --git a/apps/vue/.env.development b/apps/vue/.env.development index 24bde5406..221f51e7a 100644 --- a/apps/vue/.env.development +++ b/apps/vue/.env.development @@ -26,5 +26,5 @@ VITE_GLOB_MULTITENANCY_KEY='__tenant' # STS Connect VITE_GLOB_AUTHORITY='http://127.0.0.1:44385' -VITE_GLOB_CLIENT_ID='vue-admin-element' +VITE_GLOB_CLIENT_ID='vue-admin-client' VITE_GLOB_CLIENT_SECRET='1q2w3e*' diff --git a/apps/vue/build/utils.ts b/apps/vue/build/utils.ts index c201514f9..68adde79d 100644 --- a/apps/vue/build/utils.ts +++ b/apps/vue/build/utils.ts @@ -36,11 +36,11 @@ export function wrapperEnv(envConf: Recordable): ViteEnv { } } ret[envName] = realName; - if (typeof realName === 'string') { - process.env[envName] = realName; - } else if (typeof realName === 'object') { - process.env[envName] = JSON.stringify(realName); - } + // if (typeof realName === 'string') { + // process.env[envName] = realName; + // } else if (typeof realName === 'object') { + // process.env[envName] = JSON.stringify(realName); + // } } return ret; } diff --git a/apps/vue/src/api/openiddict/open-iddict-application/model/index.ts b/apps/vue/src/api/openiddict/open-iddict-application/model/index.ts index 34426c97e..09e2349a1 100644 --- a/apps/vue/src/api/openiddict/open-iddict-application/model/index.ts +++ b/apps/vue/src/api/openiddict/open-iddict-application/model/index.ts @@ -9,7 +9,7 @@ export interface OpenIddictApplicationUpdateDto extends OpenIddictApplicationCre } export interface OpenIddictApplicationDto extends ExtensibleAuditedEntityDto { - clientId?: string; + clientId: string; clientSecret?: string; consentType?: string; displayName?: string; diff --git a/apps/vue/src/api/openiddict/open-iddict-scope/model/index.ts b/apps/vue/src/api/openiddict/open-iddict-scope/model/index.ts index 0f0212462..d85923994 100644 --- a/apps/vue/src/api/openiddict/open-iddict-scope/model/index.ts +++ b/apps/vue/src/api/openiddict/open-iddict-scope/model/index.ts @@ -23,7 +23,7 @@ export interface OpenIddictScopeDto extends ExtensibleAuditedEntityDto { descriptions?: Dictionary; displayName?: string; displayNames?: Dictionary; - name?: string; + name: string; properties?: Dictionary; resources?: string[]; } diff --git a/apps/vue/src/api/oss-management/oss.ts b/apps/vue/src/api/oss-management/oss.ts index 21f45ac4a..15d6adefa 100644 --- a/apps/vue/src/api/oss-management/oss.ts +++ b/apps/vue/src/api/oss-management/oss.ts @@ -14,6 +14,7 @@ import { format } from '/@/utils/strings'; import { AxiosResponse } from 'axios'; import { isFunction } from '/@/utils/is'; import { UploadFileParams } from '/#/axios'; +import { useAbpStoreWithOut } from '/@/store/modules/abp'; enum Api { CreateObject = '/api/oss-management/objects', @@ -73,7 +74,7 @@ export const uploadObject = (params: UploadFileParams, event: any) => { // 已完成大小 let loadedSize = 0; // 返回包装的结果 - return new Promise>(async (resolve, reject) => { + return new Promise>(async (resolve, reject) => { function onPregress(progress: number, res: AxiosResponse) { // 回调上传进度 if (isFunction(event)) { @@ -84,8 +85,20 @@ export const uploadObject = (params: UploadFileParams, event: any) => { } if (progress === totalSize) { if (!res.data) { + let formatUrl = '/api/files/static/{bucket}/p/{path}/{name}'; + const abpStore = useAbpStoreWithOut(); + const { currentTenant } = abpStore.getApplication; + if (currentTenant.id) { + formatUrl = '/api/files/static/t/{tenantId}/{bucket}/p/{path}/{name}'; + } + const path = encodeURIComponent(params.data?.path); res.data = { - url: format('/api/files/static/{bucket}/p/{path}/{name}', { bucket: params.data?.bucket, path: params.data?.path, name: fileName }), + url: format(formatUrl, { + bucket: params.data?.bucket, + tenantId: currentTenant.id, + path: path, + name: fileName, + }), }; } resolve(res); diff --git a/apps/vue/src/api/sys/user.ts b/apps/vue/src/api/sys/user.ts index 067358799..478a94e4c 100644 --- a/apps/vue/src/api/sys/user.ts +++ b/apps/vue/src/api/sys/user.ts @@ -33,6 +33,7 @@ export function loginApi(params: LoginParams, mode: ErrorMessageMode = 'modal') grant_type: 'password', username: params.username, password: params.password, + scope: 'openid email address phone profile offline_access lingyun-abp-application', TwoFactorProvider: params.twoFactorProvider, TwoFactorCode: params.twoFactorCode, }; @@ -47,6 +48,7 @@ export function loginApi(params: LoginParams, mode: ErrorMessageMode = 'modal') { errorMessageMode: mode, apiUrl: '/connect', + withToken: false, }, ); } diff --git a/apps/vue/src/layouts/default/setting/components/SettingFooter.vue b/apps/vue/src/layouts/default/setting/components/SettingFooter.vue index a0fb5e104..786eea9f7 100644 --- a/apps/vue/src/layouts/default/setting/components/SettingFooter.vue +++ b/apps/vue/src/layouts/default/setting/components/SettingFooter.vue @@ -38,9 +38,10 @@ import { updateColorWeak } from '/@/logics/theme/updateColorWeak'; import { updateGrayMode } from '/@/logics/theme/updateGrayMode'; + import { changeTheme } from '/@/logics/theme'; import defaultSetting from '/@/settings/projectSetting'; - import { changeTheme } from '/@/api/sys/theme'; + import { changeTheme as changeThemeApi } from '/@/api/sys/theme'; import { ThemeSetting } from '/@/api/sys/model/themeModel'; export default defineComponent({ @@ -69,8 +70,8 @@ function handleResetSetting() { try { appStore.setProjectConfig(defaultSetting); - const { colorWeak, grayMode } = defaultSetting; - // updateTheme(themeColor); + const { colorWeak, grayMode, themeColor } = defaultSetting; + changeTheme(themeColor); updateColorWeak(colorWeak); updateGrayMode(grayMode); createMessage.success(t('layout.setting.resetSuccess')); @@ -96,7 +97,7 @@ }; syncLoading.value = true; - changeTheme(themeSetting) + changeThemeApi(themeSetting) .then(() => { createMessage.success(t('layout.setting.operatingTitle')); }) diff --git a/apps/vue/src/store/modules/user.ts b/apps/vue/src/store/modules/user.ts index 46e220e61..6548609e8 100644 --- a/apps/vue/src/store/modules/user.ts +++ b/apps/vue/src/store/modules/user.ts @@ -173,7 +173,7 @@ export const useUserStore = defineStore({ const abpStore = useAbpStoreWithOut(); let currentUser = abpStore.getApplication.currentUser; // 避免多次请求接口 - if (userInfo.sub !== currentUser.id) { + if (userInfo?.sub !== currentUser.id) { await abpStore.initlizeAbpApplication(); currentUser = abpStore.getApplication.currentUser; } @@ -184,13 +184,13 @@ export const useUserStore = defineStore({ username: currentUser.userName, roles: currentUser.roles, // 从 userinfo 端点获取 - realName: userInfo.nickname, - phoneNumber: userInfo.phone_number, - phoneNumberConfirmed: userInfo.phone_number_verified === 'True', - email: userInfo.email, - emailConfirmed: userInfo.email_verified === 'True', + realName: userInfo?.nickname, + phoneNumber: userInfo?.phone_number, + phoneNumberConfirmed: userInfo?.phone_number_verified === 'True', + email: userInfo?.email, + emailConfirmed: userInfo?.email_verified === 'True', }; - if (userInfo.avatarUrl) { + if (userInfo?.avatarUrl) { outgoingUserInfo.avatar = formatUrl(userInfo.avatarUrl); } this.setUserInfo(outgoingUserInfo); diff --git a/apps/vue/src/utils/http/abp/abp.ts b/apps/vue/src/utils/http/abp/abp.ts index fb7b04ed2..fba3a469b 100644 --- a/apps/vue/src/utils/http/abp/abp.ts +++ b/apps/vue/src/utils/http/abp/abp.ts @@ -8,7 +8,6 @@ import { ModuleApiDescriptionModel, } from '/@/api/abp/model/apiDefinition'; import { ParameterBindingSources, UrlBuilder } from '/@/utils/helper/abpApiHelper'; -import { ListResultDto, PagedResultDto } from '/@/api/model/baseModel'; import { useI18n } from '/@/hooks/web/useI18n'; import { useMessage } from '/@/hooks/web/useMessage'; @@ -26,7 +25,7 @@ export class abpRequest { uniqueName?: string; data?: any; params?: any; - }) { + }): Promise> { return this.request>(options); } @@ -37,7 +36,7 @@ export class abpRequest { uniqueName?: string; data?: any; params?: any; - }) { + }): Promise> { return this.request>(options); } diff --git a/apps/vue/src/views/openiddict/applications/components/ApplicationModal.vue b/apps/vue/src/views/openiddict/applications/components/ApplicationModal.vue index 4a764d59d..82df799d4 100644 --- a/apps/vue/src/views/openiddict/applications/components/ApplicationModal.vue +++ b/apps/vue/src/views/openiddict/applications/components/ApplicationModal.vue @@ -1,29 +1,408 @@ diff --git a/apps/vue/src/views/openiddict/applications/components/ApplicationScope.vue b/apps/vue/src/views/openiddict/applications/components/ApplicationScope.vue new file mode 100644 index 000000000..1e61df632 --- /dev/null +++ b/apps/vue/src/views/openiddict/applications/components/ApplicationScope.vue @@ -0,0 +1,68 @@ + + + diff --git a/apps/vue/src/views/openiddict/applications/components/ApplicationTable.vue b/apps/vue/src/views/openiddict/applications/components/ApplicationTable.vue index dbf1bb3f8..c5f9ef590 100644 --- a/apps/vue/src/views/openiddict/applications/components/ApplicationTable.vue +++ b/apps/vue/src/views/openiddict/applications/components/ApplicationTable.vue @@ -1,34 +1,52 @@ diff --git a/apps/vue/src/views/openiddict/applications/components/RedirectUri.vue b/apps/vue/src/views/openiddict/applications/components/RedirectUri.vue new file mode 100644 index 000000000..4a0560911 --- /dev/null +++ b/apps/vue/src/views/openiddict/applications/components/RedirectUri.vue @@ -0,0 +1,60 @@ + + + diff --git a/apps/vue/src/views/openiddict/applications/types/props.ts b/apps/vue/src/views/openiddict/applications/types/props.ts new file mode 100644 index 000000000..16c1e908e --- /dev/null +++ b/apps/vue/src/views/openiddict/applications/types/props.ts @@ -0,0 +1,18 @@ +import { Rule } from 'ant-design-vue/lib/form'; +import { OpenIdConfiguration } from '/@/api/identity-server/model/basicModel'; +import { OpenIddictApplicationDto } from '/@/api/openiddict/open-iddict-application/model'; + +export interface EndPointComponent { + component: string; + uris?: string[]; +} + +export interface ApplicationState { + activeTab: string; + formRules?: Dictionary, + application: OpenIddictApplicationDto; + endPoint: EndPointComponent; + openIdConfiguration?: OpenIdConfiguration; + entityChanged: boolean; + isEdit: boolean; +} \ No newline at end of file diff --git a/apps/vue/src/views/openiddict/components/DisplayNames/DisplayNameForm.vue b/apps/vue/src/views/openiddict/components/DisplayNames/DisplayNameForm.vue new file mode 100644 index 000000000..0bf211b59 --- /dev/null +++ b/apps/vue/src/views/openiddict/components/DisplayNames/DisplayNameForm.vue @@ -0,0 +1,133 @@ + + + + + diff --git a/apps/vue/src/views/openiddict/components/Permissions/PermissionForm.vue b/apps/vue/src/views/openiddict/components/Permissions/PermissionForm.vue new file mode 100644 index 000000000..827289e08 --- /dev/null +++ b/apps/vue/src/views/openiddict/components/Permissions/PermissionForm.vue @@ -0,0 +1,41 @@ + + + diff --git a/apps/vue/src/views/openiddict/components/Properties/PropertyForm.vue b/apps/vue/src/views/openiddict/components/Properties/PropertyForm.vue new file mode 100644 index 000000000..bd82a5b6e --- /dev/null +++ b/apps/vue/src/views/openiddict/components/Properties/PropertyForm.vue @@ -0,0 +1,120 @@ + + + diff --git a/apps/vue/src/views/openiddict/components/Uris/UriForm.vue b/apps/vue/src/views/openiddict/components/Uris/UriForm.vue new file mode 100644 index 000000000..7624f2c97 --- /dev/null +++ b/apps/vue/src/views/openiddict/components/Uris/UriForm.vue @@ -0,0 +1,124 @@ + + + + + diff --git a/aspnet-core/modules/localization/LINGYUN.Abp.AspNetCore.Mvc.Localization/LINGYUN/Abp/AspNetCore/Mvc/Localization/TextAppService.cs b/aspnet-core/modules/localization/LINGYUN.Abp.AspNetCore.Mvc.Localization/LINGYUN/Abp/AspNetCore/Mvc/Localization/TextAppService.cs index c526df74b..066551876 100644 --- a/aspnet-core/modules/localization/LINGYUN.Abp.AspNetCore.Mvc.Localization/LINGYUN/Abp/AspNetCore/Mvc/Localization/TextAppService.cs +++ b/aspnet-core/modules/localization/LINGYUN.Abp.AspNetCore.Mvc.Localization/LINGYUN/Abp/AspNetCore/Mvc/Localization/TextAppService.cs @@ -27,15 +27,11 @@ namespace LINGYUN.Abp.AspNetCore.Mvc.Localization public async virtual Task GetByCultureKeyAsync(GetTextByKeyInput input) { var resource = _localizationOptions.Resources.GetOrDefault(input.ResourceName); - - IEnumerable localizedStrings = new List(); + var localizer = await _localizerFactory.CreateByResourceNameAsync(resource.ResourceName); using (CultureHelper.Use(input.CultureName, input.CultureName)) { - localizedStrings = localizer.GetAllStrings(true) - .OrderBy(l => l.Name); - var result = new TextDto { Key = input.Key, @@ -96,7 +92,7 @@ namespace LINGYUN.Abp.AspNetCore.Mvc.Localization using (CultureHelper.Use(cultureName, cultureName)) { - localizedStrings = localizer.GetAllStrings(true) + localizedStrings = (await localizer.GetAllStringsAsync(true)) .WhereIf(!filter.IsNullOrWhiteSpace(), x => x.Name.Contains(filter)) .OrderBy(l => l.Name); } @@ -109,7 +105,7 @@ namespace LINGYUN.Abp.AspNetCore.Mvc.Localization { using (CultureHelper.Use(targetCultureName, targetCultureName)) { - targetLocalizedStrings = localizer.GetAllStrings(true) + targetLocalizedStrings = (await localizer.GetAllStringsAsync(true)) .WhereIf(!filter.IsNullOrWhiteSpace(), x => x.Name.Contains(filter)) .OrderBy(l => l.Name); } diff --git a/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/LocalizationStoreInMemoryCache.cs b/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/LocalizationStoreInMemoryCache.cs index e28c3d141..eb9239b30 100644 --- a/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/LocalizationStoreInMemoryCache.cs +++ b/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/LocalizationStoreInMemoryCache.cs @@ -175,15 +175,17 @@ public class LocalizationStoreInMemoryCache : ILocalizationStoreCache, ISingleto localizedStrings ??= new LocalizationDictionaryWithCulture(); localizedStrings.Clear(); - var currentCultureLocalizedStrings = new LocalizationDictionary(); - - foreach (var textRecord in textRecords.Where(x => x.ResourceName == resourceRecord.Name)) + // 需要按照不同文化聚合 + foreach (var textRecordByCulture in textRecords.Where(x => x.ResourceName == resourceRecord.Name).GroupBy(x => x.CultureName)) { - currentCultureLocalizedStrings[textRecord.Key] = new LocalizedString(textRecord.Key, textRecord.Value); + var currentCultureLocalizedStrings = new LocalizationDictionary(); + foreach (var textRecord in textRecordByCulture) + { + currentCultureLocalizedStrings[textRecord.Key] = new LocalizedString(textRecord.Key, textRecord.Value); + } + localizedStrings[textRecordByCulture.Key] = currentCultureLocalizedStrings; } - localizedStrings[CultureInfo.CurrentCulture.Name] = currentCultureLocalizedStrings; - LocalizedStrings[resourceRecord.Name] = localizedStrings; } diff --git a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Application.Contracts/LINGYUN/Abp/OpenIddict/Applications/OpenIddictApplicationCreateDto.cs b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Application.Contracts/LINGYUN/Abp/OpenIddict/Applications/OpenIddictApplicationCreateDto.cs index 5a749d5e4..c4f5653ed 100644 --- a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Application.Contracts/LINGYUN/Abp/OpenIddict/Applications/OpenIddictApplicationCreateDto.cs +++ b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Application.Contracts/LINGYUN/Abp/OpenIddict/Applications/OpenIddictApplicationCreateDto.cs @@ -1,8 +1,14 @@ using System; +using System.ComponentModel.DataAnnotations; +using Volo.Abp.OpenIddict.Applications; +using Volo.Abp.Validation; namespace LINGYUN.Abp.OpenIddict.Applications; [Serializable] public class OpenIddictApplicationCreateDto : OpenIddictApplicationCreateOrUpdateDto { + [Required] + [DynamicStringLength(typeof(OpenIddictApplicationConsts), nameof(OpenIddictApplicationConsts.ClientIdMaxLength))] + public string ClientId { get; set; } } diff --git a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Application.Contracts/LINGYUN/Abp/OpenIddict/Applications/OpenIddictApplicationCreateOrUpdateDto.cs b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Application.Contracts/LINGYUN/Abp/OpenIddict/Applications/OpenIddictApplicationCreateOrUpdateDto.cs index e476b97c6..e6f3dff55 100644 --- a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Application.Contracts/LINGYUN/Abp/OpenIddict/Applications/OpenIddictApplicationCreateOrUpdateDto.cs +++ b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Application.Contracts/LINGYUN/Abp/OpenIddict/Applications/OpenIddictApplicationCreateOrUpdateDto.cs @@ -8,10 +8,6 @@ namespace LINGYUN.Abp.OpenIddict.Applications; public abstract class OpenIddictApplicationCreateOrUpdateDto : ExtensibleObject { - [Required] - [DynamicStringLength(typeof(OpenIddictApplicationConsts), nameof(OpenIddictApplicationConsts.ClientIdMaxLength))] - public string ClientId { get; set; } - public string ClientSecret { get; set; } [DynamicStringLength(typeof(OpenIddictApplicationConsts), nameof(OpenIddictApplicationConsts.ConsentTypeMaxLength))] diff --git a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Application.Contracts/LINGYUN/Abp/OpenIddict/Applications/OpenIddictApplicationDto.cs b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Application.Contracts/LINGYUN/Abp/OpenIddict/Applications/OpenIddictApplicationDto.cs index 38518cf9f..b0df93400 100644 --- a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Application.Contracts/LINGYUN/Abp/OpenIddict/Applications/OpenIddictApplicationDto.cs +++ b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Application.Contracts/LINGYUN/Abp/OpenIddict/Applications/OpenIddictApplicationDto.cs @@ -1,11 +1,12 @@ using System; using System.Collections.Generic; using Volo.Abp.Application.Dtos; +using Volo.Abp.Domain.Entities; namespace LINGYUN.Abp.OpenIddict.Applications; [Serializable] -public class OpenIddictApplicationDto : ExtensibleAuditedEntityDto +public class OpenIddictApplicationDto : ExtensibleAuditedEntityDto, IHasConcurrencyStamp { public string ClientId { get; set; } public string ClientSecret { get; set; } @@ -23,4 +24,5 @@ public class OpenIddictApplicationDto : ExtensibleAuditedEntityDto public string Type { get; set; } public string ClientUri { get; set; } public string LogoUri { get; set; } + public string ConcurrencyStamp { get; set; } } diff --git a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Application.Contracts/LINGYUN/Abp/OpenIddict/Applications/OpenIddictApplicationUpdateDto.cs b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Application.Contracts/LINGYUN/Abp/OpenIddict/Applications/OpenIddictApplicationUpdateDto.cs index 2e925c5f0..226d90a3c 100644 --- a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Application.Contracts/LINGYUN/Abp/OpenIddict/Applications/OpenIddictApplicationUpdateDto.cs +++ b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Application.Contracts/LINGYUN/Abp/OpenIddict/Applications/OpenIddictApplicationUpdateDto.cs @@ -1,8 +1,10 @@ using System; +using Volo.Abp.Domain.Entities; namespace LINGYUN.Abp.OpenIddict.Applications; [Serializable] -public class OpenIddictApplicationUpdateDto : OpenIddictApplicationCreateOrUpdateDto +public class OpenIddictApplicationUpdateDto : OpenIddictApplicationCreateOrUpdateDto, IHasConcurrencyStamp { + public string ConcurrencyStamp { get; set; } } diff --git a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Application.Contracts/LINGYUN/Abp/OpenIddict/Authorizations/OpenIddictAuthorizationDto.cs b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Application.Contracts/LINGYUN/Abp/OpenIddict/Authorizations/OpenIddictAuthorizationDto.cs index 45bb46998..3397c8b4f 100644 --- a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Application.Contracts/LINGYUN/Abp/OpenIddict/Authorizations/OpenIddictAuthorizationDto.cs +++ b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Application.Contracts/LINGYUN/Abp/OpenIddict/Authorizations/OpenIddictAuthorizationDto.cs @@ -1,12 +1,14 @@ using System; using System.Collections.Generic; using Volo.Abp.Application.Dtos; +using Volo.Abp.Domain.Entities; namespace LINGYUN.Abp.OpenIddict.Authorizations; [Serializable] -public class OpenIddictAuthorizationDto : ExtensibleAuditedEntityDto +public class OpenIddictAuthorizationDto : ExtensibleAuditedEntityDto, IHasConcurrencyStamp { + public string ConcurrencyStamp { get; set; } public Guid? ApplicationId { get; set; } public DateTime? CreationDate { get; set; } public Dictionary Properties { get; set; } = new Dictionary(); diff --git a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Application.Contracts/LINGYUN/Abp/OpenIddict/Localization/Resources/en.json b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Application.Contracts/LINGYUN/Abp/OpenIddict/Localization/Resources/en.json index a419cc540..ccd7d0c04 100644 --- a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Application.Contracts/LINGYUN/Abp/OpenIddict/Localization/Resources/en.json +++ b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Application.Contracts/LINGYUN/Abp/OpenIddict/Localization/Resources/en.json @@ -9,14 +9,19 @@ "Permissions:Update": "Update", "Permissions:Delete": "Delete", "Permissions:ManagePermissions": "Manage Permissions", - "OpenIddict:Applications:0001": "The application client id {ClientId} already exists!", - "OpenIddict:Scopes:0001": "The scope name {Name} already exists!", + "OpenIddict:001001": "The application client id {ClientId} already exists!", + "OpenIddict:002001": "The scope name {Name} already exists!", "DisplayName:ClientId": "Client Id", "DisplayName:ClientSecret": "Client Secret", + "Description:ClientSecret": "Please copy the key information before saving. You can only reset the key after the data is submitted.", "DisplayName:ConsentType": "Consent Type", "DisplayName:DisplayName": "Display Name", "DisplayName:DisplayNames": "Display Names", + "DisplayName:DefaultDisplayName": "Default Display Name", "DisplayName:Permissions": "Permissions", + "DisplayName:Endpoints": "Endpoints", + "DisplayName:GrantTypes": "Grant Types", + "DisplayName:ResponseTypes": "Response Types", "DisplayName:PostLogoutRedirectUris": "Post Logout Redirect Uris", "DisplayName:Properties": "Properties", "DisplayName:RedirectUris": "Redirect Uris", @@ -39,6 +44,23 @@ "DisplayName:RedemptionDate": "Redemption Date", "DisplayName:ReferenceId": "Reference Id", "DisplayName:LastModificationTime": "Modify time", - "DisplayName:CreationTime": "Creation time" + "DisplayName:CreationTime": "Creation time", + "Applications": "Applications", + "Applications:AddNew": "New Application", + "Authorizations": "Authorizations", + "Scopes": "Scopes", + "Tokens": "Tokens", + "ManagePermissions": "Manage Permissions", + "BasicInfo": "Basic", + "DisplayNames": "Display Names", + "DisplayName:AddNew": "New Display Name", + "Endpoints": "Endpoints", + "Propertites": "Propertites", + "Uri:AddNew": "New Uri", + "Assigned": "Assigned", + "Available": "Available", + "Propertites:New": "New Property", + "Propertites:Key": "Key", + "Propertites:Value": "Value" } } \ No newline at end of file diff --git a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Application.Contracts/LINGYUN/Abp/OpenIddict/Localization/Resources/zh-Hans.json b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Application.Contracts/LINGYUN/Abp/OpenIddict/Localization/Resources/zh-Hans.json index c79ef4142..f7e576790 100644 --- a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Application.Contracts/LINGYUN/Abp/OpenIddict/Localization/Resources/zh-Hans.json +++ b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Application.Contracts/LINGYUN/Abp/OpenIddict/Localization/Resources/zh-Hans.json @@ -9,14 +9,19 @@ "Permissions:Update": "编辑", "Permissions:Delete": "删除", "Permissions:ManagePermissions": "管理权限", - "OpenIddict:Applications:0001": "应用标识 {ClientId} 已经存在!", - "OpenIddict:Scopes:0001": "范围名称 {Name} 已经存在!", + "OpenIddict:001001": "应用标识 {ClientId} 已经存在!", + "OpenIddict:002001": "范围名称 {Name} 已经存在!", "DisplayName:ClientId": "客户端标识", "DisplayName:ClientSecret": "客户端密钥", + "Description:ClientSecret": "请在保存之前复制密钥信息,数据提交后将只能重置密钥.", "DisplayName:ConsentType": "同意类型", "DisplayName:DisplayName": "显示名称", "DisplayName:DisplayNames": "显示名称", + "DisplayName:DefaultDisplayName": "默认显示名称", "DisplayName:Permissions": "权限", + "DisplayName:Endpoints": "端点", + "DisplayName:GrantTypes": "授权类型", + "DisplayName:ResponseTypes": "响应类型", "DisplayName:PostLogoutRedirectUris": "注销后重定向Uri", "DisplayName:Properties": "属性", "DisplayName:RedirectUris": "重定向Uri", @@ -39,6 +44,23 @@ "DisplayName:RedemptionDate": "偿还时间", "DisplayName:ReferenceId": "引用标识", "DisplayName:LastModificationTime": "修改时间", - "DisplayName:CreationTime": "创建时间" + "DisplayName:CreationTime": "创建时间", + "Applications": "应用", + "Applications:AddNew": "新应用", + "Authorizations": "授权", + "Scopes": "范围", + "Tokens": "令牌", + "ManagePermissions": "管理权限", + "BasicInfo": "基本信息", + "DisplayNames": "显示名称", + "DisplayName:AddNew": "新显示配置", + "Endpoints": "端点", + "Propertites": "属性", + "Uri:AddNew": "新Uri", + "Assigned": "可分配的", + "Available": "已拥有的", + "Propertites:New": "新属性", + "Propertites:Key": "属性名称", + "Propertites:Value": "属性值" } } \ No newline at end of file diff --git a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Application.Contracts/LINGYUN/Abp/OpenIddict/OpenIddictApplicationErrorCodes.cs b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Application.Contracts/LINGYUN/Abp/OpenIddict/OpenIddictApplicationErrorCodes.cs index a9a6f0c9b..f6c7a5af1 100644 --- a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Application.Contracts/LINGYUN/Abp/OpenIddict/OpenIddictApplicationErrorCodes.cs +++ b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Application.Contracts/LINGYUN/Abp/OpenIddict/OpenIddictApplicationErrorCodes.cs @@ -6,21 +6,23 @@ public static class OpenIddictApplicationErrorCodes public static class Applications { - public const string ClientIdExisted = Namespace + "Applications:0001"; + public const string Prefix = Namespace + ":001"; + public const string ClientIdExisted = Prefix + "001"; } - public static class Authorizations + public static class Scopes { - + public const string Prefix = Namespace + ":002"; + public const string NameExisted = Prefix + "001"; } - public static class Scopes + public static class Authorizations { - public const string NameExisted = Namespace + "Scopes:0001"; + public const string Prefix = Namespace + ":003"; } public static class Tokens { - + public const string Prefix = Namespace + ":004"; } } diff --git a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Application.Contracts/LINGYUN/Abp/OpenIddict/Scopes/OpenIddictScopeDto.cs b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Application.Contracts/LINGYUN/Abp/OpenIddict/Scopes/OpenIddictScopeDto.cs index 957badaa0..eb37c9199 100644 --- a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Application.Contracts/LINGYUN/Abp/OpenIddict/Scopes/OpenIddictScopeDto.cs +++ b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Application.Contracts/LINGYUN/Abp/OpenIddict/Scopes/OpenIddictScopeDto.cs @@ -1,12 +1,15 @@ using System; using System.Collections.Generic; using Volo.Abp.Application.Dtos; +using Volo.Abp.Domain.Entities; namespace LINGYUN.Abp.OpenIddict.Scopes; [Serializable] -public class OpenIddictScopeDto : ExtensibleAuditedEntityDto +public class OpenIddictScopeDto : ExtensibleAuditedEntityDto, IHasConcurrencyStamp { + public string ConcurrencyStamp { get; set; } + public string Description { get; set; } public Dictionary Descriptions { get; set; } = new Dictionary(); diff --git a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Application.Contracts/LINGYUN/Abp/OpenIddict/Scopes/OpenIddictScopeUpdateDto.cs b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Application.Contracts/LINGYUN/Abp/OpenIddict/Scopes/OpenIddictScopeUpdateDto.cs index f42e0b455..d04095409 100644 --- a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Application.Contracts/LINGYUN/Abp/OpenIddict/Scopes/OpenIddictScopeUpdateDto.cs +++ b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Application.Contracts/LINGYUN/Abp/OpenIddict/Scopes/OpenIddictScopeUpdateDto.cs @@ -1,8 +1,10 @@ using System; +using Volo.Abp.Domain.Entities; namespace LINGYUN.Abp.OpenIddict.Scopes; [Serializable] -public class OpenIddictScopeUpdateDto : OpenIddictScopeCreateOrUpdateDto +public class OpenIddictScopeUpdateDto : OpenIddictScopeCreateOrUpdateDto, IHasConcurrencyStamp { + public string ConcurrencyStamp { get; set; } } diff --git a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Application.Contracts/LINGYUN/Abp/OpenIddict/Tokens/OpenIddictTokenDto.cs b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Application.Contracts/LINGYUN/Abp/OpenIddict/Tokens/OpenIddictTokenDto.cs index 8583b4cc1..6e7c4caef 100644 --- a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Application.Contracts/LINGYUN/Abp/OpenIddict/Tokens/OpenIddictTokenDto.cs +++ b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Application.Contracts/LINGYUN/Abp/OpenIddict/Tokens/OpenIddictTokenDto.cs @@ -1,11 +1,14 @@ using System; using Volo.Abp.Application.Dtos; +using Volo.Abp.Domain.Entities; namespace LINGYUN.Abp.OpenIddict.Tokens; [Serializable] -public class OpenIddictTokenDto : ExtensibleAuditedEntityDto +public class OpenIddictTokenDto : ExtensibleAuditedEntityDto, IHasConcurrencyStamp { + public string ConcurrencyStamp { get; set; } + public Guid? ApplicationId { get; set; } public Guid? AuthorizationId { get; set; } diff --git a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Application/LINGYUN/Abp/OpenIddict/Applications/OpenIddictApplicationAppService.cs b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Application/LINGYUN/Abp/OpenIddict/Applications/OpenIddictApplicationAppService.cs index f634808d5..6393a1ddb 100644 --- a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Application/LINGYUN/Abp/OpenIddict/Applications/OpenIddictApplicationAppService.cs +++ b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Application/LINGYUN/Abp/OpenIddict/Applications/OpenIddictApplicationAppService.cs @@ -1,10 +1,13 @@ using LINGYUN.Abp.OpenIddict.Permissions; using Microsoft.AspNetCore.Authorization; +using OpenIddict.Abstractions; using System; using System.Linq; using System.Threading.Tasks; using Volo.Abp; using Volo.Abp.Application.Dtos; +using Volo.Abp.Data; +using Volo.Abp.OpenIddict; using Volo.Abp.OpenIddict.Applications; namespace LINGYUN.Abp.OpenIddict.Applications; @@ -12,25 +15,29 @@ namespace LINGYUN.Abp.OpenIddict.Applications; [Authorize(AbpOpenIddictPermissions.Applications.Default)] public class OpenIddictApplicationAppService : OpenIddictApplicationServiceBase, IOpenIddictApplicationAppService { - protected IOpenIddictApplicationRepository Repository { get; } + private readonly IAbpApplicationManager _applicationManager; + + private readonly IOpenIddictApplicationRepository _applicationRepository; public OpenIddictApplicationAppService( - IOpenIddictApplicationRepository repository) + IAbpApplicationManager applicationManager, + IOpenIddictApplicationRepository applicationRepository) { - Repository = repository; + _applicationManager = applicationManager; + _applicationRepository = applicationRepository; } public async virtual Task GetAsync(Guid id) { - var application = await Repository.GetAsync(id); + var application = await _applicationRepository.GetAsync(id); return application.ToDto(JsonSerializer); } public async virtual Task> GetListAsync(OpenIddictApplicationGetListInput input) { - var totalCount = await Repository.GetCountAsync(input.Filter); - var entites = await Repository.GetListAsync(input.Sorting, input.SkipCount, input.MaxResultCount, input.Filter); + var totalCount = await _applicationRepository.GetCountAsync(input.Filter); + var entites = await _applicationRepository.GetListAsync(input.Sorting, input.SkipCount, input.MaxResultCount, input.Filter); return new PagedResultDto(totalCount, entites.Select(entity => entity.ToDto(JsonSerializer)).ToList()); @@ -39,16 +46,20 @@ public class OpenIddictApplicationAppService : OpenIddictApplicationServiceBase, [Authorize(AbpOpenIddictPermissions.Applications.Create)] public async virtual Task CreateAsync(OpenIddictApplicationCreateDto input) { - if (await Repository.FindByClientIdAsync(input.ClientId) != null) + if (await _applicationRepository.FindByClientIdAsync(input.ClientId) != null) { throw new BusinessException(OpenIddictApplicationErrorCodes.Applications.ClientIdExisted) .WithData(nameof(OpenIddictApplication.ClientId), input.ClientId); } - var application = new OpenIddictApplication(GuidGenerator.Create()); + var application = new OpenIddictApplication(GuidGenerator.Create()) + { + ClientId = input.ClientId, + }; + application = input.ToEntity(application, JsonSerializer); - application = await Repository.InsertAsync(application); + application = await _applicationRepository.InsertAsync(application); await CurrentUnitOfWork.SaveChangesAsync(); @@ -58,20 +69,24 @@ public class OpenIddictApplicationAppService : OpenIddictApplicationServiceBase, [Authorize(AbpOpenIddictPermissions.Applications.Update)] public async virtual Task UpdateAsync(Guid id, OpenIddictApplicationUpdateDto input) { - var application = await Repository.GetAsync(id); + var application = await _applicationRepository.GetAsync(id); - if (!string.Equals(application.ClientId, input.ClientId) && - await Repository.FindByClientIdAsync(input.ClientId) != null) - { - throw new BusinessException(OpenIddictApplicationErrorCodes.Applications.ClientIdExisted) - .WithData(nameof(OpenIddictApplicationCreateDto.ClientId), input.ClientId); - } + //if (!string.Equals(application.ClientId, input.ClientId) && + // await _applicationRepository.FindByClientIdAsync(input.ClientId) != null) + //{ + // throw new BusinessException(OpenIddictApplicationErrorCodes.Applications.ClientIdExisted) + // .WithData(nameof(OpenIddictApplicationCreateDto.ClientId), input.ClientId); + //} + + application.SetConcurrencyStampIfNotNull(input.ConcurrencyStamp); application = input.ToEntity(application, JsonSerializer); - application = await Repository.UpdateAsync(application); + var cache = LazyServiceProvider.LazyGetRequiredService>(); - await CurrentUnitOfWork.SaveChangesAsync(); + await cache.RemoveAsync(application.ToModel(), GetCancellationToken()); + + await _applicationRepository.UpdateAsync(application); return application.ToDto(JsonSerializer); } @@ -79,8 +94,8 @@ public class OpenIddictApplicationAppService : OpenIddictApplicationServiceBase, [Authorize(AbpOpenIddictPermissions.Applications.Delete)] public async virtual Task DeleteAsync(Guid id) { - await Repository.DeleteAsync(id); + var application = await _applicationRepository.GetAsync(id); - await CurrentUnitOfWork.SaveChangesAsync(); + await _applicationManager.DeleteAsync(application.ToModel()); } } diff --git a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Application/LINGYUN/Abp/OpenIddict/Applications/OpenIddictApplicationExtensions.cs b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Application/LINGYUN/Abp/OpenIddict/Applications/OpenIddictApplicationExtensions.cs index 14e59d6d8..4554cc7d5 100644 --- a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Application/LINGYUN/Abp/OpenIddict/Applications/OpenIddictApplicationExtensions.cs +++ b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Application/LINGYUN/Abp/OpenIddict/Applications/OpenIddictApplicationExtensions.cs @@ -15,7 +15,6 @@ internal static class OpenIddictApplicationExtensions Check.NotNull(dto, nameof(dto)); Check.NotNull(entity, nameof(entity)); - entity.ClientId = dto.ClientId; entity.ClientSecret = dto.ClientSecret; entity.ConsentType = dto.ConsentType; entity.DisplayName = dto.DisplayName; diff --git a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Application/LINGYUN/Abp/OpenIddict/Authorizations/OpenIddictAuthorizationAppService.cs b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Application/LINGYUN/Abp/OpenIddict/Authorizations/OpenIddictAuthorizationAppService.cs index bfe8d44c6..419e0416f 100644 --- a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Application/LINGYUN/Abp/OpenIddict/Authorizations/OpenIddictAuthorizationAppService.cs +++ b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Application/LINGYUN/Abp/OpenIddict/Authorizations/OpenIddictAuthorizationAppService.cs @@ -1,5 +1,6 @@ using LINGYUN.Abp.OpenIddict.Permissions; using Microsoft.AspNetCore.Authorization; +using OpenIddict.Abstractions; using System; using System.Linq; using System.Linq.Dynamic.Core; @@ -13,32 +14,35 @@ namespace LINGYUN.Abp.OpenIddict.Authorizations; [Authorize(AbpOpenIddictPermissions.Authorizations.Default)] public class OpenIddictAuthorizationAppService : OpenIddictApplicationServiceBase, IOpenIddictAuthorizationAppService { - protected IRepository Repository { get; } + private readonly IOpenIddictAuthorizationManager _authorizationManager; + private readonly IRepository _authorizationRepository; public OpenIddictAuthorizationAppService( - IRepository repository) + IOpenIddictAuthorizationManager authorizationManager, + IRepository authorizationRepository) { - Repository = repository; + _authorizationManager = authorizationManager; + _authorizationRepository = authorizationRepository; } [Authorize(AbpOpenIddictPermissions.Authorizations.Delete)] public async virtual Task DeleteAsync(Guid id) { - await Repository.DeleteAsync(id); + var authorization = await _authorizationRepository.GetAsync(id); - await CurrentUnitOfWork.SaveChangesAsync(); + await _authorizationManager.DeleteAsync(authorization.ToModel()); } public async virtual Task GetAsync(Guid id) { - var authorization = await Repository.GetAsync(id); + var authorization = await _authorizationRepository.GetAsync(id); return authorization.ToDto(JsonSerializer); } public async virtual Task> GetListAsync(OpenIddictAuthorizationGetListInput input) { - var queryable = await Repository.GetQueryableAsync(); + var queryable = await _authorizationRepository.GetQueryableAsync(); if (input.ClientId.HasValue) { queryable = queryable.Where(x => x.ApplicationId == input.ClientId); @@ -69,8 +73,14 @@ public class OpenIddictAuthorizationAppService : OpenIddictApplicationServiceBas x.Status.Contains(input.Filter) || x.Type.Contains(input.Filter) || x.Scopes.Contains(input.Filter) || x.Properties.Contains(input.Filter)); } + + var sorting = input.Sorting; + if (sorting.IsNullOrWhiteSpace()) + { + sorting = $"{nameof(OpenIddictAuthorization.CreationTime)} DESC"; + } queryable = queryable - .OrderBy(input.Sorting ?? $"{nameof(OpenIddictAuthorization.CreationTime)} DESC") + .OrderBy(sorting) .PageBy(input.SkipCount, input.MaxResultCount); var totalCount = await AsyncExecuter.CountAsync(queryable); diff --git a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Application/LINGYUN/Abp/OpenIddict/Scopes/OpenIddictScopeAppService.cs b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Application/LINGYUN/Abp/OpenIddict/Scopes/OpenIddictScopeAppService.cs index 3398f40fd..01248e331 100644 --- a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Application/LINGYUN/Abp/OpenIddict/Scopes/OpenIddictScopeAppService.cs +++ b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Application/LINGYUN/Abp/OpenIddict/Scopes/OpenIddictScopeAppService.cs @@ -1,10 +1,13 @@ using LINGYUN.Abp.OpenIddict.Permissions; using Microsoft.AspNetCore.Authorization; +using OpenIddict.Abstractions; using System; using System.Linq; using System.Threading.Tasks; using Volo.Abp; using Volo.Abp.Application.Dtos; +using Volo.Abp.Data; +using Volo.Abp.OpenIddict.Applications; using Volo.Abp.OpenIddict.Scopes; namespace LINGYUN.Abp.OpenIddict.Scopes; @@ -12,26 +15,32 @@ namespace LINGYUN.Abp.OpenIddict.Scopes; [Authorize(AbpOpenIddictPermissions.Scopes.Default)] public class OpenIddictScopeAppService : OpenIddictApplicationServiceBase, IOpenIddictScopeAppService { - protected IOpenIddictScopeRepository Repository { get; } + private readonly IOpenIddictScopeManager _scopeManager; - public OpenIddictScopeAppService(IOpenIddictScopeRepository repository) + private readonly IOpenIddictScopeRepository _scoppeRepository; + + public OpenIddictScopeAppService( + IOpenIddictScopeManager scopeManager, + IOpenIddictScopeRepository scopeRepository) { - Repository = repository; + _scopeManager = scopeManager; + _scoppeRepository = scopeRepository; } [Authorize(AbpOpenIddictPermissions.Scopes.Create)] public async virtual Task CreateAsync(OpenIddictScopeCreateDto input) { - if (await Repository.FindByNameAsync(input.Name) != null) + if (await _scoppeRepository.FindByNameAsync(input.Name) != null) { throw new BusinessException(OpenIddictApplicationErrorCodes.Scopes.NameExisted) .WithData(nameof(OpenIddictScope.Name), input.Name); } var scope = new OpenIddictScope(GuidGenerator.Create()); + scope = input.ToEntity(scope, JsonSerializer); - scope = await Repository.InsertAsync(scope); + scope = await _scoppeRepository.InsertAsync(scope); await CurrentUnitOfWork.SaveChangesAsync(); @@ -41,22 +50,22 @@ public class OpenIddictScopeAppService : OpenIddictApplicationServiceBase, IOpen [Authorize(AbpOpenIddictPermissions.Scopes.Delete)] public async virtual Task DeleteAsync(Guid id) { - await Repository.DeleteAsync(id); + var scope = await _scoppeRepository.GetAsync(id); - await CurrentUnitOfWork.SaveChangesAsync(); + await _scopeManager.DeleteAsync(scope.ToModel()); } public async virtual Task GetAsync(Guid id) { - var scope = await Repository.GetAsync(id); + var scope = await _scoppeRepository.GetAsync(id); return scope.ToDto(JsonSerializer); } public async virtual Task> GetListAsync(OpenIddictScopeGetListInput input) { - var totalCount = await Repository.GetCountAsync(input.Filter); - var entites = await Repository.GetListAsync(input.Sorting, input.SkipCount, input.MaxResultCount, input.Filter); + var totalCount = await _scoppeRepository.GetCountAsync(input.Filter); + var entites = await _scoppeRepository.GetListAsync(input.Sorting, input.SkipCount, input.MaxResultCount, input.Filter); return new PagedResultDto(totalCount, entites.Select(entity => entity.ToDto(JsonSerializer)).ToList()); @@ -65,20 +74,24 @@ public class OpenIddictScopeAppService : OpenIddictApplicationServiceBase, IOpen [Authorize(AbpOpenIddictPermissions.Scopes.Update)] public async virtual Task UpdateAsync(Guid id, OpenIddictScopeUpdateDto input) { - var scope = await Repository.GetAsync(id); + var scope = await _scoppeRepository.GetAsync(id); if (!string.Equals(scope.Name, input.Name) && - await Repository.FindByNameAsync(input.Name) != null) + await _scoppeRepository.FindByNameAsync(input.Name) != null) { throw new BusinessException(OpenIddictApplicationErrorCodes.Scopes.NameExisted) .WithData(nameof(OpenIddictScope.Name), input.Name); } + scope.SetConcurrencyStampIfNotNull(input.ConcurrencyStamp); + scope = input.ToEntity(scope, JsonSerializer); - scope = await Repository.UpdateAsync(scope); + var cache = LazyServiceProvider.LazyGetRequiredService>(); - await CurrentUnitOfWork.SaveChangesAsync(); + await cache.RemoveAsync(scope.ToModel(), GetCancellationToken()); + + await _scoppeRepository.UpdateAsync(scope); return scope.ToDto(JsonSerializer); } diff --git a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Application/LINGYUN/Abp/OpenIddict/Tokens/OpenIddictTokenAppService.cs b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Application/LINGYUN/Abp/OpenIddict/Tokens/OpenIddictTokenAppService.cs index c8fa3fffe..3513853ee 100644 --- a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Application/LINGYUN/Abp/OpenIddict/Tokens/OpenIddictTokenAppService.cs +++ b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Application/LINGYUN/Abp/OpenIddict/Tokens/OpenIddictTokenAppService.cs @@ -1,5 +1,6 @@ using LINGYUN.Abp.OpenIddict.Permissions; using Microsoft.AspNetCore.Authorization; +using OpenIddict.Abstractions; using System; using System.Linq; using System.Linq.Dynamic.Core; @@ -13,31 +14,35 @@ namespace LINGYUN.Abp.OpenIddict.Tokens; [Authorize(AbpOpenIddictPermissions.Tokens.Default)] public class OpenIddictTokenAppService : OpenIddictApplicationServiceBase, IOpenIddictTokenAppService { - protected IRepository Repository { get; } + private readonly IOpenIddictTokenManager _tokenManager; + private readonly IRepository _tokenRepository; - public OpenIddictTokenAppService(IRepository repository) + public OpenIddictTokenAppService( + IOpenIddictTokenManager tokenManager, + IRepository tokenRepository) { - Repository = repository; + _tokenManager = tokenManager; + _tokenRepository = tokenRepository; } [Authorize(AbpOpenIddictPermissions.Tokens.Delete)] public async virtual Task DeleteAsync(Guid id) { - await Repository.DeleteAsync(id); + var token = await _tokenRepository.GetAsync(id); - await CurrentUnitOfWork.SaveChangesAsync(); + await _tokenManager.DeleteAsync(token.ToModel()); } public async virtual Task GetAsync(Guid id) { - var scope = await Repository.GetAsync(id); + var token = await _tokenRepository.GetAsync(id); - return scope.ToDto(); + return token.ToDto(); } public async virtual Task> GetListAsync(OpenIddictTokenGetListInput input) { - var queryable = await Repository.GetQueryableAsync(); + var queryable = await _tokenRepository.GetQueryableAsync(); if (input.ClientId.HasValue) { queryable = queryable.Where(x => x.ApplicationId == input.ClientId); @@ -81,8 +86,15 @@ public class OpenIddictTokenAppService : OpenIddictApplicationServiceBase, IOpen x.Payload.Contains(input.Filter) || x.Properties.Contains(input.Filter) || x.ReferenceId.Contains(input.ReferenceId)); } + + var sorting = input.Sorting; + if (sorting.IsNullOrWhiteSpace()) + { + sorting = $"{nameof(OpenIddictToken.CreationTime)} DESC"; + } + queryable = queryable - .OrderBy(input.Sorting ?? $"{nameof(OpenIddictToken.CreationTime)} DESC") + .OrderBy(sorting) .PageBy(input.SkipCount, input.MaxResultCount); var totalCount = await AsyncExecuter.CountAsync(queryable); diff --git a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain/LINGYUN/Abp/TextTemplating/TemplateDefinitionStoreCacheInvalidator.cs b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain/LINGYUN/Abp/TextTemplating/TemplateDefinitionStoreCacheInvalidator.cs index e9ab66d1a..a38b0f07e 100644 --- a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain/LINGYUN/Abp/TextTemplating/TemplateDefinitionStoreCacheInvalidator.cs +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain/LINGYUN/Abp/TextTemplating/TemplateDefinitionStoreCacheInvalidator.cs @@ -25,17 +25,20 @@ public class TemplateDefinitionStoreCacheInvalidator : private readonly IClock _clock; private readonly IDistributedCache _distributedCache; private readonly AbpDistributedCacheOptions _cacheOptions; + private readonly AbpTextTemplatingCachingOptions _templatingCachingOptions; public TemplateDefinitionStoreCacheInvalidator( IClock clock, IDistributedCache distributedCache, ITemplateDefinitionStoreCache storeCache, - IOptions cacheOptions) + IOptions cacheOptions, + IOptions templatingCachingOptions) { _storeCache = storeCache; _clock = clock; _distributedCache = distributedCache; _cacheOptions = cacheOptions.Value; + _templatingCachingOptions = templatingCachingOptions.Value; } public async virtual Task HandleEventAsync(EntityChangedEventData eventData) @@ -67,7 +70,7 @@ public class TemplateDefinitionStoreCacheInvalidator : await _distributedCache.RemoveAsync(cacheKey); _storeCache.CacheStamp = Guid.NewGuid().ToString(); - _storeCache.LastCheckTime = _clock.Now.AddMinutes(-5); + _storeCache.LastCheckTime = _clock.Now.Subtract(_templatingCachingOptions.TemplateDefinitionsCacheRefreshInterval); } } diff --git a/aspnet-core/services/LY.MicroService.Applications.Single/MicroServiceApplicationsSingleModule.Configure.cs b/aspnet-core/services/LY.MicroService.Applications.Single/MicroServiceApplicationsSingleModule.Configure.cs index ea3bcb9dc..fb96cb3e6 100644 --- a/aspnet-core/services/LY.MicroService.Applications.Single/MicroServiceApplicationsSingleModule.Configure.cs +++ b/aspnet-core/services/LY.MicroService.Applications.Single/MicroServiceApplicationsSingleModule.Configure.cs @@ -84,7 +84,7 @@ public partial class MicroServiceApplicationsSingleModule { builder.AddValidation(options => { - options.AddAudiences("lingyun-abp-application"); + //options.AddAudiences("lingyun-abp-application"); options.UseLocalServer(); diff --git a/aspnet-core/services/LY.MicroService.Applications.Single/appsettings.Development.json b/aspnet-core/services/LY.MicroService.Applications.Single/appsettings.Development.json index 8ff77b2cf..fd007ac3f 100644 --- a/aspnet-core/services/LY.MicroService.Applications.Single/appsettings.Development.json +++ b/aspnet-core/services/LY.MicroService.Applications.Single/appsettings.Development.json @@ -110,7 +110,7 @@ }, "AuthServer": { "UseOpenIddict": false, - "Authority": "http://127.0.0.1:44385/", + "Authority": "http://127.0.0.1:30000/", "ApiName": "lingyun-abp-application", "SwaggerClientId": "InternalServiceClient", "SwaggerClientSecret": "1q2w3E*"