summaryrefslogtreecommitdiffstats
path: root/lib/session.lua
diff options
context:
space:
mode:
authorMike Mason <ms13sp@gmail.com>2008-02-07 14:36:23 +0000
committerMike Mason <ms13sp@gmail.com>2008-02-07 14:36:23 +0000
commit91d0d9e6292ba2f2f0541e0489a2b53eeaff00b3 (patch)
treee0b3756dea6596dcbcf31e8e8e37c19c40fcad80 /lib/session.lua
parent488d84633e944dda8381ce9e8fd99674702b9e8c (diff)
downloadacf-core-91d0d9e6292ba2f2f0541e0489a2b53eeaff00b3.tar.bz2
acf-core-91d0d9e6292ba2f2f0541e0489a2b53eeaff00b3.tar.xz
Cleaning up the session management and expiration items. Will be more bug fixes/changes to come...
git-svn-id: svn://svn.alpinelinux.org/acf/core/trunk@706 ab2d0c66-481e-0410-8bed-d214d4d58bed
Diffstat (limited to 'lib/session.lua')
-rw-r--r--lib/session.lua20
1 files changed, 14 insertions, 6 deletions
diff --git a/lib/session.lua b/lib/session.lua
index 751b693..c6ea7ca 100644
--- a/lib/session.lua
+++ b/lib/session.lua
@@ -15,6 +15,10 @@ module (..., package.seeall)
require "posix"
require "format"
+minutes_expired_events=30
+minutes_count_events=30
+limit_count_events=10
+
local b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-"
-- Return a sessionid of at least size bits length
@@ -183,17 +187,17 @@ end
-- Check how many invalid login events
-- have happened for this id in the last n minutes
-- this will only effect the lockevent files
-count_events = function (sessionpath, id_user, ipaddr, minutes)
+count_events = function (sessionpath, id_user, ipaddr)
--we need to have the counts added up? deny off any and or all
local now = os.time()
- local minutes_ago = now - (minutes * 60)
+ local minutes_ago = now - (minutes_count_events * 60)
local t = {}
--give me all lockevents then we will sort through them
local searchfor = sessionpath .. "/lockevent.*"
local t = posix.glob(searchfor)
if t == nil or id_user == nil or ipaddr == nil then
- return 0
+ return false
else
local temp = {}
@@ -208,17 +212,21 @@ count_events = function (sessionpath, id_user, ipaddr, minutes)
if c ~= nil then temp2[#temp2 + 1] = v end
end
- return #temp2
+ if #temp2 > limit_count_events then
+ return true
+ else
+ return false
+ end
end
end
-- Clear events that are older than n minutes
-expired_events = function (sessionpath, minutes)
+expired_events = function (sessionpath)
--current os time in seconds
local now = os.time()
--take minutes and convert to seconds
- local minutes_ago = now - (minutes * 60)
+ local minutes_ago = now - (minutes_expired_events * 60)
local searchfor = sessionpath .. "/lockevent.*"
--first do the lockevent files
local temp = posix.glob(searchfor)