Software /
code /
prosody
Comparison
util/paseto.lua @ 12711:9e9f158d6699
util.paseto: Export similar API to new util.jwt for ease and consistency
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Mon, 11 Jul 2022 14:09:16 +0100 |
parent | 12710:2dbb3335cd34 |
child | 12713:52eead170bb8 |
comparison
equal
deleted
inserted
replaced
12710:2dbb3335cd34 | 12711:9e9f158d6699 |
---|---|
118 return setmetatable({ | 118 return setmetatable({ |
119 key = key; | 119 key = key; |
120 }, v4_public_privkey_mt); | 120 }, v4_public_privkey_mt); |
121 end | 121 end |
122 | 122 |
123 function v4_public.init(private_key_pem, public_key_pem, options) | |
124 local sign, verify = v4_public.sign, v4_public.verify; | |
125 local public_key = public_key_pem and v4_public.import_public_key(public_key_pem); | |
126 local private_key = private_key_pem and v4_public.import_private_key(private_key_pem); | |
127 local default_footer = options and options.default_footer; | |
128 local default_assertion = options and options.default_implicit_assertion; | |
129 return private_key and function (token, token_footer, token_assertion) | |
130 return sign(token, private_key, token_footer or default_footer, token_assertion or default_assertion); | |
131 end, public_key and function (token, expected_footer, token_assertion) | |
132 return verify(token, public_key, expected_footer or default_footer, token_assertion or default_assertion); | |
133 end; | |
134 end | |
135 | |
136 function v4_public.new_signer(private_key_pem, options) | |
137 return (v4_public.init(private_key_pem, nil, options)); | |
138 end | |
139 | |
140 function v4_public.new_verifier(public_key_pem, options) | |
141 return (select(2, v4_public.init(public_key_pem, options))); | |
142 end | |
143 | |
123 return { | 144 return { |
124 pae = pae; | 145 pae = pae; |
125 v4_public = v4_public; | 146 v4_public = v4_public; |
126 }; | 147 }; |