0

我正在使用 JS 应用程序遍历代码示例并试图了解如何确保系统安全。

AFAIK,在将令牌传递给资源 API 服务器以允许访问之后,必须验证身份服务器范围内提供的机密。

因此,在身份服务器上,我们为“api”资源范围设置了一个秘密,例如:

      new Scope
            {
                Name = "api",
                DisplayName = "Access to API",
                Description = "This will grant you access to the API",
                ScopeSecrets = new List<Secret>
                {
                    new Secret("api-secret".Sha256())
                },
                Type = ScopeType.Resource
            },

在资源 API 上,我们必须验证此令牌是否由受信任的颁发者授予:

  // Wire token validation
        app.UseIdentityServerBearerTokenAuthentication(new IdentityServerBearerTokenAuthenticationOptions
        {
            Authority = "https://localhost:44300",

            ClientId = "api",
            //ClientSecret = "api-secret",
            ClientSecret = "api-secret-changed",

            RequiredScopes = new[] { "api" }
        });

但是,我已经更改了代码中的 ClientSecret,但用户仍然经过身份验证,我可以访问所有声明。

那么,令牌验证的秘密机制是如何工作的呢?

除了提供给 Scope API 的秘密之外,我们是否还需要在客户端级别提供秘密?

4

1 回答 1

1

作用域上的秘密用于与自省端点的通信。

如果令牌是引用令牌,或者ValidationEndpoint在令牌验证中间件上显式设置验证模式,则使用自省。

于 2016-09-30T15:08:48.897 回答