Commit Graph

213 Commits

Author SHA1 Message Date
Min RK
29416463ff proxy needs user dict, which has proxy path
this won't be needed if/when I make a schema change, where domain is included in the Server table.
2016-02-26 17:32:55 +01:00
Min RK
a9b8542ec7 pass hub's host to single-user servers via hub_host 2016-02-26 17:32:54 +01:00
Min RK
b54bfad8c2 [WIP]: allow running single-user servers on subdomains
relies on CHP's host-based routing (a feature I didn't add!)

requires wildcard DNS and wildcard SSL for a proper setup

still lots to workout and cleanup in terms of cookies and where to use host, domain, path, but it works locally.
2016-02-26 17:32:54 +01:00
Min RK
cb55118f70 add debug logging for adding users with no running server
in check_routes, it has been reported that users without a running server are attempted to be added.

So something is wrong, either in sqlalchemy or my understanding of what it does (likely the latter),
because a filter for users with a non-None server is returning at least one result whose server is None.
2016-02-20 14:22:50 +01:00
Min RK
f626d2f6e5 use 127.0.0.1 instead of localhost
localhost can cause some issues on badly behaved or misconfigured systems,
and 127 seems simpler.
2016-02-03 10:30:09 +01:00
Min RK
cc4c65bd0b fix possible loss of port info due to mixed db sessions 2016-01-25 14:28:54 +01:00
Min RK
b9df681115 Merge pull request #353 from minrk/try-localhost
Ensure that we can bind and connect to localhost
2016-01-20 15:37:42 +01:00
Zoltan Fedor
faa259e97b IPv6 ready hosts file localhost issue
This is to resolve the 'Network is Unreachable' error experienced by a few when JupyterHUB is connecting to localhost.

On most recent linux OS versions like CentOS 6, 7, Red Hat 6, 7, Oracle Linux 6, 7, etc, the hosts file (/etc/hosts) usually has a line to make the server IPv6-ready:
    ::1 localhost
even if the given server actually has no IPv6 permissioned. In such case the Python socket library when connecting to 'localhost' will try to connect via the IPv6 protocol - which will fail with the 'Network is Unreachable' error.

To solve this we capture this error and try to reconnect on 127.0.0.1 instead of localhost, alias forcing the user of the IPv4 protocol.
2015-12-15 10:53:06 -05:00
Min RK
4785a1ef87 Ensure that we can bind and connect to localhost
otherwise fallback to 127.0.0.1 for defaults
2015-12-15 13:37:30 +01:00
Min RK
6f128758db move non-persisted User objects (spawner-related) off of orm.User
adds higher level User object, which handles spawning.
This object has running, spawner, etc. attributes.
2015-11-30 14:05:00 +01:00
Min RK
6f2aefb990 add pre/post-spawn hooks for Authenticators
allows setup/cleanup to be performed by the authenticator

use this to open PAM sessions at spawn
and close them at stop,
rather than open at login and never close.
2015-10-16 12:02:44 +02:00
Min RK
a451f11cd3 give Spawners a handle on the Authenticator
band-aid for spawner-authenticator pairs
2015-09-11 11:57:41 +02:00
Jessica B. Hamrick
ea5bfa9999 Unset all login cookies 2015-08-21 19:24:44 -07:00
Min RK
d4a4d04183 quote usernames
allow @ to be left unescaped in URLs, quote everything in cookie names
2015-04-30 12:04:32 -07:00
Min RK
e883fccf2b don't update last_activity on shutdown 2015-04-08 12:48:04 -07:00
Min RK
ba81bd4a01 Merge pull request #190 from minrk/bind_url
url logging
2015-03-24 11:52:33 -07:00
Min RK
5529774c1d url logging
log the actual bind url (Server.bind_url),
rather than the connect url (Server.url),
which converts all-interfaces IPs to 'localhost'
2015-03-23 12:12:10 -07:00
Min RK
da1fe54aee better error messages for spawn failure
Server started, but never became accessible:

> Failed to reach your server.
> Please try again later.
> Contact admin if the issue persists.

Server failed to start (errors in Spawner):

> Failed to start your server.
> Please contact admin.
2015-03-13 12:12:36 -07:00
Scott Sanderson
0c3bce8b57 DEV: Make the timeout used by wait_for_http_server configurable. 2015-03-04 23:37:30 -05:00
Min RK
c991438c3d make host connectable when ip is empty
turn '' into 'localhost', so that it is a valid URL for connection
2015-03-04 12:13:06 -08:00
Min RK
8ae0109322 make spawner IP configurable
mainly for localhost->127.0.0.1 config in pathological cases
2015-03-02 16:48:21 -08:00
Min RK
7082ea60ee fix filter check in Proxy.check_routes
and test that check_routes works as intended
2015-02-11 11:17:01 -08:00
Min RK
edfb39c74c Merge pull request #148 from minrk/poke-proxy-api
add proxy API
2015-02-08 10:24:42 -08:00
Min RK
b4980f1736 test inconsistent state if Spawner.start fails 2015-02-08 10:19:48 -08:00
Min RK
0dc3150762 add Proxy.check_routes
checks to ensure proxy table and user db are in sync

