RT.MesWeb.Authentication
1.1.0
dotnet add package RT.MesWeb.Authentication --version 1.1.0
NuGet\Install-Package RT.MesWeb.Authentication -Version 1.1.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="RT.MesWeb.Authentication" Version="1.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="RT.MesWeb.Authentication" Version="1.1.0" />
<PackageReference Include="RT.MesWeb.Authentication" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add RT.MesWeb.Authentication --version 1.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: RT.MesWeb.Authentication, 1.1.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package RT.MesWeb.Authentication@1.1.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=RT.MesWeb.Authentication&version=1.1.0
#tool nuget:?package=RT.MesWeb.Authentication&version=1.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Authentication 使用说明
配置要求
- 需要在
appsettings.json中添加以下配置:
{
"Authentication": {
"AuthEntities": {
"ConnectionString": "Server=127.0.0.1;uid=sa;pwd=password;database=dbname;Trust Server Certificate=true;",
"DatabaseType": "SqlServer" // 可选值:SqlServer / Oracle / DM
},
"SystemAccount": {
"AdminRoleName": "administrator",
"AdminUserName": "admin",
"DefaultPassword": "mes123"
},
"ThreeManager": {
"EnableThreeManager": false,
"SystemManagerUserName": "110101199001010001",
"SecurityManagerUserName": "110101199001010002",
"SecurityAuditorUserName": "110101199001010003",
"SystemManagerRoleName": "系统管理员",
"SecurityManagerRoleName": "安全管理员",
"SecurityAuditorRoleName": "安全审计员",
"SystemManagerPermissions": "",
"SecurityManagerPermissions": "",
"SecurityAuditorPermissions": ""
},
"AccessControl": {
"AllowMultiTerminal": false,
"SessionTimeoutSeconds": 200,
"HeartbeatIntervalSeconds": 60,
"Lockout": {
"MaxFailedAccessAttempts": 5,
"DefaultLockoutMinutes": 30,
"InactiveDaysToLock": 90
},
"PasswordPolicy": {
"ExpiryDays": 180,
"ReminderDaysBeforeExpiry": 7,
"RequiredLength": 8,
"ComplexityRegex": "^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d).+$",
"AllowRepeatWithLast": false
}
}
},
}
数据库要求
- AuthEntities指向的数据库应当全套权限认证体系的数据表
- AuthEntities指向的数据库应当包含以下序列:
- AUTH_SEQ_NO:用于生成数据表编号的序列。
- 数据库中应包含序号生成机制
- SQL Server:应包含生成Sequence的存储过程和Sequence序列对象
- Oracle:包含生成Sequence的序列对象即可
- DM:包含生成Sequence的序列对象即可
使用说明
- Authentication服务配置:
// 在MesWebApiHostModule中增加对AuthenticationApiModule的依赖:
[DependsOn(
typeof(AuthenticationApiModule)
)]
- 需要在主工程内注册基础服务:
builder.Services.AddHttpContextAccessor();
- AuthEntities需要在主工程内进行依赖注入,直接通过以下方法进行注册:
services.ConfigureAuthentication(configuration);
- LoginService需要在主工程内注册扩展登录提供程序,格式如:
services.AddTransient<CustomLoginProvider>();
services.AddTransient<IDictionary<string, ILoginProvider>>(sp =>
new Dictionary<string, ILoginProvider>
{
{ "BS03", sp.GetRequiredService<CustomLoginProvider>() },
});
当前项目依赖Redis服务(Redis服务内容参见RT.MesWeb.Redis);
Authentication有授权检查,需要在主工程内启动授权服务(授权配置参见RT.MesWeb.Framework中的README):
MesLicenseChecker.Current.Start(configuration, hostEnvironment.ContentRootPath, logger);
- 当前项目已经启用多语言支持,需要在主工程内注册多语言资源:
// 在应用程序构建前:
services.AddLocalization(options => options.ResourcesPath = "");
services.Configure<RequestLocalizationOptions>(options =>
{
var supportedCultures = new[]
{
new CultureInfo("zh-CN"), // 中文简体
new CultureInfo("en-US"), // 英文
};
// 设置支持的语言列表
options.SupportedCultures = supportedCultures;
options.SupportedUICultures = supportedCultures;
// 默认语言(无语言标识时使用)
options.DefaultRequestCulture = new RequestCulture("zh-CN");
// 优先级:URL参数 > Cookie > 请求头
options.RequestCultureProviders.Insert(0, new QueryStringRequestCultureProvider());
});
// 在应用程序构建后:
app.UseRequestLocalization(app.Services.GetRequiredService<IOptions<RequestLocalizationOptions>>().Value);
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- Audit.Mvc.Core (>= 30.0.0)
- DM.DmProvider (>= 8.3.1.47463)
- DM.Microsoft.EntityFrameworkCore (>= 9.0.0.43760)
- Microsoft.EntityFrameworkCore.SqlServer (>= 9.0.15)
- Oracle.EntityFrameworkCore (>= 9.23.60)
- RT.MesWeb.Audit (>= 1.1.0)
- RT.MesWeb.Framework (>= 1.0.3)
- RT.MesWeb.Redis (>= 1.0.1)
-
net8.0
- Audit.Mvc.Core (>= 30.0.0)
- DM.DmProvider (>= 8.3.1.47463)
- DM.Microsoft.EntityFrameworkCore (>= 9.0.0.43760)
- Microsoft.EntityFrameworkCore.SqlServer (>= 9.0.15)
- Oracle.EntityFrameworkCore (>= 9.23.60)
- RT.MesWeb.Audit (>= 1.1.0)
- RT.MesWeb.Framework (>= 1.0.3)
- RT.MesWeb.Redis (>= 1.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.