Commit Graph

371 Commits

Author SHA1 Message Date
Min RK
992717adc0 support cross-user redirects when JupyterHub is on a prefix 2016-06-16 15:42:00 +02:00
Min RK
c6640aa51d only strip base_url if it's actually there 2016-05-30 10:34:33 +02:00
Min RK
1f861b2c90 server proxy error pages from the Hub 2016-04-27 14:06:29 +02:00
YuviPanda
9ffebd0c5e Send metrics about various redirects from User spawning 2016-04-01 14:05:02 -07:00
YuviPanda
2dd3d3c448 Send timing info about spawner success / failure 2016-04-01 10:20:37 -07:00
YuviPanda
cac5175c9b Send CSP metrics to statsd 2016-04-01 10:20:37 -07:00
YuviPanda
80556360ac Add statsd to the base request handler 2016-04-01 10:20:37 -07:00
YuviPanda
80932a51f4 Use User.url instead of constructing it manually
This fixes issues with URL encoding when redirecting users to
their own notebook instances
2016-03-31 17:28:33 -07:00
Min RK
195eea55f3 log.warning 2016-03-29 09:22:32 -07:00
Matthias Bussonnier
2cb1618937 Merge pull request #467 from minrk/add-user-more-often
Call `add_user` more often
2016-03-10 14:45:56 -08:00
YuviPanda
e0219d0363 Use encoded URL when redirecting user notebooks
Otherwise it breaks for usernames that have url unsafe
characters.
2016-03-08 18:41:35 -08:00
Min RK
96269fac0f Call add_user more often
- Ensures add_user is called as part of startup *for all users*.
  This was previously only true for users not already in the db.
- Normalize usernames in whitelist and admin sets
- Call add_user on new users logged in when there is no whitelist.
2016-03-08 10:49:02 +01:00
Carol Willing
03c25b5cac Merge pull request #452 from minrk/redundant-use-subdomain
remove redundant use_subdomains
2016-03-05 11:52:43 -08:00
Min RK
be5860822d remove redundant use_subdomains
non-empty subdomain_host is enough
2016-03-04 11:11:41 +01:00
Dara Adib
5a10d304c9 Redirect user to login page when not logged in 2016-03-02 16:55:33 -08:00
Dara Adib
4d55a48a79 Redirect requests to logged in user
If a user, alice, requests /user/bob/notebooks/mynotebook.ipynb,
redirect her to /user/alice/notebooks/mynotebook.ipynb.
Currently, such requests get stuck in a redirect loop because
the request will be redirected to login page with a next parameter
that when followed is again redirected.

When notebook_dir is consistent across users, this will allow
users to share notebook URLs. Fixes #424.
2016-03-02 16:15:50 -08:00
Kyle Kelley
5ec05822f1 Merge pull request #436 from minrk/subdomains
allow running single-user servers on subdomains
2016-02-28 09:49:45 -06:00
Min RK
335b47d7c1 include protocol in subdomain_host
makes everything easier, and tests are passing with and without subdomains (yay!)
2016-02-28 11:12:41 +01:00
Min RK
a4ae2ec2d8 consolidate cookie setting in _set_user_cookie 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
e74934cb17 avoid calling Spawner.poll during Spawner.start
moves `spawn_pending` flag to only around start, not the HTTP wait.

Some Spawners may not know how to poll until start has finished (DockerSpawner).
Let's not require that they do.
2016-02-25 10:13:51 +01:00
Min RK
c4fad21850 If spawner fails to start, show error page
instead of slow-spawner page
2016-01-25 13:32:54 +01:00
Min RK
887fdaf9d3 add username normalization
Handlers call `get_authenticated_user`, which in turn calls

- authenticate
- normalize_username
- check_whitelist

get_authenticated_user shouldn't need to be overridden.

Normalization can be handled via overriding normalize_username.
2016-01-13 14:02:50 +01:00
Min RK
53785a985d return after redirect to spawner form
avoids double-call to redirect, which fails
2016-01-05 14:02:20 +01:00
Min RK
041c1a4a1e remove always-False else branch 2015-12-30 13:55:38 +01:00
Min RK
f9c9c2b471 options_form is a regular configurable
now that we can assume User.spawner exists at all times
2015-12-30 13:55:38 +01:00
Min RK
41ea696546 Instantiate Spawner on User init
shrinks `User.spawn` to take single argument, grants User more direct access to state.
2015-12-30 13:55:36 +01:00
Min RK
ba634354dd Add Spawner form
If Spawner.options_form is specified, a form providing input controls is shown to the user prior to launch.

Spawners access the result via the `self.user_options` dict.

The default spawners offer no form.
2015-12-30 13:55:01 +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
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
2c8c88ac3f add CSP report handler 2015-07-12 11:22:21 -05:00
Tim Shawver
ff1bf7c4c0 Don't strip query string parameters out of GET requests to the notebook server.
Using self.request.uri instead of self.request.path in a few places accomplishes this.
2015-05-28 15:05:39 -04:00
Scott Sanderson
74d3740921 DEV: Allow configuration of default headers.
Applies Content-Security-Policy: frame-ancestors 'self' by default.
2015-04-24 01:19:25 -04:00
Matthias Bussonnier
494e4fe68b Make cookie secure if used over https 2015-04-17 10:13:28 -07:00
Min RK
1bc8d50261 add "Login with..." button
for custom authenticators that use external services (e.g. OAuth)
2015-03-31 13:56:49 -07:00
Min RK
2a2f9c0b67 Merge pull request #189 from minrk/timeout-spawn-error
better error messages for spawn failure
2015-03-23 11:55:15 -07:00
Min RK
3fb2afc2bd expire login cookies
via tornado's max_age_days mechanism

default expiry is two weeks
2015-03-17 12:56:06 -06: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
Min RK
288e361ae6 Don't schedule user stop before removing from proxy
user.stop clears user.server, which proxy.delete_user uses

scheduling user.stop first creates a race where user.server is None when it's removed from the proxy.
2015-03-04 14:54:38 -08:00
Min RK
f2b818e685 Merge pull request #132 from minrk/admin-access
add JupyterHub.admin_access
2015-01-31 16:48:32 -08:00
Min RK
4e2b79a60f Merge pull request #135 from minrk/slow-stop
handle Spawners that are slow to stop
2015-01-31 16:47:56 -08:00
Min RK
7753428dd7 cache control on static files
same principle as used in IPython,
slightly different implementation.
2015-01-28 14:21:43 -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
6b9f73ba1f add JupyterHub.admin_access
optionally allow admin users to login to user servers by visiting a special admin-only URL that sets the relevant cookie

- disabled by default
- an 'access server' button is added to the admin panel, which sets the necessary cookie to log in to the user server
2015-01-27 17:04:30 -08:00
Min RK
6dc65d55a5 split cookie setting into sub-methods
so they can be reused
2015-01-27 16:32:15 -08:00
Min RK
213b3e2afb don't track every login as activity
only server activity should be tracked
2015-01-06 15:41:41 -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
6a235da1ce fix redirects when using base_url 2014-11-21 17:56:04 -08:00
Min RK
75d2400b6c fix 'Invalid cookie token' message when no cookie is set 2014-11-04 13:47:08 -08:00