Skip to content

Commit

Permalink
fix(auth): interact redirect (#2832)
Browse files Browse the repository at this point in the history
* fix(auth): interact redirect

* fix(auth): session cookie not expiring in browser

* fix(auth): session expiration time unit

---------

Co-authored-by: Blair Currey <[email protected]>
  • Loading branch information
sabineschaller and BlairCurrey authored Aug 7, 2024
1 parent 8338dfc commit 2c8887d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
25 changes: 9 additions & 16 deletions packages/auth/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,18 +353,22 @@ export class App {
signed: true,
store: {
async get(key) {
return await redis.hgetall(key)
const s = await redis.get(key)

if (!s) return null

return JSON.parse(s)
},
async set(key, session) {
// Add a delay to cookie age to ensure redis record expires after cookie
const expireInMs = maxAgeMs + 10 * 1000
const expireInSec = maxAgeMs / 1000 + 10
const op = redis.multi()
op.hset(key, session)
op.expire(key, expireInMs)
op.set(key, JSON.stringify(session))
op.expire(key, expireInSec)
await op.exec()
},
async destroy(key) {
await redis.hdel(key)
await redis.del(key)
}
}
},
Expand Down Expand Up @@ -441,17 +445,6 @@ export class App {

koa.use(cors())
koa.keys = [this.config.cookieKey]
koa.use(
session(
{
key: 'sessionId',
maxAge: 60 * 1000,
signed: true
},
koa
)
)

koa.use(router.middleware())
koa.use(router.routes())

Expand Down
1 change: 0 additions & 1 deletion packages/auth/src/interaction/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ async function startInteraction(

const trx = await Interaction.startTransaction()
try {
// TODO: also establish session in redis with short expiry
await grantService.markPending(interaction.id, trx)
await trx.commit()

Expand Down

0 comments on commit 2c8887d

Please sign in to comment.