Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

grafana with gitlab oauth2 login.OAuthLogin(NewTransportWithCode)

I have a grafana container (5.3.1) configuration where I already have a google oauth working and I added a gitlab oauth using variables

  - GF_AUTH_GITLAB_ENABLED=true
  - GF_AUTH_GITLAB_CLIENT_ID=ID
  - GF_AUTH_GITLAB_CLIENT_SECRET=SECRET
  - GF_AUTH_GITLAB_AUTH_URL=https://GITLABURL/oauth/authorize
  - GF_AUTH_GITLAB_TOKEN_URL=https://GITLABURL/oauth/token
  - GF_AUTH_GITLAB_API_URL=https://GITLABURL/api/v4
  - GF_AUTH_GITLAB_ALLOWED_GROUPS=GROUPE
  - GF_AUTH_GITLAB_ALLOW_SIGN_UP=true
  - GF_AUTH_GITLAB_SCOPES=read_user openid api

That seems to works as when I create the application in gitlab, the authentication seems ok and I'm redirected to grafana which give me the error :

login.OAuthLogin(NewTransportWithCode)

I tried to upgrade the scopes of the oauth, grafana and gitlab side but I get the same error and the same error log:

t=2018-10-18T09:40:10+0000 lvl=info msg="Request Completed" logger=context userId=0 orgId=0 uname= method=GET path=/ status=302 remote_addr=IP time_ms=72 size=37 referer=https://GRAFANA/
t=2018-10-18T09:40:12+0000 lvl=info msg="Request Completed" logger=context userId=0 orgId=0 uname= method=GET path=/login/gitlab status=302 remote_addr=IP time_ms=0 size=342 referer=https://GITLAB/grafana/login
t=2018-10-18T09:40:12+0000 lvl=eror msg=login.OAuthLogin(NewTransportWithCode) logger=context userId=0 orgId=0 uname= error="oauth2: cannot fetch token: 401 Unauthorized\nResponse: {\"error\":\"invalid_client\",\"error_description\":\"Client authentication failed due to unknown client, no client authentication included, or unsupported authentication method.\"}"
t=2018-10-18T09:40:12+0000 lvl=eror msg="Request Completed" logger=context userId=0 orgId=0 uname= method=GET path=/login/gitlab status=500 remote_addr=IP time_ms=72 size=1732 referer=https://GITLAB/

I also tried to deactivate the google oauth but that didn't help.

I'm still looking on my side for a solution but if anyone as an idea on how to configure this gitlab oauth to work it would be great.

like image 966
night-gold Avatar asked Oct 18 '18 10:10

night-gold


1 Answers

This one works for me:

docker run \
  -d \
  -p 443:3000 \
  --name=grafana \
  -v $PWD/certs/:/certs/ \
  -e GF_SECURITY_ADMIN_PASSWORD=secret \
  -e GF_AUTH_GITLAB_ENABLED=true \
  -e GF_AUTH_GITLAB_CLIENT_ID=03ca83645e2c479d7f247eda8344aef8cb9f1bae77726101d18b9a91a4878208 \
  -e GF_AUTH_GITLAB_CLIENT_SECRET=12da2d61d4dc3d4d7393bf8cbbb200cbc8a361d76394ac235130311be5c898f8 \
  -e GF_AUTH_GITLAB_AUTH_URL=https://gitlab.com/oauth/authorize \
  -e GF_AUTH_GITLAB_TOKEN_URL=https://gitlab.com/oauth/token \
  -e GF_AUTH_GITLAB_API_URL=https://gitlab.com/api/v4 \
  -e GF_AUTH_GITLAB_ALLOW_SIGN_UP=true \
  -e GF_AUTH_GITLAB_ALLOWED_GROUPS=group \
  -e "GF_AUTH_GITLAB_SCOPES=read_user openid api" \
  -e GF_SERVER_CERT_FILE=/certs/domain.cer \
  -e GF_SERVER_CERT_KEY=/certs/domain.key \
  -e GF_SERVER_PROTOCOL=https \
  -e GF_SERVER_DOMAIN=domain.tld \
  -e GF_SERVER_ROOT_URL=https://domain.tld \
  grafana/grafana

Is anyone able to provide Docker example with real configuration (client id/secret/...) which will have a mentioned problem. Otherwise, other people are not able to replicate your issue.

like image 142
Jan Garaj Avatar answered Oct 31 '22 10:10

Jan Garaj