inveniosoftware / invenio-oauthclient

Invenio module that provides OAuth web authorization support.
https://invenio-oauthclient.readthedocs.io
MIT License
6 stars 76 forks source link

examples: addition of CERN authentication app #17

Closed JavierDelgadoFernandez closed 8 years ago

JavierDelgadoFernandez commented 8 years ago

Signed-off-by: Javier Delgado javier.delgado.fernandez@cern.ch

JavierDelgadoFernandez commented 8 years ago

I couldn't test the application completly since CERN configuration has a strong dependency in Invenio-Groups module. The current state can go to CERN authentication, grant access and return to the application but in this point is crashing because current_user doesn't have info attribute.

JavierDelgadoFernandez commented 8 years ago

@lnielsen The thing is that CERN requires a HTTPS direction as return url. I was testing some other ways to provide a secure connection (Flask-SSLify and OpenSSL creating a context inside the flask app) but I was not able to make them run, (errors with WSGI, pyOpenSSL has a confirmed bug and Flask-SSLify was in the same case). I think the easiest way is this, but it is pretty ugly, you need to generate the certificate manually...

lnielsen commented 8 years ago

I'm not against using gunicorn for HTTPs, however, it's just for the example app, so I think its better to not put in the setup.py and just put a line in the documentation instead about pip install gunicorn.

What were the problems with using: http://werkzeug.pocoo.org/docs/0.11/serving/#ssl ?

JavierDelgadoFernandez commented 8 years ago

@lnielsen I have removed gunicorn from setup.py.
In the case werkzeug ssl the development server gets stuck, there is no way to stop it except sending a KILL signal to the process. And if you enable the debug mode, you get the same issue of Flask-SSLify or pyOpenSSL, (You can't access to any page), here is the stack trace:

 * Debugger is active!
 * Debugger pin code: 254-670-152
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 58830)
Traceback (most recent call last):
  File "/usr/lib/python2.7/SocketServer.py", line 295, in _handle_request_noblock
    self.process_request(request, client_address)
  File "/usr/lib/python2.7/SocketServer.py", line 321, in process_request
    self.finish_request(request, client_address)
  File "/usr/lib/python2.7/SocketServer.py", line 334, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib/python2.7/SocketServer.py", line 655, in __init__
    self.handle()
  File "/home/javier/Documents/invenio-oauthclient/env/local/lib/python2.7/site-packages/Werkzeug-0.11.2-py2.7.egg/werkzeug/serving.py", line 217, in handle
    rv = BaseHTTPRequestHandler.handle(self)
  File "/usr/lib/python2.7/BaseHTTPServer.py", line 340, in handle
    self.handle_one_request()
  File "/home/javier/Documents/invenio-oauthclient/env/local/lib/python2.7/site-packages/Werkzeug-0.11.2-py2.7.egg/werkzeug/serving.py", line 251, in handle_one_request
    elif self.parse_request():
  File "/usr/lib/python2.7/BaseHTTPServer.py", line 281, in parse_request
    "Bad HTTP/0.9 request type (%r)" % command)
  File "/usr/lib/python2.7/BaseHTTPServer.py", line 364, in send_error
    self.log_error("code %d, message %s", code, message)
  File "/home/javier/Documents/invenio-oauthclient/env/local/lib/python2.7/site-packages/Werkzeug-0.11.2-py2.7.egg/werkzeug/serving.py", line 273, in log_error
    self.log('error', *args)
  File "/home/javier/Documents/invenio-oauthclient/env/local/lib/python2.7/site-packages/Werkzeug-0.11.2-py2.7.egg/werkzeug/serving.py", line 279, in log
    _log(type, '%s - - [%s] %s\n' % (self.address_string(),
  File "/home/javier/Documents/invenio-oauthclient/env/local/lib/python2.7/site-packages/Werkzeug-0.11.2-py2.7.egg/werkzeug/serving.py", line 267, in address_string
    return self.environ['REMOTE_ADDR']
AttributeError: 'WSGIRequestHandler' object has no attribute 'environ'
----------------------------------------
JavierDelgadoFernandez commented 8 years ago

@jirikuncar Ping.

jirikuncar commented 8 years ago

@JavierDelgadoFernandez please rebase

JavierDelgadoFernandez commented 8 years ago

@jirikuncar Done.

JavierDelgadoFernandez commented 8 years ago

@jirikuncar Rebased after HTTPretty issue.