From 3783a1bc6c4648beae680ed210a43aca3477fd9c Mon Sep 17 00:00:00 2001 From: Min RK Date: Mon, 2 Aug 2021 14:37:44 +0200 Subject: [PATCH] Backport PR #3552: Add expiration date dropdown to Token page --- share/jupyterhub/static/js/token.js | 7 ++++++- share/jupyterhub/templates/token.html | 22 ++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/share/jupyterhub/static/js/token.js b/share/jupyterhub/static/js/token.js index 2a0e3f7e..3022a3f2 100644 --- a/share/jupyterhub/static/js/token.js +++ b/share/jupyterhub/static/js/token.js @@ -20,9 +20,14 @@ require(["jquery", "jhapi", "moment"], function ($, JHAPI, moment) { if (!note.length) { note = "Requested via token page"; } + var expiration_seconds = + parseInt($("#token-expiration-seconds").val()) || null; api.request_token( user, - { note: note }, + { + note: note, + expires_in: expiration_seconds, + }, { success: function (reply) { $("#token-result").text(reply.token); diff --git a/share/jupyterhub/templates/token.html b/share/jupyterhub/templates/token.html index a493c8e8..aa30aa3b 100644 --- a/share/jupyterhub/templates/token.html +++ b/share/jupyterhub/templates/token.html @@ -19,6 +19,20 @@ This note will help you keep track of what your tokens are for. +

+ + {% block expiration_options %} + + {% endblock expiration_options %} + + You can configure when your token will be expired. + @@ -56,6 +70,7 @@ Note Last used Created + Expires at @@ -77,6 +92,13 @@ N/A {%- endif -%} + + {%- if token.expires_at -%} + {{ token.expires_at.isoformat() + 'Z' }} + {%- else -%} + Never + {%- endif -%} +