Commit Graph

243 Commits

Author SHA1 Message Date
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
MinRK
34cebb5dba add Proxy.fetch_routes
and DRY up the api requests
2014-09-22 17:24:09 -07:00
MinRK
2a46893448 update proxy with already-running users at startup 2014-09-21 22:50:01 -07:00
MinRK
fc93f1b0c2 allow resetting the database 2014-09-21 22:44:50 -07:00
MinRK
363d81a380 fix inverted logic in Server.is_up() 2014-09-21 22:44:50 -07:00
MinRK
3a0f19f1a4 cookie_secret is no longer bytes
add utils.random_hex for generating a unicode object
with random hex bytes
2014-09-21 22:44:50 -07:00
MinRK
2eb42eb0b3 add orm.User.find and orm.[Foo]Token.find
for simple get-by-name access
2014-09-21 22:44:50 -07:00
MinRK
24eebd94e4 make HTTP requests to the proxy async 2014-09-18 17:16:33 -07:00
MinRK
58b32f634a restart the proxy if it goes down
and populate its table from the database
2014-09-18 17:04:17 -07:00
MinRK
a77e106488 move some utility functions to ORM classes
simplify handler methods
2014-09-18 15:37:39 -07:00
MinRK
0a8759b0a5 flesh out REST API
can now list/view/add/create/modify users
and start/stop single-user servers
2014-09-14 16:47:09 -07:00
MinRK
53edc0b2f7 add a notion of admin users
and an @admin_only decorator for restricted methods
2014-09-14 11:54:05 -07:00
MinRK
696b887b50 allow threaded access to sqlite by default 2014-09-13 16:05:43 -07:00
MinRK
534eee46fc rename db.py orm.py
less confusing to have self.db and orm.User
than self.db and db.User.
2014-08-25 15:10:28 -07:00