当前位置:网站首页>ABP 6.0.0-rc.1的新特性
ABP 6.0.0-rc.1的新特性
2022-08-09 16:09:00 【dotNET跨平台】
2022-07-26官方发布ABP 6.0.0-rc.1版本,本文挑选了几个新特性进行了介绍,主要包括LeptonX Lite默认主题、OpenIddict模块,以及如何将Identity Server迁移到OpenIddict。据ABP官方公众号介绍,ABP 6.0.0稳定版的计划发布日期为2022-09-06,具体以实际发布日期为准。
一.LeptonX Lite默认主题
LeptonX Lite算是LeptonX Theme的一个简单实现,使用的是Razor Pages技术,而LeptonX Theme在ABP的商业版中有着完整的实现[17]。以前在ABP的MVC启动模板中,使用的是基本主题[18],而ABP 6.0.0-rc.1把LeptonX Lite作为默认主题[19]。
1.基本主题
基本主题的样子如下:
基本主题在使用的时候都安装了哪些包呢?主要是在Web项目中需要安装Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic包,同时在模块类中需要依赖AbpAspNetCoreMvcUiBasicThemeModule模块,安装npm install @abp/aspnetcore.mvc.ui.theme.basic,运行abp install-libs。在wwwroot/styles中自定义global-styles.css文件,并且把该文件配置在模块的ConfigureServices()方法中:
Configure<AbpBundlingOptions>(options =>
{
options.StyleBundles.Configure(BasicThemeBundles.Styles.Global, bundle =>
{
bundle.AddFiles("/styles/global-styles.css");
});
});2.LeptonX Lite主题
LeptonX Lite的样子如下:
LeptonX Lite主题在使用的时候和基本主题差不多,差异如下:
(1)更新或安装CLI
dotnet tool update Volo.Abp.Cli -g --version 6.0.0-rc.1
dotnet tool install Volo.Abp.Cli -g --version 6.0.0-rc.1(2)安装包
dotnet add package Volo.Abp.AspNetCore.Mvc.UI.Theme.LeptonXLite --prerelease说明:务必加上这个--prerelease选项。
(3)依赖模块
[DependsOn(
// Remove BasicTheme module from DependsOn attribute
- typeof(AbpAspNetCoreMvcUiBasicThemeModule),
// Add LeptonX Lite module to DependsOn attribute
+ typeof(AbpAspNetCoreMvcUiLeptonXLiteThemeModule),
)](4)配置服务
Configure<AbpBundlingOptions>(options =>
{
options.StyleBundles.Configure(
// Remove following line
- BasicThemeBundles.Styles.Global,
// Add following line instead
+ LeptonXLiteThemeBundles.Styles.Global
bundle =>
{
bundle.AddFiles("/global-styles.css");
}
);
}); ABP商业版的LeptonX Theme样子如下:
说明:因为平时在开发中使用的前后端分离方式,所以对这块不做过多介绍,了解即可。如果感兴趣,可以深入的学习下Razor Pages、Blazor、Bootstrap、jQuery等技术。
二.OpenIddict模块
这次ABP 6.0.0-rc.1较大的一个变化就是开始使用OpenIddict代替IDS(IdentityServer),因为IDS要收费了。ABP封装的OpenIddict模块源码结构如下:
1.将Demo项目运行起来
在模块的app目录下有6个项目,重点关心的是OpenIddict.Demo.Server和OpenIddict.Demo.API,前者是集成模块的ABP应用,包含2个clients和1个scope。后者是使用authentication认证的ASP.NET Core API应用。配置好OpenIddict.Demo.Server的appsettings.json文件,然后启动OpenIddict.Demo.Server和OpenIddict.Demo.API项目。https://localhost:44303/api/claims接口如下:
OpenIddict.Demo.Server项目启动后,生成的数据库OpenIddict-Demo-Server如下:
2.Volo.Abp.OpenIddict模块
4个Repository分别为:
IOpenIddictApplicationRepository
IOpenIddictScopeRepository
IOpenIddictAuthorizationRepository
IOpenIddictTokenRepository4个Store分别为:
IOpenIddictApplicationStore
IOpenIddictScopeStore
IOpenIddictAuthorizationStore
IOpenIddictTokenStore Repository和Store的关系是什么呢?就是在Store中可以使用Repository来操作上述4种实体。从数据表上看,觉得OpenIddict相对于IDS4还是简单的,继续深入研究OpenIddict可以参考相关资源[6]-[15][21]。
另外讲下怎么将OpenIddict模块运行起来,因为ABP中的模块在依赖其它项目的时候,都使用的源码依赖,将项目依赖(ProjectReference)修改为包依赖(PackageReference)即可。修改后的OpenIddict模块源码下载链接[23]。
三.MAUI启动模板
ABP 6.0.0-rc.1版本的CLI还不支持通过MAUI模板来创建项目,应该要到ABP 6.0.0版本了:
四.将Identity Server迁移到OpenIddict[10]
1.OpenIddict默认授权服务
从ABP 6.0.0版本起,在ABP的启动模板中默认使用OpenIddict作为授权服务,ABP应该会一直支持IDS的,ABP7.0将基于.NET7,如果IDS支持.NET7,那么ABP也会继续跟进的。但是ABP不会支持商业版本的Duende IDS[22]。
2.IDS迁移OpenIddict步骤
(1)将所有Volo的软件包更新为6.x。
(2)使用相应的OpenIddict.*包替换Volo的IdentityServer.*包。比如,Volo.Abp.IdentityServer.Domain到Volo.Abp.OpenIddict.Domain,Volo.Abp.Account.Web.IdentityServer到Volo.Abp.Account.Web.OpenIddict。
(3)使用相应的OpenIddict模块替换所有IdentityServer模块。比如,AbpIdentityServerDomainModule到AbpOpenIddictDomainModule,AbpAccountWebIdentityServerModule到AbpAccountWebOpenIddictModule。
(4)在ProjectNameDbContext类中,重命名ConfigureIdentityServer为ConfigureOpenIddict。
(5)在UseAuthentication后,删除UseIdentityServer,添加UseAbpOpenIddictValidation。
(6)在启动模块中添加如下代码:
public override void PreConfigureServices(ServiceConfigurationContext context)
{
PreConfigure<OpenIddictBuilder>(builder =>
{
builder.AddValidation(options =>
{
options.AddAudiences("ProjectName"); //修改为实际项目的名字
options.UseLocalServer();
options.UseAspNetCore();
});
});
}(7)如果项目不是单独的AuthServer,那么添加ForwardIdentityAuthenticationForBearer:
private void ConfigureAuthentication(ServiceConfigurationContext context)
{
context.Services.ForwardIdentityAuthenticationForBearer(OpenIddictValidationAspNetCoreDefaults.AuthenticationScheme);
}(8)将IdentityServerDataSeedContributor从Domain项目中删除。
(9)创建新版本的项目,并且与现有项目同名。
(10)拷贝新项目的ProjectName.Domain\OpenIddict\OpenIddictDataSeedContributor.cs到项目中,并且基于ProjectName.DbMigrator\appsettings.json来更新appsettings.json,注意修改端口号。
(11)如果在IndexModel中使用IClientRepository,那么拷贝新项目的Index.cshtml.cs和Index.cs到项目中。
(12)在AddAbpOpenIdConnect()方法中,更新scope的名字从role到roles。
(13)在HttpApi.Host项目中,删除options.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]);。
(14)AuthServer不再要求JWT bearer authentication,需要删除它,比如AddJwtBearer和UseJwtTokenMiddleware。
(15)在IDE中尝试编译项目,根据报错来删除和引用代码和命名空间。
(16)如果使用EF Core作为DatabaseProvider,那么迁移和更新数据库。
3.OpenIddict相关的模块包
(1)开源版本
Volo.Abp.OpenIddict.Domain (AbpOpenIddictDomainModule)
Volo.Abp.OpenIddict.Domain.Shared (AbpOpenIddictDomainSharedModule)
Volo.Abp.OpenIddict.EntityFrameworkCore (AbpOpenIddictEntityFrameworkCoreModule)
Volo.Abp.OpenIddict.AspNetCore (AbpOpenIddictAspNetCoreModule)
Volo.Abp.OpenIddict.MongoDB (AbpOpenIddictMongoDbModule)
Volo.Abp.Account.Web.OpenIddict (AbpAccountWebOpenIddictModule)
Volo.Abp.PermissionManagement.Domain.OpenIddict (AbpPermissionManagementDomainOpenIddictModule)(2)商业版本
Volo.Abp.OpenIddict.Pro.Application.Contracts (AbpOpenIddictProApplicationContractsModule)
Volo.Abp.OpenIddict.Pro.Application (AbpOpenIddictProApplicationModule)
Volo.Abp.OpenIddict.Pro.HttpApi.Client (AbpOpenIddictProHttpApiClientModule)
Volo.Abp.OpenIddict.Pro.HttpApi (AbpOpenIddictProHttpApiModule)
Volo.Abp.OpenIddict.Pro.Blazor(AbpOpenIddictProBlazorModule)
Volo.Abp.OpenIddict.Pro.Blazor.Server (AbpOpenIddictProBlazorServerModule)
Volo.Abp.OpenIddict.Pro.Blazor.WebAssembly (AbpOpenIddictProBlazorWebAssemblyModule)
Volo.Abp.OpenIddict.Pro.Web (AbpOpenIddictProWebModule)五.ABP的路线图
貌似进展比较慢,特别是Vue启动模板,千呼万唤都出不来。不过似乎也不重要了,GitHub上面有很多的基于Vue的前端框架,比如vue-element-admin就不错:
参考文献:
[1]ABP v5.3.3和6.0.0-rc.1比较改变:https://github.com/abpframework/abp/compare/5.3.3...6.0.0-rc.1
[2]ABP路线图:https://docs.abp.io/zh-Hans/abp/latest/Road-Map
[3]ABP 6.0.0-rc.1最近发布日志:https://github.com/abpframework/abp/releases
[4]ABP.IO Platform 6.0 RC Has Been Published:https://blog.abp.io/abp/ABP.IO-Platform-6.0-RC-Has-Been-Published
[5]ABP框架功能:https://abp.io/features
[6]Add OpenIddict module:https://github.com/abpframework/abp/pull/12084
[7]ABP OpenIddict Modules:https://github.com/abpframework/abp/blob/dev/docs/en/Modules/OpenIddict.md
[8]Announcement of plan to replace the IdentityServer:https://github.com/abpframework/abp/issues/11989
[9]ABP OpenIddict Modules:https://docs.abp.io/zh-Hans/abp/6.0/Modules/OpenIddict
[10]Migration Identity Server to OpenIddict Guide:https://docs.abp.io/en/abp/6.0/Migration-Guides/IdentityServer_To_OpenIddict
[11]OpenIddict:https://github.com/openiddict
[12]OpenIddict官方文档:https://documentation.openiddict.com/
[13]openiddict/openiddict-core:https://github.com/openiddict/openiddict-core
[14]openiddict/openiddict-samples:https://github.com/openiddict/openiddict-samples
[15]openiddict/openiddict-documentation:https://github.com/openiddict/openiddict-documentation
[16]Integrated MAUI application startup template:https://github.com/abpframework/abp/pull/12962
[17]LeptonX Theme:https://x.leptontheme.com/
[18]ASP.NET Core MVC/Razor Pages: The Basic Theme:https://docs.abp.io/en/abp/latest/UI/AspNetCore/Basic-Theme
[19]LeptonX Lite MVC UI:https://docs.abp.io/en/abp/latest/Themes/LeptonXLite/AspNetCore
[20]ASP.NET Core MVC/Razor Pages: UI Theming:https://docs.abp.io/en/abp/latest/UI/AspNetCore/Theming
[21]abp-samples/Ids2OpenId:https://github.com/abpframework/abp-samples/tree/master/Ids2OpenId
[22]Fair Trade Software License:https://blog.duendesoftware.com/posts/20220111_fair_trade
[23]修改后的OpenIddict模块源码:https://url39.ctfile.com/f/2501739-633476836-599209?p=2096 (访问密码: 2096)
边栏推荐
- Vim practical skills_2. Normal mode and insert mode
- B019 - 甲醛甲烷煤气温湿度时间测试仪
- 网络——数据交换方式
- 【教程3】疯壳·ARM功能手机-整板资源介绍
- 【嵌入式入门篇】嵌入式0基础沉浸式刷题篇1
- 如何通过 open-local 玩转容器本地存储? | 龙蜥技术
- CryoEM粒子(Particle)类型预测的数据集构建
- B44 - 基于stm32蓝牙智能语音识别分类播报垃圾桶
- 【服务器数据恢复】SAN LUN映射出错导致文件系统数据丢失的数据恢复案例
- PHP completes missing dates in date ranges/returns missing dates
猜你喜欢

