☰
Orchard Core OpenID Connect 模块实战指南:授权服务器、令牌验证与 OIDC 客户端集成
2026/9/28 2:23:11 网站建设 项目流程
  • CMS
  • 后端
  • Web框架

【免费下载链接】OrchardCore

Orchard Core is an open-source modular and multi-tenant application framework built with ASP.NET Core, and a content management system (CMS) built on top of that framework.

项目地址:https://gitcode.com/gh_mirrors/or/OrchardCore
点击查看免费下载

OrchardCore.OpenId是 Orchard Core 内置的 OpenID Connect 功能模块,它让 Orchard Core 既能充当符合 OpenID Connect 与 OAuth 2.0 标准的授权服务器(身份提供方 IdP),也能作为客户端接入外部身份提供方,同时还提供令牌验证与管理界面能力。读完本文,你将掌握该模块五大特性的职责划分、服务端/客户端/验证端三类配置项的完整含义、recipe 步骤的编写方法,以及生产环境中签名证书的生成与部署要点。

OpenId 模块与五大特性总览

OrchardCore.OpenId模块在 Manifest.cs 中声明了五个可独立启用的功能特性,它们之间有明确的依赖关系:

特性 ID名称说明依赖
OrchardCore.OpenIdOpenID Connect Core Services提供支撑其他所有 OpenID Connect 特性的基础服务,仅可被依赖启用(EnabledByDependencyOnly = true)无
OrchardCore.OpenId.ClientOpenID Connect Client Integration允许通过外部 OpenID Connect 授权服务器(身份提供方)认证用户Core、OrchardCore.Users.ExternalAuthentication
OrchardCore.OpenId.ManagementOpenID Connect Management UI在管理后台提供管理应用、Scope 与权限的界面Core
OrchardCore.OpenId.ServerOpenID Connect Authorization Server使 Orchard Core 充当授权服务器/身份提供方,签发令牌Core、Management
OrchardCore.OpenId.ValidationOpenID Connect Token Validation验证本地授权服务器或其他可信服务器签发的令牌Core

特性常量定义在 OpenIdConstants.cs 的OpenIdConstants.Features中。从依赖结构可以看出:要启用授权服务器,管理 UI 会被一并启用;而令牌验证与客户端集成均只依赖核心服务,可以独立部署在单独租户上。

OpenID Connect Core Services:一切的基石

该特性提供支撑其他所有 OpenID Connect 特性的基础服务,涵盖安全通信、令牌处理与用户认证所必需的基础组件。从 Startup.cs 的Startup类可以看到,它注册了 OpenIddict 核心服务以及 Orchard 自己的迁移、管理器和默认的 YesSql 存储:

services.AddOpenIddict() .AddCore(options => { options.AddOrchardMigrations() .UseOrchardManagers() .UseYesSql(); });

如源码注释所述,默认的 YesSql 存储可以替换为其他数据库(例如引用 OpenIddict.EntityFrameworkCore 包并在选项中注册)。核心服务的实现分布在 OrchardCore.OpenId.Core 项目中:包括应用、授权、Scope、令牌四类抽象管理器(IOpenIdApplicationManager、IOpenIdAuthorizationManager、IOpenIdScopeManager、IOpenIdTokenManager),对应的 YesSql 存储实现、索引与迁移,以及IUserInfoClaimsProvider这类用于扩展 UserInfo 端点声明输出的钩子。

OpenID Connect Management UI:后台管理界面

启用后会在 Orchard Core 管理后台新增"OpenID Connect"导航分组(见 ManagementAdminMenu.cs),支持:

  • 管理 OpenID Connect 应用(创建、编辑、删除);
  • 定义与修改 Scope(作用域);
  • 配置应用权限(允许的端点、流程与响应类型)。

对应的控制器分别为ApplicationController、ScopeController,视图位于 Views 目录下,前端脚本见 Assets/ts 中的application-create.ts、application-edit.ts等。应用与 Scope 的持久化通过OpenIdApplicationManager/OpenIdScopeManager与 YesSql 存储完成。

