]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
Make authentication ticket lifetime configurable
authorDietmar Konermann <dk@diddle-online.de>
Tue, 23 Oct 2018 12:35:26 +0000 (14:35 +0200)
committerJaroslav Kysela <perex@perex.cz>
Thu, 25 Oct 2018 16:44:02 +0000 (18:44 +0200)
src/access.c
src/config.c
src/config.h
src/webui/comet.c

index a9e1990e44c698aa57e8fd5324ef66a690d874b5..330fb7f4f9ae00bf0619dbefca15879b01d1eedf 100644 (file)
@@ -39,8 +39,6 @@
 #include "tcp.h"
 #include "lang_codes.h"
 
-#define TICKET_LIFETIME (5*60) /* in seconds */
-
 struct access_entry_queue access_entries;
 struct access_ticket_queue access_tickets;
 struct passwd_entry_queue passwd_entries;
@@ -124,7 +122,7 @@ access_ticket_timeout(void *aux)
 const char *
 access_ticket_create(const char *resource, access_t *a)
 {
-  const int64_t lifetime = sec2mono(TICKET_LIFETIME);
+  const int64_t lifetime = sec2mono(config.ticket_expires);
   uint8_t buf[20];
   char id[41];
   uint_fast32_t i;
index 35548a59a6e1857c7e1cb98f0731b5096ef61f4e..cd4d31046c5aa21490c788225ae37af2724e536a 100644 (file)
@@ -1695,6 +1695,7 @@ config_boot
   config.realm = strdup("tvheadend");
   config.info_area = strdup("login,storage,time");
   config.cookie_expires = 7;
+  config.ticket_expires = 5 * 60;
   config.dscp = -1;
   config.descrambler_buffer = 9000;
   config.epg_compress = 1;
@@ -2393,6 +2394,17 @@ const idclass_t config_class = {
       .opts   = PO_EXPERT,
       .group  = 5
     },
+    {
+      .type   = PT_U32,
+      .intextra = INTEXTRA_RANGE(1, 0x7ff, 1),
+      .id     = "ticket_expires",
+      .name   = N_("Ticket expiration (seconds)"),
+      .desc   = N_("The number of seconds in which authentication tickets generated by "
+                   "Tvheadend should expire."),
+      .off    = offsetof(config_t, ticket_expires),
+      .opts   = PO_EXPERT,
+      .group  = 5
+    },
     {
       .type   = PT_BOOL,
       .id     = "proxy",
index 87891a3374bffd93db2e02a6c13ac383a51fef27..19ada3c97db96b677cf6cd18b7a8fa247714eb0d 100644 (file)
@@ -69,6 +69,7 @@ typedef struct config {
   int iptv_tpool_count;
   char *date_mask;
   int label_formatting;
+  uint32_t ticket_expires;
 } config_t;
 
 extern const idclass_t config_class;
index de762d82940c5a9cbd5da07fc988b016454696d7..5f5b6d0430e36998d13c869f3a644f4e8bb7aaab 100644 (file)
@@ -205,6 +205,9 @@ comet_access_update(http_connection_t *hc, comet_mailbox_t *cmb)
   if (config.cookie_expires)
     htsmsg_add_u32(m, "cookie_expires", config.cookie_expires);
 
+  if (config.ticket_expires)
+    htsmsg_add_u32(m, "ticket_expires", config.ticket_expires);
+
   if (config.info_area && config.info_area[0])
     htsmsg_add_str(m, "info_area", config.info_area);