mod_auth_token/token_auth_utils.lib.lua
changeset 3572 6b3181fe5617
parent 3476 ac1f63cdb6d6
child 3697 0fb12a4b6106
equal deleted inserted replaced
3571:179424d557f2 3572:6b3181fe5617
    46 	local otp = token:sub(1,8)
    46 	local otp = token:sub(1,8)
    47 	local nonce = token:sub(9)
    47 	local nonce = token:sub(9)
    48 	local signature = base64.decode(string.match(password, " (.+)"))
    48 	local signature = base64.decode(string.match(password, " (.+)"))
    49 	local jid = username.."@"..realm
    49 	local jid = username.."@"..realm
    50 
    50 
    51 	if totp:verify(otp, OTP_DEVIATION, luatz.gmtime(luatz.time())) then
    51 	if totp:verify(otp, OTP_DEVIATION, luatz.time()) then
    52 		log("debug", "The TOTP was verified");
    52 		log("debug", "The TOTP was verified");
    53 		local hmac_ctx = hmac.new(token_secret, DIGEST_TYPE)
    53 		local hmac_ctx = hmac.new(token_secret, DIGEST_TYPE)
    54 		if signature == hmac_ctx:final(otp..nonce..jid) then
    54 		if signature == hmac_ctx:final(otp..nonce..jid) then
    55 			log("debug", "The key was verified");
    55 			log("debug", "The key was verified");
    56 			if check_nonce(jid, otp, nonce) then
    56 			if check_nonce(jid, otp, nonce) then