@budibase/worker 3.4.11 → 3.4.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@budibase/worker",
3
3
  "email": "hi@budibase.com",
4
- "version": "3.4.11",
4
+ "version": "3.4.13",
5
5
  "description": "Budibase background service",
6
6
  "main": "src/index.ts",
7
7
  "repository": {
@@ -62,6 +62,7 @@
62
62
  "koa-body": "4.2.0",
63
63
  "koa-compress": "4.0.1",
64
64
  "koa-passport": "4.1.4",
65
+ "koa-redis": "^4.0.1",
65
66
  "koa-send": "5.0.1",
66
67
  "koa-session": "5.13.1",
67
68
  "koa-static": "5.0.0",
@@ -82,7 +83,6 @@
82
83
  "@swc/jest": "0.2.27",
83
84
  "@types/jest": "29.5.5",
84
85
  "@types/jsonwebtoken": "9.0.3",
85
- "@types/koa": "2.13.4",
86
86
  "@types/koa__router": "12.0.4",
87
87
  "@types/lodash": "4.14.200",
88
88
  "@types/node-fetch": "2.6.4",
@@ -114,5 +114,5 @@
114
114
  }
115
115
  }
116
116
  },
117
- "gitHead": "f29da76d472126c681c45fd5f59cde1b45cd0fda"
117
+ "gitHead": "e2369c1039767e60669f4588cd69524a954814ff"
118
118
  }
@@ -311,7 +311,7 @@ describe("/api/global/auth", () => {
311
311
  })
312
312
  })
313
313
 
314
- describe("GET /api/global/auth/:tenantId/oidc/callback", () => {
314
+ describe.skip("GET /api/global/auth/:tenantId/oidc/callback", () => {
315
315
  it("logs in", async () => {
316
316
  const email = `${generator.guid()}@example.com`
317
317
 
package/src/index.ts CHANGED
@@ -4,7 +4,7 @@ if (process.env.DD_APM_ENABLED) {
4
4
 
5
5
  // need to load environment first
6
6
  import env from "./environment"
7
- import Application from "koa"
7
+ import Application, { Middleware } from "koa"
8
8
  import { bootstrap } from "global-agent"
9
9
  import * as db from "./db"
10
10
  import { sdk as proSdk } from "@budibase/pro"
@@ -20,6 +20,7 @@ import {
20
20
  cache,
21
21
  features,
22
22
  } from "@budibase/backend-core"
23
+ import RedisStore from "koa-redis"
23
24
 
24
25
  db.init()
25
26
  import koaBody from "koa-body"
@@ -52,7 +53,28 @@ app.proxy = true
52
53
  app.use(handleScimBody)
53
54
  app.use(koaBody({ multipart: true }))
54
55
 
55
- app.use(koaSession(app))
56
+ const sessionMiddleware: Middleware = async (ctx: any, next: any) => {
57
+ const redisClient = await new redis.Client(
58
+ redis.utils.Databases.SESSIONS
59
+ ).init()
60
+ return koaSession(
61
+ {
62
+ // @ts-ignore
63
+ store: new RedisStore({ client: redisClient.getClient() }),
64
+ key: "koa:sess",
65
+ maxAge: 86400000, // one day
66
+ httpOnly: true,
67
+ secure: process.env.NODE_ENV === "production",
68
+ sameSite: "strict",
69
+ rolling: true,
70
+ renew: true,
71
+ },
72
+ app
73
+ )(ctx, next)
74
+ }
75
+
76
+ app.use(sessionMiddleware)
77
+
56
78
  app.use(middleware.correlation)
57
79
  app.use(middleware.pino)
58
80
  app.use(middleware.ip)
@@ -0,0 +1 @@
1
+ declare module "koa-redis" {}