OpenID Connect Authorization Server:让 Orchard Core 成为身份提供方

该特性使 Orchard Core 可作为集中式身份提供方,允许外部应用认证用户并管理访问控制。其底层由开源库 OpenIddict 可以看到服务注册方式:AddOpenIddict().AddServer()组合UseAspNetCore()、UseDataProtection(),并注册了PersistStoresHandler用于持久化令牌与授权。

两个重要的架构事实(README 明确说明):

  • 授权服务器会自行验证/connect/userinfo端点收到的访问令牌,因此当前租户无需启用令牌验证特性;
  • 要验证签发的令牌,请启用"OpenID Connect Token Validation"特性。

支持的认证流程

授权服务器支持以下标准流程(对应各 RFC/规范文档):

  • Authorization Code Flow(授权码流程,OpenID Connect Core 规范);
  • Implicit Flow(隐式流程);
  • Hybrid Flow(混合流程);
  • Client Credentials Grant(客户端凭证授权,RFC 6749);
  • Resource Owner Password Grant(资源所有者密码授权,RFC 6749)。

此外,设置项中还包含 Refresh Token 流程与 PKCE(Proof Key for Code Exchange)支持。

服务器设置项详解

服务器配置可通过管理后台的OpenID Connect设置菜单配置,也可以通过 recipe 步骤配置。设置模型定义在 OpenIdServerSettings.cs,核心设置项如下:

  • Token Format(访问令牌格式):两种取值——
    • DataProtection:默认格式,使用 ASP.NET Core Data Protection 堆栈加密的非标准不透明令牌;
    • JsonWebToken:使用带签名的标准 JWT 令牌。默认加密,但可以关闭访问令牌加密,以便第三方资源服务器直接使用 Orchard OpenID 服务器签发的 JWT。
  • Authority:Orchard 作为身份服务器使用的 URL(即Issuer,见 OpenIdServerConfiguration.cs 中的options.Issuer = settings.Authority)。
  • Signing Certificate Store Location:签名证书存储位置,取值为CurrentUser/LocalMachine。
  • Signing Certificate Store Name:签名证书存储名称,可取AddressBook/AuthRoot/CertificateAuthority/Disallowed/My/Root/TrustedPeople/TrustedPublisher。
  • Signing Certificate Thumbprint:签名证书指纹(建议不要使用与 SSL 相同的证书)。
  • Encryption Certificate Store Location / Store Name / Thumbprint:加密证书的存储位置、存储名称与指纹(同样建议不要与 SSL 证书混用)。
  • Enable Token Endpoint:启用令牌端点。
  • Enable Authorization Endpoint:启用授权端点。
  • Enable Logout Endpoint:启用登出端点。
  • Enable User Info Endpoint:启用用户信息端点。
  • Allow Password Flow:允许密码流程,要求启用 Token Endpoint(RFC 6749 §1.3.3)。
  • Allow Client Credentials Flow:允许客户端凭证流程,要求启用 Token Endpoint(RFC 6749 §1.3.4)。
  • Allow Authorization Code Flow:允许授权码流程,要求启用 Authorization 与 Token Endpoint(OpenID Connect Core 规范 CodeFlowAuth)。
  • Allow Implicit Flow:允许隐式流程,要求启用 Authorization Endpoint(ImplicitFlowAuth)。
  • Allow Refresh Token Flow:允许使用刷新令牌刷新访问令牌,可与密码流程、授权码流程、混合流程组合使用(RefreshTokens)。
  • Require Proof Key for Code Exchange:全局 PKCE 开关,对所有已注册客户端生效(无论应用设置页中的 "Require PKCE" 标志是否设置)。

服务器设置 Recipe 步骤示例

以下是一个完整的OpenIdServerSettingsrecipe 步骤(继承自原文档,可直接用于部署场景):

