2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
-- sessions are implemented so as to avoid any local data storage. they
-- are tracked by storing an encrypted cookie which contains an authid,
-- a login epoch time, and a truncated hmac code authenticating both, all
-- encoded using Shorthand. we need functions to generate and parse these
local m = {
maxlen = lib.math.shorthand.maxlen*3 + 2;
maxage = 2 * 60 * 60; -- 2 hours
cookiename = 'auth';
}
terra m.cookie_gen(secret: lib.mem.ptr(int8), authid: uint64, time: uint64, out: &int8): intptr
var ptr = out
ptr = ptr + lib.math.shorthand.gen(authid, ptr)
@ptr = @'.' ptr = ptr + 1
|
|
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
-- sessions are implemented so as to avoid any local data storage. they
-- are tracked by storing an encrypted cookie which contains an authid,
-- a login epoch time, and a truncated hmac code authenticating both, all
-- encoded using Shorthand. we need functions to generate and parse these
local m = {
maxlen = lib.math.shorthand.maxlen*3 + 2;
maxage = 16 * 60 * 60; -- 16 hours
cookiename = 'auth';
}
terra m.cookie_gen(secret: lib.mem.ptr(int8), authid: uint64, time: uint64, out: &int8): intptr
var ptr = out
ptr = ptr + lib.math.shorthand.gen(authid, ptr)
@ptr = @'.' ptr = ptr + 1
|