From 65cad5efad91de015697f55c2ba6fd6fd3a420a1 Mon Sep 17 00:00:00 2001 From: Joshua Milas Date: Mon, 11 Sep 2017 00:09:57 -0400 Subject: [PATCH] Updated the reference flask example to include token auth --- docs/source/reference/services.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/source/reference/services.md b/docs/source/reference/services.md index c358ad74..faf99914 100644 --- a/docs/source/reference/services.md +++ b/docs/source/reference/services.md @@ -200,7 +200,9 @@ or via the `JUPYTERHUB_API_TOKEN` environment variable. Most of the logic for authentication implementation is found in the [`HubAuth.user_for_cookie`](services.auth.html#jupyterhub.services.auth.HubAuth.user_for_cookie) -method, which makes a request of the Hub, and returns: +and in the +[`HubAuth.user_for_token`](services.auth.html#jupyterhub.services.auth.HubAuth.user_for_token) +methods, which makes a request of the Hub, and returns: - None, if no user could be identified, or - a dict of the following form: @@ -252,8 +254,11 @@ def authenticated(f): @wraps(f) def decorated(*args, **kwargs): cookie = request.cookies.get(auth.cookie_name) + token = request.headers.get(auth.auth_header_name) if cookie: user = auth.user_for_cookie(cookie) + elif token: + user = auth.user_for_token(token) else: user = None if user: