Джанго-Аллах - перенаправление OpenID и OAuth + Apache в качестве прокси

2

Я пытаюсь включить логин через Steam на основе OpenID.

Мой env довольно прост, django работает с gunicorn @8000, Apache @80

<VirtualHost *:80>
    ServerName dev.example.com

    # Point this to your public folder of teambox
    DocumentRoot /var/www/vhosts/dev.example.com/Example/

    # Custom log file locations
    ErrorLog  /var/log/apache2/dev.example.com_error.log
    CustomLog /var/log/apache2/dev.example.com_access.log combined

    ProxyRequests     Off
    ProxyPreserveHost On
    ProxyPass / http://127.0.0.1:8000/
    <Location />
        ProxyPassReverse /
        Order deny,allow
        Allow from all
    </Location>
</VirtualHost>

В обоих случаях я получаю следующую ошибку

ERROR:root:Missing required parameter in response from https://steamcommunity.com/openid/login: ('http://specs.openid.net/auth/2.0', 'assoc_type')
Traceback (most recent call last):
  File "/usr/local/lib/python3.4/dist-packages/openid/message.py", line 455, in getArg
    return self.args[args_key]
KeyError: ('http://specs.openid.net/auth/2.0', 'assoc_type')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.4/dist-packages/openid/consumer/consumer.py", line 1280, in _requestAssociation
    assoc = self._extractAssociation(response, assoc_session)
  File "/usr/local/lib/python3.4/dist-packages/openid/consumer/consumer.py", line 1397, in _extractAssociation
    OPENID_NS, 'assoc_type', no_default)
  File "/usr/local/lib/python3.4/dist-packages/openid/message.py", line 458, in getArg
    raise KeyError((namespace, key))
KeyError: ('http://specs.openid.net/auth/2.0', 'assoc_type')

Теперь странная (для меня) часть заключается в том, что если я подключаюсь непосредственно к 8000, перенаправление действительно работает, даже если оно создает ошибку в фоновом режиме, но через 80 это не так. Самая странная часть - перенаправление, возвращаемое Django, отличается.

: 80 через Apache

example.com/nl/openid/login/?process=login&openid=http%3A%2F%2Fsteamcommunity.com%2Fopenid

example.com/nl/openid/login?openid.ax.mode=fetch_request&openid.ax.required=...

example.com/nl/openid/login/?openid.ax.mode=fetch_request&openid.ax.required=...

: Корпус 8000 - прямое соединение с пушкой

example.com:8000/nl/openid/login/?process=login&openid=http%3A%2F%2Fsteamcommunity.com%2Fopenid

https://steamcommunity.com/openid/login?openid.ax.mode=fetch_request&openid.ax.required=...

-- РЕДАКТИРОВАТЬ --

После еще одного тестирования выясняется, что Google OAuth имеет ту же проблему, перенаправляя меня на мой сайт /o/oauth2/ вместо google.com/o/oauth2/

Теги:
gunicorn
django-allauth

1 ответ

1
Лучший ответ

После некоторого удара, крика и молитвы богам Apache оказалось, что моя конфигурация Apache была неправильной, ProxyPassReverse был неисправен

ProxyRequests     Off
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:8000/
ProxyPassReverse / http://127.0.0.1:8000/
<Location />
    # ProxyPassReverse /
    Order deny,allow
    Allow from all
</Location>

Ещё вопросы

Сообщество Overcoder
Наверх
Меню