如何实现 IClientSecretValidator
How to implement IClientSecretValidator
我想在我的 IdentityServer4 主机中实现一个自定义客户端密码验证器。我的问题是,如何在我的 startup.cs 文件中向身份服务器构建器注册它?
有一种注册常规秘密验证器的方法,但我找不到用于添加 ClientSecretValidator 的方法。
IdentityServer4 上下文中的 'secret validator' 指的是客户端机密 (see the description of the 'AddSecretValidator' extension method under 'Additional Services') 的验证器。这可能就是您要查找的内容,除非您希望在同一 class.
中实现用于在请求中查找机密、获取客户端并验证机密的代码
The implementation of IClientSecretValidator just orchestrates the usage of the ISecretParser (the default implementation of this interface will find the client secret on the incoming request), the IClientStore (the chosen implementation of this interface will retrieve the configured client so the actual secret can be retrieved), and the ISecretValidator (the default implementation of this interface will validate the secret in the request against the 'parsedSecret' retrieved from the client).
要回答您最初的问题,您不能通过构建器添加自己的 ClientSecretValidator,尽管您可以替换现有的。为此,您必须进行类似于 services.Replace(ServiceDescriptor.Transient<IClientSecretValidator, CustomClientSecretValidator>());
的调用
有关替换已在 ASP.NET Core 的依赖注入系统中注册的服务的更多信息,请参见
我想在我的 IdentityServer4 主机中实现一个自定义客户端密码验证器。我的问题是,如何在我的 startup.cs 文件中向身份服务器构建器注册它? 有一种注册常规秘密验证器的方法,但我找不到用于添加 ClientSecretValidator 的方法。
IdentityServer4 上下文中的 'secret validator' 指的是客户端机密 (see the description of the 'AddSecretValidator' extension method under 'Additional Services') 的验证器。这可能就是您要查找的内容,除非您希望在同一 class.
中实现用于在请求中查找机密、获取客户端并验证机密的代码The implementation of IClientSecretValidator just orchestrates the usage of the ISecretParser (the default implementation of this interface will find the client secret on the incoming request), the IClientStore (the chosen implementation of this interface will retrieve the configured client so the actual secret can be retrieved), and the ISecretValidator (the default implementation of this interface will validate the secret in the request against the 'parsedSecret' retrieved from the client).
要回答您最初的问题,您不能通过构建器添加自己的 ClientSecretValidator,尽管您可以替换现有的。为此,您必须进行类似于 services.Replace(ServiceDescriptor.Transient<IClientSecretValidator, CustomClientSecretValidator>());
有关替换已在 ASP.NET Core 的依赖注入系统中注册的服务的更多信息,请参见