docker-gitlab icon indicating copy to clipboard operation
docker-gitlab copied to clipboard

google aswell as github oauth callback url broken

Open GottZ opened this issue 11 years ago • 15 comments

hello there. today i successfully updated from 7.8.4 to 7.12.0 i previously had an issue related to a similar problem: https://github.com/sameersbn/docker-gitlab/issues/276

well.. how should i start.. this is my config: https://gist.github.com/GottZ/9a89592586568230a291

when going into a project and taking a look at the https clone url it will show like this: https://xxxxxx.de/GottZ/xxxxxxxxxx.git wich is good.

login is working just fine.. however.. google responds like this:

400. That’s an error.

Error: redirect_uri_mismatch

Application: xxxxxx

You can email the developer of this application at: [email protected]

The redirect URI in the request: https://xxxxxx.de:80/users/auth/google_oauth2/callback did not match a registered redirect URI.

as you can clearly see, it tries to redirect to https://fqdn:80 wich is.. bad

github oauth is not working at all. its only showing up in production.log with the following string:

{"error"=>"redirect_uri_mismatch", "error_description"=>"The redirect_uri MUST match the registered callback URL for this application.", "error_uri"=>"https://developer.github.com/v3/oauth/#redirect-uri-mismatch", "state"=>"xxxxxxxxxxxxxxxxxxxxxxx", "limit"=>"20", "offset"=>"0"}

i think this is not a big issue and may not even have something to do with sameersbn/docker-gitlab but hopefully someone can just help me solving it without deep digging into it.

thank you for reading greetings GottZ

GottZ avatar Jun 24 '15 11:06 GottZ

@GottZ I have google oauth enabled and have no issues logging into gitlab with google oauth. I cannot remember correctly but I think couple of months back there was a google API change. Can you try setting up google oauth again by following the instructions here http://doc.gitlab.com/ce/integration/google.html.

Regarding your configuration, I see that you have enabled SSL support at the load balancer. In this case please make sure that you have not installed the SSL certificates in the container. I also see that your docker-compose.yml has the line "127.0.0.1:8444:443" in the ports section since the container will only server requests over http.

Lastly, here is the configuration I use at my load balancer if it helps

upstream gitlab {
  server 172.17.42.1:10080 fail_timeout=0;
}

# let gitlab deal with the redirection
server {
  listen 80;
  server_name git.example.com;
  server_tokens off;
  root /dev/null;

  # Increase this if you want to upload larger attachments
  client_max_body_size 20m;

  # individual nginx logs for this vhost
  access_log /var/log/nginx/gitlab_access.log;
  error_log /var/log/nginx/gitlab_error.log;

  location / {
    proxy_read_timeout 300;
    proxy_connect_timeout   300;
    proxy_redirect off;

    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header Host $http_host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For   $proxy_add_x_forwarded_for;
    proxy_set_header X-Frame-Options   SAMEORIGIN;

    proxy_pass http://gitlab;
  }
}

server {
  listen 443 ssl spdy;
  server_name git.example.com;
  server_tokens off;
  root /dev/null;

  ## Increase this if you want to upload larger attachments
  client_max_body_size 20m;

  ## SSL
  ssl on;

  ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
  ssl_prefer_server_ciphers on;

  ssl_ciphers 'ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES256-GCM-SHA384:AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256:AES256-SHA:AES128-SHA:DES-CBC3-SHA:HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4';

  ssl_session_cache builtin:1000  shared:SSL:10m;

  ## Strong SSL Security
  ## https://raymii.org/s/tutorials/Strong_SSL_Security_On_nginx.html
  ssl_certificate /etc/nginx/ssl/server.crt;
  ssl_certificate_key /etc/nginx/ssl/server.key;

  ## [Optional] Generate a stronger DHE parameter (recommended):
  ##   cd /etc/ssl/certs
  ##   openssl dhparam -out dhparam.pem 2048
  ##
  ssl_dhparam /etc/nginx/ssl/dhparam.pem;

  ## Individual nginx logs for this vhost
  access_log /var/log/nginx/gitlab_ssl_access.log;
  error_log /var/log/nginx/gitlab_ssl_error.log;

  location / {
    ## If you use https make sure you disable gzip compression
    ## to be safe against BREACH attack.
    gzip off;

    proxy_read_timeout 300;
    proxy_connect_timeout 300;
    proxy_redirect off;

    proxy_set_header Host $http_host;
    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 https;
    proxy_set_header X-Frame-Options SAMEORIGIN;

    proxy_pass http://gitlab;
  }
}

sameersbn avatar Jun 24 '15 17:06 sameersbn

@GottZ Let me know if it helps. Tomorrow I will try your commands.

sameersbn avatar Jun 24 '15 17:06 sameersbn

@GottZ Was your issue resolved?

