Comparison

mod_unified_push/mod_unified_push.lua @ 5155:18ed655c755d

mod_unified_push: Make unified_push_secret only required for jwt backend
author Matthew Wild <mwild1@gmail.com>
date Sat, 14 Jan 2023 17:59:29 +0000
parent 5154:48ca519cd66a
comparison
equal deleted inserted replaced
5154:48ca519cd66a 5155:18ed655c755d
1 local unified_push_secret = assert(module:get_option_string("unified_push_secret"), "required option: unified_push_secret"); 1 local unified_push_secret = module:get_option_string("unified_push_secret");
2 local push_registration_ttl = module:get_option_number("unified_push_registration_ttl", 86400); 2 local push_registration_ttl = module:get_option_number("unified_push_registration_ttl", 86400);
3 3
4 local base64 = require "util.encodings".base64; 4 local base64 = require "util.encodings".base64;
5 local datetime = require "util.datetime"; 5 local datetime = require "util.datetime";
6 local id = require "util.id"; 6 local id = require "util.id";
101 end; 101 end;
102 }; 102 };
103 end 103 end
104 104
105 local backend = module:get_option_string("unified_push_backend", backends.paseto and "paseto" or "storage"); 105 local backend = module:get_option_string("unified_push_backend", backends.paseto and "paseto" or "storage");
106
107 assert(backend ~= "jwt" or unified_push_secret, "required option missing: unified_push_secret");
106 108
107 local function register_route(params) 109 local function register_route(params)
108 local expiry = os.time() + push_registration_ttl; 110 local expiry = os.time() + push_registration_ttl;
109 local token, err = backends[backend].sign({ 111 local token, err = backends[backend].sign({
110 instance = params.instance; 112 instance = params.instance;