0

我使用 Symfony 5 和 oauth2 捆绑包 trikoder/oauth2-bundle 在 Web 应用程序中构建了一个 oauth2 服务器,以便登录其他客户端站点的用户。当客户端站点激活授权请求时,我收到此错误。我在 Stackoverflow 上阅读了这个问题的答案,但他们回答了 Laravel 问题,而不是 Symfony 5。这是 .env 文件:

###> trikoder/oauth2-bundle ###

备用 OAuth2 加密密钥

请使用安全值覆盖它:https ://oauth2.thephpleague.com/installation/#string-password

OAUTH2_STRING_PASSWORD=4YUuCt#################x2wsEdg

OAUTH2_ENCRYPTION_KEY=def############################################# ########cbf

< trikoder/oauth2-bundle

这是 config/packages/trikoder_oauth2.yaml 文件

trikoder_oauth2:

authorization_server:
    private_key: /var/oauth/private.key                     # Change this
    private_key_passphrase: null                            # Passphrase of the private key, if any

    encryption_key: '%env(string:OAUTH2_ENCRYPTION_KEY)%'   # (Optional) Change this
    encryption_key_type: "defuse"
    # How long the issued access token should be valid for.
        # The value should be a valid interval: http://php.net/manual/en/dateinterval.construct.php#refsect1-dateinterval.construct-parameters
    access_token_ttl:     PT1H

        # How long the issued refresh token should be valid for.
        # The value should be a valid interval: http://php.net/manual/en/dateinterval.construct.php#refsect1-dateinterval.construct-parameters
    refresh_token_ttl:    P1M

        # How long the issued auth code should be valid for.
        # The value should be a valid interval: http://php.net/manual/en/dateinterval.construct.php#refsect1-dateinterval.construct-parameters
    auth_code_ttl:        PT10M



resource_server:
    public_key: /var/oauth/public.key                       # Change this

persistence:
    doctrine: null

public.key 和 private.key 在 var/auth/ 路径中。客户端是在 oauth2_client 表中创建的,带有两个参数 identifier 和 secret。非常感谢您的回复!阿兰·朱夫

4

2 回答 2

0

这只是您的配置中的错字吗?

/var/ oauth /private.key 而不是您描述的 /var/ auth /private.key?

于 2020-05-19T08:34:20.393 回答
0

您只需更改 public.key 和 private.key 的文件所有者,如下所示:

sudo chown -R www:data:www-data public.key private.key

这应该可以解决您的问题,如果不让我知道,我会帮助您。

于 2020-08-03T11:58:22.773 回答