{ "name": "OpenIdServerSettings", "TestingModeEnabled": false, "AccessTokenFormat": "JsonWebToken", // JsonWebToken 或 DataProtection "Authority": "https://www.orchardproject.net", "SigningCertificateStoreLocation": "LocalMachine", // 更多信息:StoreLocation 枚举文档 "SigningCertificateStoreName": "My", // 更多信息:StoreName 枚举文档 "SigningCertificateThumbprint": "27CCA66EF38EF46CD9022431FB1FF0F2DF5CA1D7", "EncryptionCertificateStoreLocation": "LocalMachine", "EncryptionCertificateStoreName": "My", "EncryptionCertificateThumbprint": "BC34460ABEA2D576EA68E8FFCFEEB3F45C94FB0F", "EnableTokenEndpoint": true, "EnableAuthorizationEndpoint": false, "EnableIntrospectionEndpoint": false, "EnableLogoutEndpoint": true, "EnablePushedAuthorizationEndpoint": false, "EnableRevocationEndpoint": false, "EnableUserInfoEndpoint": true, "AllowPasswordFlow": true, "AllowClientCredentialsFlow": false, "AllowAuthorizationCodeFlow": false, "AllowRefreshTokenFlow": false, "AllowImplicitFlow": false, "RequireProofKeyForCodeExchange": false, "RequirePushedAuthorizationRequests": false, "RequireEndSessionConfirmation": true }

使用通用 Settings Recipe 步骤配置服务器

除专用步骤外,所有 OpenID Connect 设置都可以通过通用的settingsrecipe 步骤配置。服务器设置如下:

{ "steps": [ { "name": "settings", "OpenIdServerSettings": { "TestingModeEnabled": false, "TokenFormat": "JsonWebToken", "Authority": "https://www.example.com", "AuthorizationEndpointPath": "/connect/authorize", "LogoutEndpointPath": "/connect/logout", "TokenEndpointPath": "/connect/token", "UserinfoEndpointPath": "/connect/userinfo", "IntrospectionEndpointPath": "/connect/introspect", "RevocationEndpointPath": "/connect/revoke", "EnableTokenEndpoint": true, "EnableAuthorizationEndpoint": true, "EnableLogoutEndpoint": true, "EnableUserInfoEndpoint": true, "EnableIntrospectionEndpoint": false, "EnableRevocationEndpoint": false, "AllowPasswordFlow": false, "AllowClientCredentialsFlow": false, "AllowAuthorizationCodeFlow": true, "AllowRefreshTokenFlow": true, "AllowImplicitFlow": false, "AllowHybridFlow": false, "RequireProofKeyForCodeExchange": true, "RequireEndSessionConfirmation": true, "UseRollingRefreshTokens": false, "UseReferenceAccessTokens": false } } ] }

各属性说明:

属性类型说明
TestingModeEnabledBoolean是否启用测试模式(使用临时签名/加密密钥)
TokenFormatString访问令牌格式,取值DataProtection、JsonWebToken
AuthorityStringOrchard 作为身份服务器使用的权威 URL
AuthorizationEndpointPathString授权端点路径
LogoutEndpointPathString登出端点路径
TokenEndpointPathString令牌端点路径
UserinfoEndpointPathString用户信息端点路径
IntrospectionEndpointPathString内省端点路径
RevocationEndpointPathString吊销端点路径
EnableTokenEndpointBoolean是否启用令牌端点
EnableAuthorizationEndpointBoolean是否启用授权端点
EnableLogoutEndpointBoolean是否启用登出端点
EnableUserInfoEndpointBoolean是否启用用户信息端点
EnableIntrospectionEndpointBoolean是否启用内省端点
EnableRevocationEndpointBoolean是否启用吊销端点
AllowPasswordFlowBoolean是否允许资源所有者密码流程
AllowClientCredentialsFlowBoolean是否允许客户端凭证流程
AllowAuthorizationCodeFlowBoolean是否允许授权码流程
AllowRefreshTokenFlowBoolean是否允许刷新令牌流程
AllowImplicitFlowBoolean是否允许隐式流程
AllowHybridFlowBoolean是否允许混合流程
RequireProofKeyForCodeExchangeBoolean是否对所有客户端强制 PKCE
RequireEndSessionConfirmationBoolean即使带有有效id_token_hint,用户是否也必须确认登出,默认为true
UseRollingRefreshTokensBoolean是否使用滚动刷新令牌
UseReferenceAccessTokensBoolean是否使用引用型访问令牌

端点路径会被 ServerStartup.ConfigureAsync 映射为具体的 MVC 路由(如/connect/authorize→Access.Authorize、/connect/userinfo→UserInfo.Me)。值得注意的细节是:只有当服务器设置通过校验时,这些路由与认证处理器才会被注册(见GetServerSettingsAsync中对ValidateSettingsAsync的调用),这也是 Startup.cs 中手动移除 OpenIddict 内置认证初始化器的原因——避免在设置无效时注册处理器导致运行时异常。

OpenID Connect Client Integration:应用配置

OpenID Connect 应用既可以通过管理后台的OpenID Connect Apps菜单(依赖 Management UI 特性)配置,也可以通过 recipe 步骤配置。

应用配置项

  • Id:唯一标识符。
  • Client Id:应用的客户端标识,客户端请求有效令牌时必须提供。
  • Display Name:与当前应用关联的显示名称。
  • Type:两种类型——
    • Confidential(机密型):与令牌端点、吊销端点通信时必须发送客户端密钥,保证只有合法客户端能交换授权码或获取刷新令牌;
    • Public(公开型):通信时无需使用客户端密钥。
  • Client Secret:与应用关联的密码,配置为 Confidential 类型时必填。从 OpenIdApplicationSettings.cs 的实现可以看出,当类型为 Public 时,客户端密钥会被置空(descriptor.ClientSecret = null)。
  • Flows(流程):若全局 OpenID Connect 设置允许该流程,应用也可启用对应流程:
    • Allow Password Flow:要求启用 Token Endpoint(RFC 6749 §1.3.3);
    • Allow Client Credentials Flow:要求启用 Token Endpoint(RFC 6749 §1.3.4);
    • Allow Authorization Code Flow:要求启用 Authorization 与 Token Endpoint(CodeFlowAuth);
    • Allow Implicit Flow:要求启用 Authorization Endpoint(ImplicitFlowAuth);
    • Allow Refresh Token Flow:允许使用刷新令牌刷新访问令牌,可与密码流程、授权码流程、混合流程组合使用(RefreshTokens)。
  • Normalized RoleNames:仅在启用 Client Credentials Flow 时需要,决定应用通过该流程认证后被分配的角色。
  • Redirect Options:仅在需要 Implicit Flow、Authorization Code Flow 或 Hybrid Flow 时需要:
    • Logout Redirect Uri:登出回调 URL;
    • Redirect Uri:回调 URL。
  • Skip Consent:设置用户登录后是否需要完成同意表单。
  • Advanced Parameters:允许设置随授权请求发送的附加参数(默认参数由上述选项生成)。
  • Require PKCE:为注册应用应用 PKCE,请确保所用客户端库支持 PKCE。

应用 Recipe 步骤示例

{ "name": "openidapplication", "ClientId": "openidtest", "DisplayName": "Open Id Test", "Type": "Confidential", "ClientSecret": "MyPassword", "EnableTokenEndpoint": true, "EnableAuthorizationEndpoint": false, "EnableLogoutEndpoint": true, "EnableUserInfoEndpoint": true, "AllowPasswordFlow": true, "AllowClientCredentialsFlow": false, "AllowAuthorizationCodeFlow": false, "AllowRefreshTokenFlow": false, "AllowImplicitFlow": false, "RequireProofKeyForCodeExchange": false, "RequirePushedAuthorizationRequests": false }

Recipe 步骤由 Recipes/OpenIdApplicationStep.cs 处理。从源码可以观察到应用配置与 OpenIddict 权限模型之间的映射逻辑:例如允许授权码/混合流程会添加GrantTypes.AuthorizationCode与Endpoints.Authorization权限;公开型应用在隐式/混合流程下还会获得id_token token、token、code token等响应类型权限,而机密型应用不会(见 OpenIdApplicationSettings.cs)。Scope 权限以scp:前缀形式写入权限集合。

OpenID Connect Scopes 配置

Scope 可以通过管理后台的OpenID Connect Scopes菜单(依赖 Management UI 特性)配置,也可通过 recipe 步骤配置。

属性说明
NameScope 的唯一名称
Display Name与当前 Scope 关联的显示名称
Description描述该 Scope 在系统中的用途
Tenants基于租户名称构建受众(audience)
Additional resources基于提供的空格分隔字符串构建受众

Scope Recipe 步骤示例

{ "name": "OpenIdScope", "Description": "A scope to provide audience for remote clients", "DisplayName": "External Audience Scope", "ScopeName": "custom_scope", "Resources": "my_recipient" }

Recipe 步骤由 Recipes/OpenIdScopeStep.cs 处理,Scope 数据持久化在OrchardCore.OpenId.Core的 YesSql 模型中(OpenIdScope.cs)。首次启用服务器特性时,DefaultScopesMigration会注册默认 Scope(见 Migrations/DefaultScopesMigration.cs)。

配置证书:Windows / IIS 场景

生产环境中授权服务器需要签名证书与(可选)加密证书。Windows / IIS 下可用多种工具生成签名证书。

使用 IIS Server Manager(控制有限)

  1. 进入 Server Certificates;
  2. 选择 Create Self-Signed Certificate。

使用 PowerShell(完全可控)

# 参见 New-SelfSignedCertificate 文档 New-SelfSignedCertificate ` -Subject "connect.example.com" ` -FriendlyName "Example.com Signing Certificate" ` -CertStoreLocation "cert:\LocalMachine\My" ` -KeySpec Signature ` -KeyUsage DigitalSignature ` -KeyUsageProperty Sign ` -TextExtension @("2.5.29.37={text}1.3.6.1.5.5.7.3.1") ` -KeyExportPolicy NonExportable ` -KeyAlgorithm RSA ` -KeyLength 4096 ` -HashAlgorithm SHA256 ` -NotAfter (Get-Date).AddDays(825) ` -Provider "Microsoft Enhanced RSA and AES Cryptographic Provider"

该片段必须以管理员身份运行。它生成一个 4096 位的签名证书,存入机器存储(LocalMachine\My),并返回证书指纹——你需要将该指纹填入 OpenID Connect 设置 recipe,或用它导出证书。请务必按你的实际需求修改此示例!

多节点环境的证书分发

在多节点环境中,建议先用-KeyExportPolicy Exportable创建证书,然后通过 MMC 证书管理单元或 PowerShellExport-PfxCertificate将证书(PFX)导出到安全位置,最后在每个节点上以不可导出的方式导入(Import-PfxCertificate的默认行为):

# 在生成证书的机器上执行: $mypwd = ConvertTo-SecureString -String "MySecretPassword123" -Force -AsPlainText Export-PfxCertificate -FilePath C:\securelocation\connect.example.com.pfx cert:\localMachine\my\thumbprintfromnewselfsignedcertificate -Password $mypwd # 在目标节点上执行: $mypwd = ConvertTo-SecureString -String "MySecretPassword123" -Force -AsPlainText Import-PfxCertificate -FilePath C:\securelocation\connect.example.com.pfx cert:\localMachine\my -Password $mypwd

重要:为了让OrchardCore.OpenId模块使用证书密钥签名,它需要对存储中的证书拥有Read访问权限。可通过多种方式授予:

  • MMC.exe:
    1. 添加"证书"管理单元(计算机账户);
    2. 右键相关证书,选择"所有任务"→"管理私钥";
    3. 添加相关身份(如 IIS AppPool\PoolName)——Add → Advanced → Locations 选择 IIS 服务器机器名 → Find Now → 在搜索结果中选择iisServerMachineName\IIS_IUSRS(仅示例)→ OK;
    4. 在权限中勾选 Allow Read。
  • WinHttpCertCfg.exe(授予完全控制):
    1. 例如:winhttpcertcfg -g -c LOCAL_MACHINE\My -s connect.example.com -a AppPoolIdentityName

在 Azure 中使用证书

若站点托管在 Azure,按以下步骤使用证书:

  1. 将证书上传到 Azure 门户站点的 'TLS/SSL settings' 页面;
  2. 在 Azure 站点设置页面新增一项:
    • Key:WEBSITE_LOAD_CERTIFICATES
    • Value:[证书指纹]
  3. 在CurrentUser>My证书存储中选择该证书。

OpenID Connect Token Validation:令牌验证

该特性负责验证由 Orchard Core 自身授权服务器或其他可信服务器签发的令牌,支持 JWT 与 OpenID Connect discovery,确保跨分布式应用的令牌验证安全可靠。对应 ValidationStartup 中的AddOpenIddict().AddValidation()组合(UseAspNetCore()、UseDataProtection()、UseSystemNetHttp())。

两种验证方式:

  • 验证 Orchard OpenID 服务器签发的令牌:可将验证特性配置为透明地复用另一个已启用授权服务器特性的租户的服务器配置;
  • 验证远程服务器签发的令牌:适用于支持 JWT 与 OpenID Connect discovery 的远程服务器。

验证设置项

属性说明
Authorization server tenant运行 OpenID Connect Server 的租户。若未选择,则必须提供以下属性
Authority签发令牌的远程 OpenID Connect 服务器地址
Audience必须校验的令牌预期接收方

验证设置 Recipe 步骤示例

{ "name": "OpenIdValidationSettings", "Audience": "my_recipient", "Authority": "https://idp.domain.com" }

使用通用 Settings Recipe 步骤配置验证

{ "steps": [ { "name": "settings", "OpenIdValidationSettings": { "Audience": "your-resource-server", "Authority": "https://idp.example.com", "DisableTokenTypeValidation": false, "Tenant": "", "MetadataAddress": "" } } ] }
属性类型说明
AudienceString令牌验证使用的受众
AuthorityStringOpenID Connect discovery 的权威 URL
DisableTokenTypeValidationBoolean是否禁用访问令牌类型验证
TenantString用于本地服务器验证的 Orchard 租户
MetadataAddressString覆盖元数据发现地址(用于非标准提供方)

设置模型见 OpenIdValidationSettings.cs,其中Tenant为空且Authority为空时,验证服务会尝试使用Authorization server tenant指定租户的服务器配置(Tenant属性即对应此配置)。验证通过后,OpenIdValidationConfiguration.cs 会将验证处理器注册到认证管线,并配置 API 授权策略。

OIDC Client:对接外部身份提供方

该特性(对应 ClientStartup)从外部 OpenID Connect 身份提供方认证用户。行为要点:

  • 若站点允许新用户注册,则本地用户与外部登录会被关联;
  • 若收到 "email" 声明且找到本地用户,则认证后外部登录会与该账户关联。

OpenId 配置项

配置可通过管理后台的OpenID Connect设置菜单或 recipe 步骤设置。设置模型见 OpenIdClientSettings.cs。

  • Display Name:IdP 的显示名称,显示在登录表单中。
  • Authority:进行 OpenIdConnect 调用时使用的权威 URL。
  • ClientId:查询中的client_id部分。
  • CallbackPath:从身份提供方登出后,用户代理返回的应用基路径内的请求路径(对应post_logout_redirect_uri)。
  • SignedOut CallbackPath:登出的回调端点,默认为/signout-callback-oidc。
  • SignedOut Redirect Uri:应用从身份提供方登出后,用户代理被重定向到的 URI(在SignedOutCallbackPath被调用之后发生)。
  • Scopes:除openid和profile之外的额外 Scope。
  • Response Mode:配置响应模式。若为fragment或query,则只允许 Code Authentication Flow。
  • Supported Flows:选择一种 OIDC 流程:
    • Code Authentication Flow(授权码流程):
    • Hybrid Authentication Flow(混合流程):
      • 使用code id_token响应类型;
      • 使用code id_token token响应类型;
      • 使用code token响应类型;
    • Implicit Authentication Flow(隐式流程):
      • 使用id_token响应类型;
      • 使用id_token token响应类型。
  • Client Secret:用于 code 或 hybrid 这类机密流程。

客户端设置 Recipe 步骤示例

{ "name": "OpenIdClientSettings", "Authority": "http://localhost:44300/t1", "DisplayName": "Orchard (t1) IdP", "ClientId": "orchard_t2", "CallbackPath": "/signin-oidc", "SignedOutCallbackPath": "/signout-callback-oidc", "Scopes": "email phone", "ResponseMode": "form_post", "ResponseType": "code id_token", "ClientSecret": "secret" }

使用通用 Settings Recipe 步骤配置客户端

{ "steps": [ { "name": "settings", "OpenIdClientSettings": { "DisplayName": "External Identity Provider", "Authority": "https://idp.example.com", "ClientId": "your-client-id", "ClientSecret": "your-client-secret", "CallbackPath": "/signin-oidc", "SignedOutCallbackPath": "/signout-callback-oidc", "ResponseType": "code", "ResponseMode": "form_post", "Scopes": "openid profile email" } } ] }
属性类型说明
DisplayNameString外部身份提供方的显示名称
AuthorityStringOpenID Connect 提供方的权威 URL。必填
ClientIdString客户端标识。必填
ClientSecretString客户端密钥
CallbackPathString用户代理返回时的回调路径
SignedOutCallbackPathString登出后的回调路径
SignedOutRedirectUriString登出后重定向的 URI
ResponseTypeStringOAuth 2.0 响应类型,取值code、id_token、id_token token、code id_token、code token、code id_token token
ResponseModeString响应模式,取值form_post、fragment、query
ScopesString请求的空格分隔 Scope 列表

客户端配置由 OpenIdClientConfiguration.cs 转化为 ASP.NET Core 的OpenIdConnectOptions,从而接入标准的 OpenID Connect 中间件处理登录流程。

部署与运维补充要点

  • 部署步骤支持:服务器与验证设置均提供部署步骤(Deployment Step),见 Deployment 目录下的OpenIdServerDeploymentSource/OpenIdValidationDeploymentSource,可随部署计划在站点间迁移配置。
  • 速率限制:启用OrchardCore.RateLimits时,ServerRateLimitsStartup(Startup.cs)会为Access.Token路由(POST)配置基于 IP 的滑动窗口限流(密码认证策略,10 次/窗口),用于防护令牌端点被暴力攻击。
  • 后台清理任务:OpenIdBackgroundTask(Tasks/OpenIdBackgroundTask.cs)负责清理过期的授权与令牌记录,保持存储数据量可控。
  • 角色联动:OpenIdApplicationRoleRemovedEventHandler会在角色被删除时同步清理相关应用的 Normalized RoleNames 配置,避免客户端凭证流程引用已删除的角色。

以上所有配置与代码路径均可在当前仓库中直接查阅:模块源码目录、核心抽象与存储目录、模块文档。建议在实际部署前,先在开发环境以TestingModeEnabled: true验证流程,再切换到真实证书配置,并始终为令牌端点保留速率限制防护。

  • CMS
  • 后端
  • Web框架

【免费下载链接】OrchardCore

Orchard Core is an open-source modular and multi-tenant application framework built with ASP.NET Core, and a content management system (CMS) built on top of that framework.

项目地址:https://gitcode.com/gh_mirrors/or/OrchardCore
点击查看免费下载
上一篇:Flurl性能优化终极指南:5个客户端缓存与连接复用最佳实践
下一篇:终极指南:faceai换脸功能揭秘 - 基于Dlib的智能面部融合算法完全解析

创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考

需要专业的网站建设服务?

联系我们获取免费的网站建设咨询和方案报价,让我们帮助您实现业务目标

立即咨询