成为CTO,6个月被老板干死,我损失了1000万

Reasons for slow startup of IDEA (1)

MySQL 5.5 series installation steps tutorial (graphical version)

1.1、VIFB: A Visible and Infrared Image Fusion Benchmark(一个可见光与红外图像融合Benchmark)文章阅读

IDEA启动缓慢原因(一)

2.1、基于并行上下文注意网络的场景文本图像超分辨率

2022年中国第三方证券APP创新专题分析

Leading practice | How the world's largest wine app uses design sprint to innovate the vivino model

央企施工企业数字化转型的灵魂是什么

A42 - 基于51单片机的洗衣机设计
随机推荐
3种特征分箱方法!
聊聊基于docker部署的mysql如何进行数据恢复
智能家居控制系统的功能和特点
价值10亿美元 美国向乌克兰提供单次最大规模安全援助
【教程3】疯壳·ARM功能手机-整板资源介绍
【燃】是时候展现真正的实力了!一文看懂2022华为开发者大赛技术亮点
PGSQL backup tool, which is better?
nacos控制台权限管理
Print the star chart "Recommended Collection"
日志定期压缩、清除
原油等特殊期货开户要求和豁免
The use of websocket in uni-app Disconnection, reconnection, heartbeat mechanism
总结了 110+ 公开专业数据集
Using Prometheus skillfully to extend the kubernetes scheduler
贫血模型与充血模型
@AllArgsConstructor and @NoArgsConstructor
单片机的优点和单片机开发的流程
央企施工企业数字化转型的灵魂是什么
August 9, 2022: Build .NET apps in C# -- use the Visual Studio Code debugger to interactively debug .NET apps (won't, fail)
SQL trill interview: send you a universal template, to?(key, each user to log on to the maximum number of consecutive monthly)