Authenticating with GitLab:

I’am using SonarQube 8.9.6, on a docker local installation.
I can use the default admin account or another personal user account (with the same admin rights).

In the external gitlab server (v 14.4.1),:
I’ve set the data mentioned in Creating a GitLab OAuth app.
Callback URL is http://localhost:9100/sonar/oauth2/callback/gitlab
and scopes are api, read_user.

These data have been copied in the personal user account, using the menu Administration > Configuration > General Settings > ALM Integrations > GitLab > Authentication. source.

At the end, button for accessing to sonarqube via gitlab is here but there is this error message:

Authorize SonarQube to use your account?
and this one, once the credentials provided:
You’re not authorized to access this page. Please contact the administrator.
Home

the acces.log of sonarqube server is:

172.17.0.1 - - [14/Feb/2022:17:24:30 +0000] "GET /sonar/images/gitlab-icon-rgb.svg HTTP/1.1" 304 - "http://localhost:9100/sonar/sessions/new?return_to=%2Fsonar%2F" "Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0" "AX5UutIEcv3Cauk7ABrQ"
172.17.0.1 - - [14/Feb/2022:17:25:07 +0000] "GET /sonar/sessions/init/gitlab?return_to=%2Fsonar%2F HTTP/1.1" 302 - "http://localhost:9100/sonar/sessions/new?return_to=%2Fsonar%2F" "Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0" "AX5UutIEcv3Cauk7ABrR"
172.17.0.1 - - [14/Feb/2022:17:25:38 +0000] "GET /sonar/oauth2/callback/gitlab?code=5651f39d0421ce9383763276e0e79b14015076adde6158da28defbc65dfca4af&state=l3tc88lthrlg4ro355a1m4r3em HTTP/1.1" 302 - "-" "Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0" "AX5UutIEcv3Cauk7ABrS"
172.17.0.1 - - [14/Feb/2022:17:25:39 +0000] "GET /sonar/sessions/unauthorized HTTP/1.1" 200 - "-" "Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0" "AX5UutIEcv3Cauk7ABrT"
172.17.0.1 - - [14/Feb/2022:17:25:39 +0000] "GET /sonar/api/navigation/global HTTP/1.1" 401 - "http://localhost:9100/sonar/sessions/unauthorized" "Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0" "AX5UutIEcv3Cauk7ABrU"
172.17.0.1 - - [14/Feb/2022:17:25:39 +0000] "GET /sonar/api/l10n/index?locale=en-US&ts=2022-02-14T17%3A24%3A30%2B0000 HTTP/1.1" 304 - "http://localhost:9100/sonar/sessions/unauthorized" "Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0" "AX5UutIEcv3Cauk7ABrV"
172.17.0.1 - - [14/Feb/2022:17:25:39 +0000] "GET /sonar/apple-touch-icon-180x180.png HTTP/1.1" 200 6087 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0" "AX5UutIEcv3Cauk7ABrW"
172.17.0.1 - - [14/Feb/2022:17:25:39 +0000] "GET /sonar/favicon.ico HTTP/1.1" 200 5430 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0" "AX5UutIEcv3Cauk7ABrX"

Hi,

According to the docs you cite, the Redirect URI should start with your SonarQube URL. So unless GitLab and SonarQube are hosted on the same server, a localhost URL isn’t going to work. And if they are hosted on the same server, I still wouldn’t expect a 9100 port to work.

Can you take a look at that?

 
Ann

oups sorry I’am using docker and my container had not been restarted properly.
So it works, I mean I can log in using an account of gitlab. It seems that localhost in accepted in my CentOs environment. Thank you for your answer. I’ll try to watch if there are anu issues in my configuration but it seems ok now.

1 Like