# HG changeset patch # User Matthew Wild # Date 1673710344 0 # Node ID 2b6c543c4d3a0605bc71de5533004316526e1fb7 # Parent fa56ed2bacabdc799f6cc41d39e838bdfbde1793 mod_unified_push: Fixes for paseto backend initialization Now generates and stores a random key automatically. diff -r fa56ed2bacab -r 2b6c543c4d3a mod_unified_push/mod_unified_push.lua --- a/mod_unified_push/mod_unified_push.lua Sat Jan 14 14:31:37 2023 +0000 +++ b/mod_unified_push/mod_unified_push.lua Sat Jan 14 15:32:24 2023 +0000 @@ -69,6 +69,7 @@ return reg_id; end; verify = function (token) + if token == "_private" then return nil, "invalid-token"; end local data = push_store:get(token); if not data then return nil, "item-not-found"; @@ -81,8 +82,15 @@ }; }; -if pcall(require, "util.paseto") then - local sign, verify = require "util.paseto".init(unified_push_secret); +if pcall(require, "util.paseto") and require "util.paseto".v3_local then + local paseto = require "util.paseto".v3_local; + local state = push_store:get("_private"); + local key = state and state.paseto_v3_local_key; + if not key then + key = paseto.new_key(); + push_store:set("_private", { paseto_v3_local_key = key }); + end + local sign, verify = paseto.init(key); backends.paseto = { sign = sign, verify = verify }; end