called on each last-activity check with the proxy (5 minutes)
2015-02-06 17:06:01 -08:00
Min RK
b5eda9d785 add User.running
as the one true way to check whether a user is running or not

User.running will be True if spawn or stop is pending.
2015-02-06 15:42:57 -08:00
Min RK
1fd139418a cleanup after any exception in spawn
not just timeouts
2015-02-06 14:47:14 -08:00
Min RK
09d9efb44c handle Spawners that are slow to stop
e.g. docker, which can take a long time to stop,
especially if several docker actions are already queued.

Use status `202: Accepted` for API replies sent with spawn/stop still pending
2015-01-28 11:35:38 -08:00
Min RK
8cd2a55aa8 give Spawners, Authenticators db access
as self.db
2015-01-16 16:38:30 -08:00
Min RK
53880f52b8 allow high latency spawners
such as VMs, batch and cloud services, etc. which can take minutes to start.

- Spawner.start_timeout sets a limit for true failure,
  at which point spawner should be considered dead.
- Handler.spawn_single_user only waits up to 10 seconds
  before returning. It can now return with a spawner still pending.
- Record User.spawn_pending state, and render 'pending' page
  while server is starting but not started.
2014-12-22 13:27:23 -08:00
Min RK
cf3a5744e7 better handle servers failing to start
including more informative TimeoutError messages
2014-11-21 17:55:52 -08:00
Min RK
40a99e61ac drop support for old Python, IPython < 3
Require IPython >= 3.0, Python >= 3.3
2014-11-02 15:51:06 -08:00
Min RK
27e51cd0b4 Merge pull request #81 from minrk/crypto-db
hash tokens in database

closes #80
closes #83
2014-10-30 16:20:16 -07:00
Min RK
da51affacb add hash rounds
default 16k
2014-10-30 15:59:02 -07:00
Min RK
e91b7f630c use starts with when checking token prefix
allows prefix length to change
2014-10-30 10:21:32 -07:00
Scott Sanderson
8cfbe9b38e DEV: Close transactions at the end of HTTP Requests.
Fixes #84
2014-10-29 17:38:24 -04:00
Min RK
ae7b92c55e get rid of cookie tokens
use single cookie_id, since cookies themselves are already unique via `set_secure_cookie`

resetting cookie_id effectively logs out all browser sessions for a given user
2014-10-28 15:01:29 -07:00
Min RK
aed3efc557 Don't need passlib + sqlalchemy_utils for hashing
we can store hash+salt ourselves.
Since we need to implement prefix filtering, etc. ourselves,
there is little benefit to adding a large dependency just for implicit hashing.
2014-10-28 14:18:32 -07:00
MinRK
548c404265 Don't persist proxy auth token to db
removes last need for encrypted database fields, so db_secret is removed as well.
2014-10-27 17:29:45 -07:00
MinRK
bce2be7401 only store hashed tokens
- use PasswordType
- store first 4 bytes for filtering by prefix
  since we can't filter by equality on the hashed value.
- user.new_foo_token() returns token string, not ORM object
2014-10-27 17:29:44 -07:00
MinRK
73706632d5 database security
- add files for cookie and database secrets
- store cookie secret on disk, instead of in database
- encrypt auth tokens with EncryptedType
2014-10-27 16:23:46 -07:00
MinRK
0bd03f0861 remove cookie_secret from single-user servers
pass encrypted cookies to Hub for verification
2014-10-26 20:23:24 -07:00
Scott Sanderson
d7f1d6d2aa BUG: Only pass check_same_thread when using sqlite. 2014-10-23 16:31:44 -04:00
Min RK
4ea63c05f3 Merge pull request #65 from minrk/six
use six instead of IPython.py3compat
2014-10-18 20:21:10 -07:00
MinRK
919a342770 use six instead of IPython.py3compat 2014-10-15 12:10:57 -07:00
MinRK
ed84a3e107 fix inappropriate clearing of API tokens 2014-10-15 11:27:30 -07:00
MinRK
08fd76d1e8 wait for HTTP servers to start accepting requests
avoids error messages in the proxy when servers are slow to start.
2014-10-14 14:39:53 -07:00
MinRK
a8548164cd remove Spawner.fromJSON
load state on `__init__` instead

Makes more sense now that state can persist
across server instances (e.g. docker container_id)
2014-10-14 11:44:46 -07:00
MinRK
d8ef6d59c1 adjustments to Spawner.stop
- call start/stop_polling outside Spawner
  (avoids need for custom spawners to reimplement)
- don't clear state when stopping Spawner
  (should enable spawners to resume)
2014-10-08 13:54:17 -07:00
MinRK
2393a30dec use '/api/routes' instead of '/api/routes/'
avoids need for recent fix in configproxy
2014-09-22 21:41:33 -07:00