Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GitHub OAuth configuration problem #1316

Closed
JeromeO opened this issue Jan 7, 2017 · 11 comments
Closed

GitHub OAuth configuration problem #1316

JeromeO opened this issue Jan 7, 2017 · 11 comments
Assignees
Labels
documentation Improvements or additions to the documentation.
Milestone

Comments

@JeromeO
Copy link

JeromeO commented Jan 7, 2017

Hi,
I can't use the GitHub Authentication module.
I've set up a weblate module in Github with the following Authorization callback URL : https://weblate.pyromaths.org/
When I try to register a new user, I connect to my GitHub Account and then I'm back to the https://weblate.pyromaths.org/ homepage but with the following path in the address bar : https://weblate.pyromaths.org/?error=redirect_uri_mismatch&error_description=The+redirect_uri+MUST+match+the+registered+callback+URL+for+this+application.&error_uri=https%3A%2F%2Fdeveloper.github.com%2Fv3%2Foauth%2F%23redirect-uri-mismatch&state=UWZoW2wQMcLdGfroUG2ylT9JIkJxWV5n

Any help would be welcome.
Thanks a lot.

Server configuration

./manage.py list_versions

  • Weblate weblate-2.10-155-g9ad06f2
  • Python 2.7.9
  • Django 1.10.5
  • six 1.10.0
  • python-social-auth 0.2.21
  • Translate Toolkit 2.0.0b5
  • Whoosh 2.7.4
  • defusedxml 0.4.1
  • Git 2.1.4
  • Pillow (PIL) 1.1.7
  • dateutil 2.6.0
  • lxml 3.7.1
  • django-crispy-forms 1.6.1
  • compressor 2.1
  • djangorestframework 3.5.3
  • pytz 2016.6.1
  • pyuca N/A
  • python-bidi 0.4.0
  • pyLibravatar N/A
  • Mercurial 3.9.1
  • Database backends: django.db.backends.postgresql_psycopg2
@nijel
Copy link
Member

nijel commented Jan 7, 2017

It reports to GitHub https://localhost:8002/, that's why there is mismatch, most likely caused by wrong sites setup, see https://docs.weblate.org/en/latest/admin/install.html#production-site

@nijel nijel self-assigned this Jan 7, 2017
@nijel nijel added the question This is more a question for the support than an issue. label Jan 7, 2017
@JeromeO
Copy link
Author

JeromeO commented Jan 7, 2017

Hi,
thank you very much for your answer. The problem seems to be gunicorn that I use to serve my Django files. Do you know how to set it up ?

@nijel
Copy link
Member

nijel commented Jan 8, 2017

Sorry, I've never used it. Maybe you're not passing server name from the front end webserver to gunicorn? If using nginx (see http://docs.gunicorn.org/en/latest/deploy.html#nginx-configuration):

      proxy_set_header Host $http_host;

@JeromeO
Copy link
Author

JeromeO commented Jan 8, 2017

I'll try to figure it out and post a solution here. Could you tell me how you know it reports to http://localhost:8002/ ?
Thanks again

@nijel
Copy link
Member

nijel commented Jan 8, 2017

Having working example for gunicorn in our documentation would be great: https://docs.weblate.org/en/latest/admin/install.html#running-server

Isn't your gunicorn running on 127.0.0.1:8002?

@JeromeO
Copy link
Author

JeromeO commented Jan 8, 2017

Absolutely. It is.
My question is : how did YOU find out that it was running on 127.0.0.1:8002 ? It could help me debug this situation.

@nijel
Copy link
Member

nijel commented Jan 8, 2017

Because it reports http://localhost:8002/ ... the problem really is that gunicorn is not getting Host header from the web server. Not sure what you're using there, but you need to pass this header from original request to gunicorn (and others as well, for example Authorization header is needed or API access).

@JeromeO
Copy link
Author

JeromeO commented Jan 8, 2017

At last ! I've spent so much time for such a simplistic solution. I don't know why, but the GitHub module reports to httpS://weblate.pyromaths.org and I've been struggling all day long thinking it was a simple http.
So, the trick is just to insert
ProxyPreserveHost On
in the Apache config file for the VirtualHost and it's working. And you have to prepare a ssl section too.

@nijel
Copy link
Member

nijel commented Jan 17, 2017

Can you please share your Apache and gunicorn configuration so that it can be included in our documentation?

nijel added a commit that referenced this issue Jan 24, 2017
- add gunicorn example (issue #1316)
- add links to Django docs
- remove lighttpd example as it used no longer existing fastcgi support

Signed-off-by: Michal Čihař <michal@cihar.com>
@nijel
Copy link
Member

nijel commented Jan 24, 2017

I've tried to write example based on the online docs, but it's probably incomplete. It would be great if you could improve it: https://docs.weblate.org/en/latest/admin/install.html#sample-configuration-for-apache-and-gunicorn

@nijel nijel closed this as completed Jan 24, 2017
@nijel nijel added documentation Improvements or additions to the documentation. and removed question This is more a question for the support than an issue. labels Jan 24, 2017
@nijel nijel added this to the 2.11 milestone Jan 24, 2017
@JeromeO
Copy link
Author

JeromeO commented Jan 24, 2017

The only thing I have that is missing is the line
ProxyPass / http://localhost:8000/

I had to use SSL to let GitHub authenticate. So the SSL section is

<VirtualHost *:443>
    ServerAdmin admin@weblate.example.org
    ServerName weblate.example.org

    Alias /robots.txt /usr/share/weblate/data/static/robots.txt
    Alias /favicon.ico /usr/share/weblate/data/static/favicon.ico

    Alias /static/ /usr/share/weblate/data/static/
    Alias /media/ /usr/share/weblate/data/media/

    <Directory /usr/share/weblate/data/static/>
        Require all granted
    </Directory>

    <Directory /usr/share/weblate/data/media/>
        Require all granted
    </Directory>
  
  SSLEngine on
  SSLCertificateFile /etc/apache2/ssl/https_cert.cert
  SSLCertificateKeyFile /etc/apache2/ssl/https_key.pem

  SSLProxyEngine On

  ProxyPass /robots.txt !
  ProxyPass /favicon.ico !
  ProxyPass /static/ !
  ProxyPass /media/ !

  ProxyPass / http://localhost:8000/
  ProxyPassReverse / http://localhost:8000/
  ProxyPreserveHost On
</VirtualHost>

nijel added a commit that referenced this issue Jan 24, 2017
Issue #1316

Signed-off-by: Michal Čihař <michal@cihar.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to the documentation.
Projects
None yet
Development

No branches or pull requests

2 participants