mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-29 23:49:33 +00:00
improved token validation (#4747)
This commit is contained in:
parent
197726a4a9
commit
26e0c5cd10
1 changed files with 8 additions and 4 deletions
|
|
@ -1154,10 +1154,14 @@ end
|
|||
function validateToken(token)
|
||||
|
||||
if (not token) then return false end
|
||||
if (string.len(token) ~= 32) then
|
||||
traceError(TRACE_ERROR, TRACE_CONSOLE, "The token lenght must be of 32 characters!")
|
||||
return false
|
||||
end
|
||||
if (string.len(token) ~= 32) then return false end
|
||||
-- iterate over each byte of the string
|
||||
for b in token:gmatch("%x%x") do
|
||||
-- if the byte is not valid then return false
|
||||
if (tonumber(b, 16) == nil) then
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue