这是基于vue-vben-admin 模板适用于abp vNext的前端管理项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

5.9 KiB

客户端管理

**本文档引用的文件** - [ClientDto.cs](file://aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Application.Contracts/LINGYUN/Abp/IdentityServer/Clients/Dto/ClientDto.cs) - [ClientCreateOrUpdateDto.cs](file://aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Application.Contracts/LINGYUN/Abp/IdentityServer/Clients/Dto/ClientCreateOrUpdateDto.cs) - [ClientUpdateDto.cs](file://aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Application.Contracts/LINGYUN/Abp/IdentityServer/Clients/Dto/ClientUpdateDto.cs) - [ClientAppService.cs](file://aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Application/LINGYUN/Abp/IdentityServer/Clients/ClientAppService.cs) - [ClientController.cs](file://aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.HttpApi/LINGYUN/Abp/IdentityServer/Clients/ClientController.cs)

目录

  1. 简介
  2. 客户端实体设计
  3. 客户端类型与安全配置
  4. 客户端管理API
  5. 客户端与资源关系
  6. 最佳实践

简介

本文档详细介绍了认证服务中的客户端管理功能。客户端是身份认证系统中的核心实体,代表了需要访问受保护资源的应用程序或服务。通过本文档,您将了解客户端实体的设计、配置、管理以及与API资源和身份资源的关系。

客户端实体设计

客户端实体包含多个属性,用于定义客户端的行为和安全策略。主要属性包括:

  • ClientId: 客户端的唯一标识符,用于在系统中识别客户端。
  • ClientName: 客户端的名称,用于显示和识别。
  • Description: 客户端的描述信息。
  • ClientUri: 客户端的主页URL。
  • LogoUri: 客户端的logo URL。
  • Enabled: 客户端是否启用。
  • ProtocolType: 使用的协议类型,如OpenID Connect。
  • RequireClientSecret: 是否需要客户端密钥。
  • RequireConsent: 是否需要用户同意。
  • AllowRememberConsent: 是否允许记住用户同意。
  • AllowedGrantTypes: 允许的授权类型列表。
  • RedirectUris: 重定向URI列表,用于OAuth 2.0授权流程。
  • AllowedCorsOrigins: 允许的跨域源列表。
  • PostLogoutRedirectUris: 注销后重定向URI列表。
  • ClientSecrets: 客户端密钥列表。
  • AllowedScopes: 允许的作用域列表。
  • Claims: 客户端声明列表。
  • Properties: 客户端属性列表。

客户端实体属性

  • ClientId: string, 最大长度200
  • ClientName: string, 最大长度200
  • Description: string, 最大长度200
  • ClientUri: string, 最大长度2000
  • LogoUri: string, 最大长度2000
  • ProtocolType: string, 最大长度200
  • AllowedIdentityTokenSigningAlgorithms: string, 最大长度1000
  • FrontChannelLogoutUri: string, 最大长度2000
  • BackChannelLogoutUri: string, 最大长度2000
  • ClientClaimsPrefix: string, 最大长度200
  • PairWiseSubjectSalt: string, 最大长度200
  • UserCodeType: string, 最大长度100

客户端生命周期属性

  • IdentityTokenLifetime: int, 身份令牌生命周期(秒)
  • AccessTokenLifetime: int, 访问令牌生命周期(秒)
  • AuthorizationCodeLifetime: int, 授权码生命周期(秒)
  • ConsentLifetime: int?, 同意生命周期(秒)
  • AbsoluteRefreshTokenLifetime: int, 绝对刷新令牌生命周期(秒)
  • SlidingRefreshTokenLifetime: int, 滑动刷新令牌生命周期(秒)
  • DeviceCodeLifetime: int, 设备码生命周期(秒)
  • UserSsoLifetime: int?, 用户单点登录生命周期(秒)

Section sources

  • ClientDto.cs

客户端类型与安全配置

系统支持不同类型的客户端,每种类型有不同的安全配置要求:

机密客户端 (Confidential Client)

机密客户端是指能够安全地存储客户端密钥的客户端,通常用于服务器端应用。这类客户端需要配置客户端密钥,并且通常使用授权码模式或客户端凭证模式进行认证。

机密客户端安全配置

  • RequireClientSecret: true
  • AllowedGrantTypes: authorization_code, client_credentials
  • RequireConsent: true
  • AllowRememberConsent: true

公共客户端 (Public Client)

公共客户端是指无法安全存储客户端密钥的客户端,通常用于单页应用(SPA)或移动应用。这类客户端不使用客户端密钥,而是依赖其他安全机制如PKCE。

公共客户端安全配置

  • RequireClientSecret: false
  • AllowedGrantTypes: authorization_code, implicit
  • RequirePkce: true
  • AllowPlainTextPkce: false
  • AllowAccessTokensViaBrowser: true

客户端安全属性

  • RequirePkce: 是否要求PKCE(Proof Key for Code Exchange)保护授权码流程。
  • AllowPlainTextPkce: 是否允许明文PKCE代码验证方法。
  • AllowAccessTokensViaBrowser: 是否允许通过浏览器传递访问令牌。
  • FrontChannelLogoutSessionRequired: 前通道注销是否需要会话。
  • BackChannelLogoutSessionRequired: 后通道注销是否需要会话。
  • AlwaysIncludeUserClaimsInIdToken: 是否始终在ID令牌中包含用户声明。
  • UpdateAccessTokenClaimsOnRefresh: 刷新访问令牌时是否更新声明。
  • EnableLocalLogin: 是否启用本地登录。

Section sources

  • ClientDto.cs

客户端管理API

系统提供了RESTful API来创建和管理客户端。以下是主要的API端点:

创建客户端

POST /api/identity-server/clients

创建新客户端,需要提供客户端ID、名称和允许的授权类型。

获取客户端列表

GET /api/identity-server/clients

获取分页