Authenticate and Authorize Web API Endpoints(对 Web API 端点进行身份验证和授权 )
The Web API supports all standard ASP.NET Core authentication techniques that you can specify in the MySolution.WebApi\Startup.cs (MySolution.Blazor.Server\Startup.cs) file. See the following topic for more information: Authentication.
Web API支持可以在MySolutions. WebApi\Startup.cs(MySolutions.Blazor.Server\Startup.cs)文件中指定的所有标准ASP.NET核心身份验证技术。有关详细信息,请参阅以下主题:身份验证。
If you use the Solution Wizard to create a Web API project, enable authentication on the Choose Security page:
如果您使用解决方案向导创建Web API项目,请在选择安全页面上启用身份验证:
Standard Authentication(标准认证)
The wizard generates JWT authentication scaffolding code for the Web API.
该向导为Web API生成JWT身份验证脚手架代码。
OAuth2 Authentication(OAuth2认证)
The wizard adds the JWT and Azure AD scaffolding code to the MySolution.WebApi\appsettings.json file.
该向导将JWT和Azure AD脚手架代码添加到MySolutions. WebApi\appset.json文件中。
Windows Active Directory(Windows活动目录)
The wizard adds the JWT scaffolding code to the MySolution.WebApi\appsettings.json file and the scaffolding code for Windows Active Directory to the MySolution.WebApi\Properties\launchSettings.json file.
该向导将JWT脚手架代码添加到MySolutions. WebApi\appsetings.json文件中,并将Windows Active Directory的脚手架代码添加到MySolutions.WebApi\Properties\LaunchSetings.json文件中。
See the following topics for information on how to configure the authentication scaffolding code and manually enable authentication:
有关如何配置身份验证脚手架代码和手动启用身份验证的信息,请参阅以下主题:
- Configure the JWT Authentication(配置JWT身份验证)
- Configure the OAuth2 Azure Authentication(配置OAuth2 Azure身份验证)
Configure Authorization for Endpoints or Protect Business Object Data(为端点配置授权或保护业务对象数据)
You must define Security System permissions for business objects and properties you want to expose through a Web API Service (both built-in and custom endpoints). We do not recommend that you expose business object data to all users without security protection.
您必须为要通过Web API服务(内置和自定义终结点)公开的业务对象和属性定义安全系统权限。我们不建议您在没有安全保护的情况下向所有用户公开业务对象数据。
You can configure permissions using one of the following methods:
您可以使用以下方法之一配置权限:
- In the code of the ModuleUpdater class (look for the Updater.cs file, because there may be different locations depending on your project configuration).(在ModuleUpdater类的代码中(查找Updater. cs文件,因为根据您的项目配置可能有不同的位置)。)
- In the administrative UI powered by XAF Blazor/WinForms (this feature requires the Universal license).(在由XAF Blazor/WinForms提供支持的管理UI中(此功能需要通用许可证)。)
For more information, refer to the following concepts and examples:
有关详细信息,请参阅以下概念和示例:
- Create Predefined Users, Roles and Permissions in the Database(在数据库中创建预定义的用户、角色和权限)
- How to restrict inter-departmental data access using Security Permissions (EF Core)(如何使用安全权限(EF Core)限制部门间数据访问)