代码之家  ›  专栏  ›  技术社区  ›  Tom Troughton

为SPA的授权码流配置Identity Server 3的正确方法是什么?

  •  0
  • Tom Troughton  · 技术社区  · 5 年前

    我们有一个Identity Server 3的实例,它已经在不同的客户端上使用了一段时间,一些使用隐式流,另一些使用客户端凭据。我们现在有了一个新的要求,需要将一个iOS本地应用程序与此身份提供程序集成。我知道现在不建议使用隐式流,面向公众的应用程序应该使用授权代码流。此类建议的例子有 here here .

    found here 我建议我可以简单地从 connect/token

    {
        'clientId': 'test',
        'flow': 'AuthorizationCode',
        'name': 'test',
        'redirectUris': [ 'http://localhost:8080/' ], 
        'scopes': ['openid','profile']
    }
    

    然后我做如下 GET 向我的IdP请求:

    [ID_PROVIDER]/connect/authorize?client_id=test&redirect_uri=http%3A%2F%2Flocalhost%3A8080&scope=openid%20profile&response_type=code

    http://localhost:8080

    我现在尝试用这个代码来交换JWT令牌 POST [ID_PROVIDER]/connect/token code=[AUTH_CODE]&grant_type=authorization_code&client_id=test&redirect_uri=http%3A%2F%2Flocalhost%3A8080

    invalid_client 错误。当我挖掘它的原木时,我看到一个 ClientSecretValidator

    如果有人能澄清那太好了,谢谢。

    0 回复  |  直到 5 年前
        1
  •  0
  •   danijels    5 年前

    你不能就这样忽略了客户的秘密。对于你的本地情况,我会考虑在应用程序中嵌入秘密。authorize请求仍然需要验证return_uri(本地应用程序的自定义uri方案),如果仍然觉得不安全,您还可以依靠拥有证明(PoP)令牌( https://identityserver.github.io/Documentation/docsv2/pop/overview.html ).

    对于一个SPA应用程序,我会保持它的隐式流,我认为在那里做秘密是没有意义的。