project Websites / videos.bentasker.co.uk avatar

Websites / videos.bentasker.co.uk: 8853869e




VID-13 use containing directory name rather than full path in token minting and validation

VID-13 use containing directory name rather than full path in token minting and validation

Commit 8853869e.

Authored 2019-04-18T16:41:42.000+01:00 by B Tasker in project Websites / videos.bentasker.co.uk

+17 lines -2 lines

Changes

diff --git a/resources/tokenisation/minter/token_gen.lua b/resources/tokenisation/minter/token_gen.lua
--- a/resources/tokenisation/minter/token_gen.lua
+++ b/resources/tokenisation/minter/token_gen.lua
# @@ -92,6 +92,13 @@ local function mint_token(path,expires,ip,secret)
# end
#
#
# +local function getPath(str,sep)
# + -- From https://stackoverflow.com/questions/9102126/lua-return-directory-path-from-path
# + sep=sep or'/'
# + return str:match("(.*"..sep..")")
# +end
# +
# +
# local function sendFailed(reason)
# local r = {status = false, token = 'failed', exp = '-1', msg = reason}
#
# @@ -207,7 +214,7 @@ end
# -- Calculate when the token should expire
# local expires = os.time() + tokenlife
#
# -local tok = mint_token(vidpath,expires,ip,secret)
# +local tok = mint_token(getPath(vidpath),expires,ip,secret)
#
#
# if enable_debug ~= nil
#
diff --git a/resources/tokenisation/minter/token_validate.lua b/resources/tokenisation/minter/token_validate.lua
--- a/resources/tokenisation/minter/token_validate.lua
+++ b/resources/tokenisation/minter/token_validate.lua
# @@ -26,9 +26,17 @@ local function denyaccess(reason)
# end
#
#
# +local function getPath(str,sep)
# + -- From https://stackoverflow.com/questions/9102126/lua-return-directory-path-from-path
# + sep=sep or'/'
# + return str:match("(.*"..sep..")")
# +end
# +
# +
# +
# -- Use same static values as were used to mint the origin token
#
# -vidpath = string.sub(ngx.var.uri,2)
# +vidpath = getPath(string.sub(ngx.var.uri,2))
# ip = ngx.var.remote_addr
# secret = ngx.var.secret
#
#