Linting.
This commit is contained in:
parent
e7974f7e86
commit
88c07d28eb
|
@ -1,9 +1,5 @@
|
||||||
const redis = require("../redis/authRedis")
|
const redis = require("../redis/authRedis")
|
||||||
const {
|
const { getTenantId, lookupTenantId, getGlobalDB } = require("../tenancy")
|
||||||
getTenantId,
|
|
||||||
lookupTenantId,
|
|
||||||
getGlobalDB,
|
|
||||||
} = require("../tenancy")
|
|
||||||
|
|
||||||
const EXPIRY_SECONDS = 3600
|
const EXPIRY_SECONDS = 3600
|
||||||
|
|
||||||
|
|
|
@ -7,18 +7,20 @@ class FunctionContext {
|
||||||
static getMiddleware(updateCtxFn = null) {
|
static getMiddleware(updateCtxFn = null) {
|
||||||
const namespace = this.createNamespace()
|
const namespace = this.createNamespace()
|
||||||
|
|
||||||
return async function(ctx, next) {
|
return async function (ctx, next) {
|
||||||
await new Promise(namespace.bind(function(resolve, reject) {
|
await new Promise(
|
||||||
// store a contextual request ID that can be used anywhere (audit logs)
|
namespace.bind(function (resolve, reject) {
|
||||||
namespace.set(REQUEST_ID_KEY, newid())
|
// store a contextual request ID that can be used anywhere (audit logs)
|
||||||
namespace.bindEmitter(ctx.req)
|
namespace.set(REQUEST_ID_KEY, newid())
|
||||||
namespace.bindEmitter(ctx.res)
|
namespace.bindEmitter(ctx.req)
|
||||||
|
namespace.bindEmitter(ctx.res)
|
||||||
|
|
||||||
if (updateCtxFn) {
|
if (updateCtxFn) {
|
||||||
updateCtxFn(ctx)
|
updateCtxFn(ctx)
|
||||||
}
|
}
|
||||||
next().then(resolve).catch(reject)
|
next().then(resolve).catch(reject)
|
||||||
}))
|
})
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,7 +37,9 @@ class FunctionContext {
|
||||||
|
|
||||||
static getContextStorage() {
|
static getContextStorage() {
|
||||||
if (this._namespace && this._namespace.active) {
|
if (this._namespace && this._namespace.active) {
|
||||||
const { id, _ns_name, ...contextData } = this._namespace.active
|
let contextData = this._namespace.active
|
||||||
|
delete contextData.id
|
||||||
|
delete contextData._ns_name
|
||||||
return contextData
|
return contextData
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,10 @@ exports.updateTenantId = tenantId => {
|
||||||
cls.setOnContext(TENANT_ID, tenantId)
|
cls.setOnContext(TENANT_ID, tenantId)
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.setTenantId = (ctx, opts = { allowQs: false, allowNoTenant: false }) => {
|
exports.setTenantId = (
|
||||||
|
ctx,
|
||||||
|
opts = { allowQs: false, allowNoTenant: false }
|
||||||
|
) => {
|
||||||
let tenantId
|
let tenantId
|
||||||
// exit early if not multi-tenant
|
// exit early if not multi-tenant
|
||||||
if (!exports.isMultiTenant()) {
|
if (!exports.isMultiTenant()) {
|
||||||
|
|
|
@ -13,7 +13,13 @@ const { user: userCache } = require("@budibase/auth/cache")
|
||||||
const { invalidateSessions } = require("@budibase/auth/sessions")
|
const { invalidateSessions } = require("@budibase/auth/sessions")
|
||||||
const CouchDB = require("../../../db")
|
const CouchDB = require("../../../db")
|
||||||
const env = require("../../../environment")
|
const env = require("../../../environment")
|
||||||
const { getGlobalDB, getTenantId, doesTenantExist, tryAddTenant, updateTenantId } = require("@budibase/auth/tenancy")
|
const {
|
||||||
|
getGlobalDB,
|
||||||
|
getTenantId,
|
||||||
|
doesTenantExist,
|
||||||
|
tryAddTenant,
|
||||||
|
updateTenantId,
|
||||||
|
} = require("@budibase/auth/tenancy")
|
||||||
|
|
||||||
const PLATFORM_INFO_DB = StaticDatabases.PLATFORM_INFO.name
|
const PLATFORM_INFO_DB = StaticDatabases.PLATFORM_INFO.name
|
||||||
|
|
||||||
|
|
|
@ -54,14 +54,26 @@ router
|
||||||
authController.resetUpdate
|
authController.resetUpdate
|
||||||
)
|
)
|
||||||
.post("/api/global/auth/logout", authController.logout)
|
.post("/api/global/auth/logout", authController.logout)
|
||||||
.get("/api/global/auth/:tenantId/google", updateTenant, authController.googlePreAuth)
|
.get(
|
||||||
.get("/api/global/auth/:tenantId/google/callback", updateTenant, authController.googleAuth)
|
"/api/global/auth/:tenantId/google",
|
||||||
|
updateTenant,
|
||||||
|
authController.googlePreAuth
|
||||||
|
)
|
||||||
|
.get(
|
||||||
|
"/api/global/auth/:tenantId/google/callback",
|
||||||
|
updateTenant,
|
||||||
|
authController.googleAuth
|
||||||
|
)
|
||||||
.get(
|
.get(
|
||||||
"/api/global/auth/:tenantId/oidc/configs/:configId",
|
"/api/global/auth/:tenantId/oidc/configs/:configId",
|
||||||
updateTenant,
|
updateTenant,
|
||||||
authController.oidcPreAuth
|
authController.oidcPreAuth
|
||||||
)
|
)
|
||||||
.get("/api/global/auth/:tenantId/oidc/callback", updateTenant, authController.oidcAuth)
|
.get(
|
||||||
|
"/api/global/auth/:tenantId/oidc/callback",
|
||||||
|
updateTenant,
|
||||||
|
authController.oidcAuth
|
||||||
|
)
|
||||||
// deprecated - used by the default system before tenancy
|
// deprecated - used by the default system before tenancy
|
||||||
.get("/api/admin/auth/google/callback", authController.googleAuth)
|
.get("/api/admin/auth/google/callback", authController.googleAuth)
|
||||||
.get("/api/admin/auth/oidc/callback", authController.oidcAuth)
|
.get("/api/admin/auth/oidc/callback", authController.oidcAuth)
|
||||||
|
|
Loading…
Reference in New Issue