Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/mercurial/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/reporting-services/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Identityserver4 如何从Identity Server应用程序执行外部身份验证请求?_Identityserver4 - Fatal编程技术网

Identityserver4 如何从Identity Server应用程序执行外部身份验证请求?

Identityserver4 如何从Identity Server应用程序执行外部身份验证请求?,identityserver4,Identityserver4,我正在使用Identity Server 4,需要与外部授权API交互。 授权过程必须如下所示: 客户端将基于用户数据生成的令牌发送到IdentityServer IdentityServer创建具有特定标头和正文的POST请求 IdentityServer将此请求发送到ExternalAuthApi并获取包含令牌的响应 IdentityServer将该令牌返回给客户端(并缓存它) 我查阅了有关外部身份提供者的文档,但它需要客户端和ExternalAuthApi之间以某种方式进行交互,这是我需要

我正在使用Identity Server 4,需要与外部授权API交互。 授权过程必须如下所示:

  • 客户端将基于用户数据生成的令牌发送到IdentityServer
  • IdentityServer创建具有特定标头和正文的POST请求
  • IdentityServer将此请求发送到ExternalAuthApi并获取包含令牌的响应
  • IdentityServer将该令牌返回给客户端(并缓存它)
  • 我查阅了有关外部身份提供者的文档,但它需要客户端和ExternalAuthApi之间以某种方式进行交互,这是我需要避免的


    如何实现IdentityServer和ExternalAuthApi之间的直接交互?有可能吗?

    我使用ITokenCreationService实现了这一点

    我已经创建了自己的实现并添加到服务中:
    services.AddTransient()
    第三方服务现在在
    CreateTokenAsync
    like中调用

        public override async Task<string> CreateTokenAsync(Token token)
        {
            var provider = token.GetProviderClaim();
            switch (provider)
            {
                case "3rdPartySystem_A":
                    return this._systemAClient.RequestToken(token.TransformToSystemAFormat());
                case "anotherSystem":
                    return this._anotherSystemClient.RequestToken(token.TransformToAnotherSystemFormat());
                default:
                    return await base.CreateTokenAsync(token);
            }
        }
    
    public override async任务CreateTokenAsync(令牌令牌)
    {
    var provider=token.GetProviderClaim();
    交换机(提供程序)
    {
    案例“第三方系统A”:
    返回此项。_systemAClient.RequestToken(token.transformToSystemFormat());
    案例“其他系统”:
    返回此。\u另一个SystemClient.RequestToken(token.TransformTootherSystemFormat());
    违约:
    返回wait base.CreateTokenAsync(令牌);
    }
    }