Normalize line endings
[msb/apigateway.git] / msb-core / openresty-ext / src / assembly / resources / openresty / nginx / luaext / auth.lua
1 local cache = ngx.shared.ceryx
2 local client_ip = ngx.var.remote_addr
3 local host = ngx.var.host
4 if client_ip == '127.0.0.1' or client_ip == host or client_ip == ngx.var.server_addr then
5         return
6 end     
7 local succ, err, forcible = cache:replace(client_ip, "place_holder", 3600)
8 if not succ then
9         if err == 'not found' then
10                 ngx.log(ngx.WARN, "access record not found for "..client_ip)
11                 ngx.exit(401)
12         else
13                 ngx.log(ngx.WARN, err)
14         end     
15 end