Repository: jupyterhub/jupyterhub

Issue:
Jupyterhub remote host issue
Hi,
I'm trying to use jupyterhub from a docker. I was able to get it to run properly on my local using this dockerfile but it doesn't work on the remote host.
```
FROM jupyterhub/jupyterhub
RUN apt-get -y update
RUN conda install -y jupyter
RUN jupyterhub --generate-config
RUN useradd -ms /bin/bash abc
RUN echo "abc:123" | chpasswd
EXPOSE 8000
CMD jupyterhub
```

I'm able to see the login page but when I enter the credentials, I get the following error:
```
[I 2018-03-19 12:48:32.236 JupyterHub app:925] Writing cookie_secret to /srv/jupyterhub/jupyterhub_cookie_secret
[I 2018-03-19 12:48:32.257 alembic.runtime.migration migration:117] Context impl SQLiteImpl.
[I 2018-03-19 12:48:32.257 alembic.runtime.migration migration:122] Will assume non-transactional DDL.
[I 2018-03-19 12:48:32.266 alembic.runtime.migration migration:327] Running stamp_revision  -> 56cc5a70207e
[W 2018-03-19 12:48:32.344 JupyterHub app:1008] No admin users, admin interface will be unavailable.
[W 2018-03-19 12:48:32.345 JupyterHub app:1009] Add any administrative users to `c.Authenticator.admin_users` in config.
[I 2018-03-19 12:48:32.345 JupyterHub app:1036] Not using whitelist. Any authenticated user will be allowed.
[I 2018-03-19 12:48:32.374 JupyterHub app:1615] Hub API listening on http://127.0.0.1:8081/hub/
[W 2018-03-19 12:48:32.375 JupyterHub proxy:392] 
    Generating CONFIGPROXY_AUTH_TOKEN. Restarting the Hub will require restarting the proxy.
    Set CONFIGPROXY_AUTH_TOKEN env or JupyterHub.proxy_auth_token config to avoid this message.
    
[W 2018-03-19 12:48:32.375 JupyterHub proxy:434] Running JupyterHub without SSL.  I hope there is SSL termination happening somewhere else...
[I 2018-03-19 12:48:32.375 JupyterHub proxy:436] Starting proxy @ http://*:8000/
12:48:32.558 - info: [ConfigProxy] Proxying http://*:8000 to (no default)
12:48:32.561 - info: [ConfigProxy] Proxy API at http://127.0.0.1:8001/api/routes
[W 2018-03-19 12:48:32.742 JupyterHub proxy:289] Adding missing default route
12:48:32.742 - info: [ConfigProxy] 200 GET /api/routes 
[I 2018-03-19 12:48:32.743 JupyterHub proxy:348] Adding default route for Hub: / => http://127.0.0.1:8081
12:48:32.746 - info: [ConfigProxy] Adding route / -> http://127.0.0.1:8081
12:48:32.747 - info: [ConfigProxy] 201 POST /api/routes/ 
[I 2018-03-19 12:48:32.747 JupyterHub app:1668] JupyterHub is now running at http://:8000/
[I 2018-03-19 12:49:13.084 JupyterHub log:134] 200 GET /hub/login (@::ffff:172.17.0.1) 28.40ms
[E 2018-03-19 12:49:16.642 JupyterHub web:1591] Uncaught exception POST /hub/login?next= (::ffff:172.17.0.1)
    HTTPServerRequest(protocol='http', host='localhost:8000', method='POST', uri='/hub/login?next=', version='HTTP/1.1', remote_ip='::ffff:172.17.0.1', headers={'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36', 'Content-Type': 'application/x-www-form-urlencoded', 'X-Forwarded-Host': 'localhost:8000', 'X-Forwarded-For': '::ffff:172.17.0.1', 'X-Forwarded-Port': '8000', 'X-Forwarded-Proto': 'http', 'Upgrade-Insecure-Requests': '1', 'Origin': 'http://localhost:8000', 'Cache-Control': 'max-age=0', 'Accept-Language': 'en-GB,en-US;q=0.9,en;q=0.8', 'Host': 'localhost:8000', 'Referer': 'http://localhost:8000/hub/login', 'Connection': 'close', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8', 'Content-Length': '30', 'Accept-Encoding': 'gzip, deflate, br'})
    Traceback (most recent call last):
      File "/opt/conda/lib/python3.5/site-packages/tornado/web.py", line 1512, in _execute
        result = yield result
      File "<string>", line 6, in _wrap_awaitable
      File "/opt/conda/lib/python3.5/site-packages/jupyterhub/handlers/login.py", line 81, in post
        user = await self.login_user(data)
      File "/opt/conda/lib/python3.5/site-packages/jupyterhub/handlers/base.py", line 414, in login_user
        authenticated = await self.authenticate(data)
      File "/opt/conda/lib/python3.5/asyncio/futures.py", line 381, in __iter__
        yield self  # This tells Task to wait for completion.
      File "/opt/conda/lib/python3.5/asyncio/tasks.py", line 240, in _step
        result = coro.send(None)
      File "/opt/conda/lib/python3.5/site-packages/jupyterhub/auth.py", line 228, in get_authenticated_user
        authenticated = await self.authenticate(handler, data)
    TypeError: object Future can't be used in 'await' expression
    
[E 2018-03-19 12:49:16.654 JupyterHub log:126] {
      "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36",
      "Content-Type": "application/x-www-form-urlencoded",
      "X-Forwarded-Host": "localhost:8000",
      "X-Forwarded-For": "::ffff:172.17.0.1",
      "X-Forwarded-Port": "8000",
      "X-Forwarded-Proto": "http",
      "Upgrade-Insecure-Requests": "1",
      "Origin": "http://localhost:8000",
      "Cache-Control": "max-age=0",
      "Accept-Language": "en-GB,en-US;q=0.9,en;q=0.8",
      "Host": "localhost:8000",
      "Referer": "http://localhost:8000/hub/login",
      "Connection": "close",
      "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
      "Content-Length": "30",
      "Accept-Encoding": "gzip, deflate, br"
    }
```

Any ideas what I am doing wrong?


Discussion:
I had the same error with the pre-built Docker container that had the `latest` tag.

In the meantime, I switched to the previous version '`jupyterhub/jupyterhub:0.8.1`' and the errors disappeared. I'm still hoping to find a fix for this. I used both `latest` and `0.8.1` with exactly the same configuration.
I'm having the same issue. I'll give the older build a try.
What Authenticator are you using?

Resolving patch:
diff --git a/jupyterhub/auth.py b/jupyterhub/auth.py
--- a/jupyterhub/auth.py
+++ b/jupyterhub/auth.py
@@ -225,7 +225,7 @@ async def get_authenticated_user(self, handler, data):
         .. versionchanged:: 0.8
             return dict instead of username
         """
-        authenticated = await self.authenticate(handler, data)
+        authenticated = await maybe_future(self.authenticate(handler, data))
         if authenticated is None:
             return
         if isinstance(authenticated, dict):


Test patch: