Symfony 5 中的 Oauth2 错误:键路径"file:///var/oauth/private.key"不存在或不可读



我使用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#

这是 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表中创建的,其中包含两个参数标识符和机密。 非常感谢您的回复! 阿兰·朱夫

这只是配置中的拼写错误吗?

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

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

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

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

相关内容

最新更新