sameersbn avatar Jul 07 '15 09:07 sameersbn

sorry i've not been answering yet. you also mentioned i forward 443 instead of 80. original i did that because it solved wrong clone urls that were displaying as: https://domain.de:80/namespace/project.git the traffic to and from the reverse proxy is unencrypted

i'll try something now. will report back in around an hour or so.

GottZ avatar Jul 10 '15 08:07 GottZ

ok. after updating to 7.12.2-2 the problem persists. what i did afterwards was reading through all commits from 7.8.4 to the latest one. well.. as i expected.. nothing wrong with docker-gitlab.

however: even since i use dockers http port now aswell as my nginx config matches yours, oauth will always missmatch the response url due to an appended :80 behind the hostname.

i'll now dig into the container and will see if i can figure something out.

anyways: i'm doing this in my spare time btw. i only use this container for personal stuff on my private server. so far.. i love it. you sure spent alot of effort into this! thanks for that.

GottZ avatar Jul 10 '15 09:07 GottZ

Please note if gitlab is running behind a load balancer with https support then, you need to set GITLAB_PORT to 443. This is automatically set when GTILAB_HTTPS=true

sameersbn avatar Jul 10 '15 10:07 sameersbn

i did study your entrypoint.sh and other files. i want to point out that i do know that i need to set GITLAB_PORT and even know why its needed. this is my current configuration: https://gist.github.com/GottZ/00771896dac7515bcb88

clone urls work correctly. just the oauth callback url is broken. it does not matter wich omniauth gem is being used. they all force port 80

i even dug into https://github.com/intridea/omniauth to see if i can find anything. srsly. i'm kinda lost here.

thats just another thing i found: https://github.com/gitlabhq/gitlabhq/commit/571ba5a7feb870b7aa711d5a6fc6d4d53d92a4c5 i still could not verify any relation between the version change and my issue.

if i cannot find a solution i might hot glue a string replacement into the reverse proxy.

GottZ avatar Jul 10 '15 11:07 GottZ

@GottZ did you deleting your oauth configuration on google and recreate it.

sameersbn avatar Jul 10 '15 15:07 sameersbn

Yes. I did that before updating to 7.12 (on 7.8.4 it worked fine)

GottZ avatar Jul 10 '15 16:07 GottZ

Hi guys,

I have the same issue since I updated from 7.10.0 which worked fine to 7.13.2.

My configuration is the same as @GottZ I am doing a reverse nginx proxy and only forward https traffic on port 443.

Since the upgrade the :80 is appended to the redirect uri which creates the mismatch error.

I am using docker-compose with the docker image, I did not change any parameter since the upgrade other than the certificate and domain name.

Here's my config for gitlab: https://gist.github.com/sp4ke/e3a2312ca41520539ab9

And here's an example of the redirect uri: https://github.com/login/oauth/authorize?response_type=code&client_id=53f00753e5f4b4574016&redirect_uri=https://git.marbelium.com:80/users/auth/github/callback&state=999e42f13c1071c142fa427d4de06738668b311d4c290a2e&scope=user:email

Let me know if I can help debug or give you more details to fix this issue.

blob42 avatar Aug 03 '15 16:08 blob42

This just bit me after upgrading, GitLab started appending :80 to my redirect_uri. I found that I had both GITLAB_HTTPS=true and GITLAB_PORT=80 set in my environment. When I unset GITLAB_PORT, Google OAuth magically started working again.

fizz avatar Aug 27 '15 22:08 fizz

@fizz GITLAB_PORT indicates the port on which the gitlab application will be externally accessible. In your comment you indicated use of GITLAB_HTTPS=true, this indicates that the gitlab application is externally accessible on https port 443 of the reverse proxy. This means that GITLAB_PORT should have been set to 443. If not specified, the container automatically sets it to 443 based on GITLAB_HTTPS=true.

The :80 appended to the redirect_url after the upgrade indicates that gitlab did not respect the port configuration on the redirect_url prior to the upgrade, which is why you did not notice this issue earlier.

All in all, your configuration is now correct (earlier it was not :wink: )

@sp4ke (sorry for the late reply), The resolution to your issue is probably also the same.

sameersbn avatar Aug 30 '15 04:08 sameersbn

7.14.1 fixed this issue for me. @sp4ke tell us if upgrading solved your issue too.

oh and @sameersbn, i didn't change anything in my configuration.

GottZ avatar Aug 30 '15 18:08 GottZ

oh and @sameersbn, i didn't change anything in my configuration.

neither was anything changed in the image apart from upgrading gitlab :smile:

sameersbn avatar Aug 31 '15 03:08 sameersbn

so my guess that this was not related to this repo is actually true. i'm kinda happy now :+1:

GottZ avatar Sep 01 '15 09:09 GottZ