-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Konstantin Burkalev
authored and
Konstantin Burkalev
committed
Nov 8, 2016
1 parent
f989ae7
commit 902c611
Showing
5 changed files
with
418 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
-- | ||
-- Project: wiola | ||
-- User: Konstantin Burkalev | ||
-- Date: 08.11.16 | ||
-- | ||
|
||
local _M = {} | ||
|
||
-- | ||
-- Cleans up wiola session data in redis store | ||
-- | ||
-- redis - Redis instance on which to operate | ||
-- regId - WAMP session registration ID | ||
-- | ||
function _M.cleanupSession(redis, regId) | ||
|
||
local session = redis:array_to_hash(redis:hgetall("wiSes" .. regId)) | ||
session.realm = session.realm or "" | ||
|
||
local subscriptions = redis:array_to_hash(redis:hgetall("wiRealm" .. session.realm .. "Subs")) | ||
|
||
for k, v in pairs(subscriptions) do | ||
redis:srem("wiRealm" .. session.realm .. "Sub" .. k .. "Sessions", regId) | ||
if redis:scard("wiRealm" .. session.realm .. "Sub" .. k .. "Sessions") == 0 then | ||
redis:del("wiRealm" .. session.realm .. "Sub" .. k .. "Sessions") | ||
redis:hdel("wiRealm" .. session.realm .. "Subs",k) | ||
redis:hdel("wiRealm" .. session.realm .. "RevSubs",v) | ||
end | ||
end | ||
|
||
local rpcs = redis:array_to_hash(redis:hgetall("wiSes" .. regId .. "RPCs")) | ||
|
||
for k, v in pairs(rpcs) do | ||
redis:srem("wiRealm" .. session.realm .. "RPCs",k) | ||
redis:del("wiRPC" .. k) | ||
end | ||
|
||
redis:del("wiSes" .. regId .. "RPCs") | ||
redis:del("wiSes" .. regId .. "RevRPCs") | ||
redis:del("wiSes" .. regId .. "Challenge") | ||
|
||
redis:srem("wiRealm" .. session.realm .. "Sessions", regId) | ||
if redis:scard("wiRealm" .. session.realm .. "Sessions") == 0 then | ||
redis:srem("wiolaRealms",session.realm) | ||
end | ||
|
||
redis:del("wiSes" .. regId .. "Data") | ||
redis:del("wiSes" .. regId) | ||
redis:srem("wiolaIds",regId) | ||
end | ||
|
||
return _M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
-- | ||
-- Project: wiola | ||
-- User: Konstantin Burkalev | ||
-- Date: 01.11.16 | ||
-- | ||
|
||
|
||
-- Redis connection configuration | ||
local redisConf = { | ||
host = "unix:/tmp/redis.sock", | ||
port = nil, | ||
db = nil | ||
} | ||
|
||
-- Wiola Runtime configuration | ||
local wiolaConf = { | ||
callerIdentification = "auto", -- auto | never | always | ||
cookieAuth = { | ||
authType = "none", -- none | static | dynamic | ||
cookieName = "wampauth", | ||
staticCredentials = nil, --{ | ||
-- "user1", "user2:password2", "secretkey3" | ||
--}, | ||
authCallback = nil | ||
}, | ||
wampCRA = { | ||
authType = "none", -- none | static | dynamic | ||
staticCredentials = nil, --{ | ||
-- user1 = { authrole = "userRole1", secret="secret1" }, | ||
-- user2 = { authrole = "userRole2", secret="secret2" } | ||
--}, | ||
challengeCallback = nil, | ||
authCallback = nil | ||
} | ||
} | ||
|
||
local _M = {} | ||
|
||
-- | ||
-- Get or set Wiola Runtime configuration | ||
-- | ||
-- config - Configuration table with possible options: | ||
-- { | ||
-- redis = { | ||
-- host = string - redis host or unix socket (default: "unix:/tmp/redis.sock"), | ||
-- port = number - redis port in case of network use (default: nil), | ||
-- db = number - redis database to select (default: nil) | ||
-- }, | ||
-- callerIdentification = string - Disclose caller identification? | ||
-- Possible values: auto | never | always. (default: "auto") | ||
-- } | ||
-- without params it just returns current configuration | ||
-- | ||
function _M.config(config) | ||
|
||
if not config then | ||
local conf = wiolaConf | ||
conf.redis = redisConf | ||
return conf | ||
end | ||
|
||
if config.redis then | ||
|
||
if config.redis.host ~= nil then | ||
redisConf.host = config.redis.host | ||
end | ||
|
||
if config.redis.port ~= nil then | ||
redisConf.port = config.redis.port | ||
end | ||
|
||
if config.redis.db ~= nil then | ||
redisConf.db = config.redis.db | ||
end | ||
end | ||
|
||
if config.callerIdentification ~= nil then | ||
wiolaConf.callerIdentification = config.callerIdentification | ||
end | ||
|
||
if config.cookieAuth then | ||
|
||
if config.cookieAuth.authType ~= nil then | ||
wiolaConf.cookieAuth.authType = config.cookieAuth.authType | ||
end | ||
|
||
if config.cookieAuth.cookieName ~= nil then | ||
wiolaConf.cookieAuth.cookieName = config.cookieAuth.cookieName | ||
end | ||
|
||
if config.cookieAuth.staticCredentials ~= nil then | ||
wiolaConf.cookieAuth.staticCredentials = config.cookieAuth.staticCredentials | ||
end | ||
|
||
if config.cookieAuth.authCallback ~= nil then | ||
wiolaConf.cookieAuth.authCallback = config.cookieAuth.authCallback | ||
end | ||
end | ||
|
||
if config.wampCRA then | ||
|
||
if config.wampCRA.authType ~= nil then | ||
wiolaConf.wampCRA.authType = config.wampCRA.authType | ||
end | ||
|
||
if config.wampCRA.staticCredentials ~= nil then | ||
wiolaConf.wampCRA.staticCredentials = config.wampCRA.staticCredentials | ||
end | ||
|
||
if config.wampCRA.challengeCallback ~= nil then | ||
wiolaConf.wampCRA.challengeCallback = config.wampCRA.challengeCallback | ||
end | ||
|
||
if config.wampCRA.authCallback ~= nil then | ||
wiolaConf.wampCRA.authCallback = config.wampCRA.authCallback | ||
end | ||
end | ||
end | ||
|
||
return _M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.