0

我正在尝试为名为 SonarQube(linting 工具)的应用程序设置 Bitbucket OAuth 使用者进行身份验证。按照指南,看起来我已经正确设置了所有内容 - https://github.com/SonarSource/sonar-auth-bitbucket

回调 URL 设置为https://myserver/oauth2/callback。当我直接导航到它时,我得到“您无权访问此页面。请联系管理员。” - 这可能是有效的。我没有任何尾随斜杠或不正确的方案。

需要注意的一件事是我使用的是 nginx 反向代理。当标头 X-Forwarded-For 和 X-Forwarded-Proto 设置不正确时,我确实读过这个问题。请注意,我在这方面的故障排除技巧并不是最好的,但是当我使用开发工具并导航到https://myserver/oauth2/callback时,我没有看到这些标头设置。但是,当我运行时nginx -T | grep proxy_set_header,它似乎是正确的。


root@01008bf897b1:/app# nginx -T | grep proxy_set_header
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
proxy_set_header Host $http_host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $proxy_connection;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $proxy_x_forwarded_proto;
proxy_set_header Proxy "";

此外,当我在进行 Bitbucket 身份验证时查看 URL 时,我注意到它在 redirect_uri 中不包含 https:

如果我有 https,如下所示,它实际上会提示“确认访问您的帐户”:

https://bitbucket.org/site/oauth2/authorize?response_type=code&client_id=Fs5Fq2e5VqfduRs4xD&redirect_uri=https%3A%2F%2Fmyserver%2Foauth2%2Fcallback%2Fbitbucket&scope=account

我的反向代理设置是否不正确 - 代理标头?可能的 Bitbucket 问题?任何帮助,将不胜感激!

4

2 回答 2

1

有同样的问题,并通过将实际的 Sonar URL 添加到配置中来解决。

如果将其留空,则默认值为 localhost

在配置->常规下

声纳配置屏幕

于 2019-11-05T19:10:39.540 回答
0

这与代理无关,而是 SonarQube 中的配置问题。

我最初sonar.core.serverBaseURL=https://mysonarqube.com在我的 docker 容器中设置了一个环境变量,当我签入 UI 时,我认为它没有被应用,它是空白的。然后我将 env 变量更新为,sonar.core.serverBaseURL=notworking以便稍后对其进行故障排除/删除,但它似乎设置了该值,即使 UI 显示了正确的值。一旦更新它就可以工作(以及我所有的其他身份验证集成,例如 Google 和 GitHub)。

于 2019-08-30T18:19:38.373 回答