Add pre and post validation for users that want to use their own public keys

This commit is contained in:
Andrei Bora
2020-08-11 17:29:34 +03:00
parent 10c2652a4f
commit 92e6cf7618
2 changed files with 25 additions and 7 deletions

View File

@@ -301,7 +301,10 @@ function Util:process_and_verify_token(session, acceptedIssuers)
end
local pubKey;
if self.asapKeyServer and session.auth_token ~= nil then
if session.public_key then
module:log("debug","Public key was found on the session");
pubKey = session.public_key;
elseif self.asapKeyServer and session.auth_token ~= nil then
local dotFirst = session.auth_token:find("%.");
if not dotFirst then return nil, "Invalid token" end
local header, err = json_safe.decode(basexx.from_url64(session.auth_token:sub(1,dotFirst-1)));