首页 文章

IdentityServer4是否具有验证访问令牌的API?

提问于
浏览
1

我有一个使用IdentityServer4构建的Identity Server .

我有2个应用程序(1个.NET,1个PHP)相互访问资源,并使用此Identity Server验证请求标头中的访问令牌 .

在Identity Server应用程序中,我添加了一个客户端配置如下

clients.Add(
            new Client
            {
                ClientId = "myClientId",
                ClientName = "My Client Name",
                ClientSecrets = new List<Secret>
                {
                    new Secret("secret".Sha256())
                },
                AllowedGrantTypes = GrantTypes.ClientCredentials,
                AllowedScopes = new List<string>
                {
                    "php.es.api"
                }
            });

从.NET应用程序,我可以通过调用范围为“php.es.api”的方法RequestClientCredentialsAsync轻松获取访问令牌 . 然后添加此承载令牌并将请求发送到PHP API .

问题是我不知道IdentityServer4是否具有API,以便PHP应用程序可以调用它来验证访问令牌 . 我谷歌并没有找到任何关于此API的文档提及 .

我是否必须在用于PHP或其他非.NET应用程序的Identity Server应用程序中编写新API以验证令牌?

PHP应用程序的.NET应用程序访问资源如下 .

IdentityServer4

1 回答

  • 1

    有一个名为introspection endpoint的标准 endpoints ,IdentityServer4支持它 . 你最好的办法是在PHP中找到一个oauth客户端 . 如果您使用自包含承载令牌,则可以在不需要反向信道通信的情况下验证令牌,因为承载令牌由您的提供商签名,并且您的提供商在验证令牌所需的发现文档中列出了其密钥(/.well -known / OpenID的配置) . 我对PHP并不太熟悉,无法指出正确的方向,那里有很酷的库

相关问题