Merge pull request #3995 from Budibase/feature/auth-core

Renaming @budibase/auth to @budibase/backend-core
This commit is contained in:
Michael Drury 2022-01-11 17:19:08 +00:00 committed by GitHub
commit 71240f1613
166 changed files with 216 additions and 187 deletions

View File

@ -4,7 +4,7 @@ This library contains core functionality, like auth and security features
which are shared between backend services. which are shared between backend services.
#### Note about top level JS files #### Note about top level JS files
For the purposes of being able to do say `require("@budibase/auth/permissions")` we need to For the purposes of being able to do say `require("@budibase/backend-core/permissions")` we need to
specify the exports at the top-level of the module. specify the exports at the top-level of the module.
For these files they should be limited to a single `require` of the file that should For these files they should be limited to a single `require` of the file that should

View File

@ -1,7 +1,7 @@
{ {
"name": "@budibase/auth", "name": "@budibase/backend-core",
"version": "1.0.27-alpha.11", "version": "1.0.27-alpha.11",
"description": "Authentication middlewares for budibase builder and apps", "description": "Budibase backend core libraries used in server and worker",
"main": "src/index.js", "main": "src/index.js",
"author": "Budibase", "author": "Budibase",
"license": "GPL-3.0", "license": "GPL-3.0",

View File

@ -70,7 +70,7 @@
"license": "GPL-3.0", "license": "GPL-3.0",
"dependencies": { "dependencies": {
"@apidevtools/swagger-parser": "^10.0.3", "@apidevtools/swagger-parser": "^10.0.3",
"@budibase/auth": "^1.0.27-alpha.11", "@budibase/backend-core": "^1.0.27-alpha.11",
"@budibase/client": "^1.0.27-alpha.11", "@budibase/client": "^1.0.27-alpha.11",
"@budibase/string-templates": "^1.0.27-alpha.11", "@budibase/string-templates": "^1.0.27-alpha.11",
"@bull-board/api": "^3.7.0", "@bull-board/api": "^3.7.0",

View File

@ -7,7 +7,7 @@
const CouchDB = require("../src/db") const CouchDB = require("../src/db")
const { DocumentTypes } = require("../src/db/utils") const { DocumentTypes } = require("../src/db/utils")
const { getAllDbs } = require("@budibase/auth/db") const { getAllDbs } = require("@budibase/backend-core/db")
const appName = process.argv[2].toLowerCase() const appName = process.argv[2].toLowerCase()
const remoteUrl = process.argv[3] const remoteUrl = process.argv[3]

View File

@ -1,5 +1,5 @@
const { StaticDatabases } = require("@budibase/auth/db") const { StaticDatabases } = require("@budibase/backend-core/db")
const { getGlobalDB } = require("@budibase/auth/tenancy") const { getGlobalDB } = require("@budibase/backend-core/tenancy")
const KEYS_DOC = StaticDatabases.GLOBAL.docs.apiKeys const KEYS_DOC = StaticDatabases.GLOBAL.docs.apiKeys

View File

@ -19,7 +19,10 @@ const {
DocumentTypes, DocumentTypes,
AppStatus, AppStatus,
} = require("../../db/utils") } = require("../../db/utils")
const { BUILTIN_ROLE_IDS, AccessController } = require("@budibase/auth/roles") const {
BUILTIN_ROLE_IDS,
AccessController,
} = require("@budibase/backend-core/roles")
const { BASE_LAYOUTS } = require("../../constants/layouts") const { BASE_LAYOUTS } = require("../../constants/layouts")
const { cloneDeep } = require("lodash/fp") const { cloneDeep } = require("lodash/fp")
const { processObject } = require("@budibase/string-templates") const { processObject } = require("@budibase/string-templates")
@ -28,7 +31,7 @@ const {
isDevAppID, isDevAppID,
getDeployedAppID, getDeployedAppID,
Replication, Replication,
} = require("@budibase/auth/db") } = require("@budibase/backend-core/db")
const { USERS_TABLE_SCHEMA } = require("../../constants") const { USERS_TABLE_SCHEMA } = require("../../constants")
const { const {
getDeployedApps, getDeployedApps,
@ -41,9 +44,9 @@ const {
backupClientLibrary, backupClientLibrary,
revertClientLibrary, revertClientLibrary,
} = require("../../utilities/fileSystem/clientLibrary") } = require("../../utilities/fileSystem/clientLibrary")
const { getTenantId, isMultiTenant } = require("@budibase/auth/tenancy") const { getTenantId, isMultiTenant } = require("@budibase/backend-core/tenancy")
const { syncGlobalUsers } = require("./user") const { syncGlobalUsers } = require("./user")
const { app: appCache } = require("@budibase/auth/cache") const { app: appCache } = require("@budibase/backend-core/cache")
const { cleanupAutomations } = require("../../automations/utils") const { cleanupAutomations } = require("../../automations/utils")
const URL_REGEX_SLASH = /\/|\\/g const URL_REGEX_SLASH = /\/|\\/g

View File

@ -2,7 +2,7 @@ const CouchDB = require("../../db")
const { outputProcessing } = require("../../utilities/rowProcessor") const { outputProcessing } = require("../../utilities/rowProcessor")
const { InternalTables } = require("../../db/utils") const { InternalTables } = require("../../db/utils")
const { getFullUser } = require("../../utilities/users") const { getFullUser } = require("../../utilities/users")
const { BUILTIN_ROLE_IDS } = require("@budibase/auth/roles") const { BUILTIN_ROLE_IDS } = require("@budibase/backend-core/roles")
exports.fetchSelf = async ctx => { exports.fetchSelf = async ctx => {
const appId = ctx.appId const appId = ctx.appId

View File

@ -1,5 +1,5 @@
const env = require("../../environment") const env = require("../../environment")
const { getAllApps } = require("@budibase/auth/db") const { getAllApps } = require("@budibase/backend-core/db")
const CouchDB = require("../../db") const CouchDB = require("../../db")
const { const {
exportDB, exportDB,
@ -7,7 +7,10 @@ const {
readFileSync, readFileSync,
} = require("../../utilities/fileSystem") } = require("../../utilities/fileSystem")
const { stringToReadStream } = require("../../utilities") const { stringToReadStream } = require("../../utilities")
const { getGlobalDBName, getGlobalDB } = require("@budibase/auth/tenancy") const {
getGlobalDBName,
getGlobalDB,
} = require("@budibase/backend-core/tenancy")
const { create } = require("./application") const { create } = require("./application")
const { getDocParams, DocumentTypes, isDevAppID } = require("../../db/utils") const { getDocParams, DocumentTypes, isDevAppID } = require("../../db/utils")

View File

@ -1,12 +1,12 @@
const CouchDB = require("../../../db") const CouchDB = require("../../../db")
const Deployment = require("./Deployment") const Deployment = require("./Deployment")
const { Replication, getDeployedAppID } = require("@budibase/auth/db") const { Replication, getDeployedAppID } = require("@budibase/backend-core/db")
const { DocumentTypes, getAutomationParams } = require("../../../db/utils") const { DocumentTypes, getAutomationParams } = require("../../../db/utils")
const { const {
disableAllCrons, disableAllCrons,
enableCronTrigger, enableCronTrigger,
} = require("../../../automations/utils") } = require("../../../automations/utils")
const { app: appCache } = require("@budibase/auth/cache") const { app: appCache } = require("@budibase/backend-core/cache")
// the max time we can wait for an invalidation to complete before considering it failed // the max time we can wait for an invalidation to complete before considering it failed
const MAX_PENDING_TIME_MS = 30 * 60000 const MAX_PENDING_TIME_MS = 30 * 60000

View File

@ -4,9 +4,9 @@ const env = require("../../environment")
const { checkSlashesInUrl } = require("../../utilities") const { checkSlashesInUrl } = require("../../utilities")
const { request } = require("../../utilities/workerRequests") const { request } = require("../../utilities/workerRequests")
const { clearLock } = require("../../utilities/redis") const { clearLock } = require("../../utilities/redis")
const { Replication } = require("@budibase/auth").db const { Replication } = require("@budibase/backend-core").db
const { DocumentTypes } = require("../../db/utils") const { DocumentTypes } = require("../../db/utils")
const { app: appCache } = require("@budibase/auth/cache") const { app: appCache } = require("@budibase/backend-core/cache")
async function redirect(ctx, method, path = "global") { async function redirect(ctx, method, path = "global") {
const { devPath } = ctx.params const { devPath } = ctx.params

View File

@ -1,7 +1,7 @@
const CouchDB = require("../../db") const CouchDB = require("../../db")
const { getDeployedApps } = require("../../utilities/workerRequests") const { getDeployedApps } = require("../../utilities/workerRequests")
const { getScopedConfig } = require("@budibase/auth/db") const { getScopedConfig } = require("@budibase/backend-core/db")
const { Configs } = require("@budibase/auth").constants const { Configs } = require("@budibase/backend-core").constants
const { checkSlashesInUrl } = require("../../utilities") const { checkSlashesInUrl } = require("../../utilities")
exports.fetchUrls = async ctx => { exports.fetchUrls = async ctx => {

View File

@ -1,10 +1,10 @@
const { getBuiltinPermissions } = require("@budibase/auth/permissions") const { getBuiltinPermissions } = require("@budibase/backend-core/permissions")
const { const {
isBuiltin, isBuiltin,
getDBRoleID, getDBRoleID,
getExternalRoleID, getExternalRoleID,
getBuiltinRoles, getBuiltinRoles,
} = require("@budibase/auth/roles") } = require("@budibase/backend-core/roles")
const { getRoleParams } = require("../../db/utils") const { getRoleParams } = require("../../db/utils")
const CouchDB = require("../../db") const CouchDB = require("../../db")
const { const {

View File

@ -4,7 +4,7 @@ const {
getRole, getRole,
isBuiltin, isBuiltin,
getAllRoles, getAllRoles,
} = require("@budibase/auth/roles") } = require("@budibase/backend-core/roles")
const { const {
generateRoleID, generateRoleID,
getUserMetadataParams, getUserMetadataParams,

View File

@ -2,7 +2,7 @@ const { getRoutingInfo } = require("../../utilities/routing")
const { const {
getUserRoleHierarchy, getUserRoleHierarchy,
BUILTIN_ROLE_IDS, BUILTIN_ROLE_IDS,
} = require("@budibase/auth/roles") } = require("@budibase/backend-core/roles")
const URL_SEPARATOR = "/" const URL_SEPARATOR = "/"

View File

@ -1,6 +1,6 @@
const { SearchIndexes } = require("../../../db/utils") const { SearchIndexes } = require("../../../db/utils")
const fetch = require("node-fetch") const fetch = require("node-fetch")
const { getCouchUrl } = require("@budibase/auth/db") const { getCouchUrl } = require("@budibase/backend-core/db")
/** /**
* Class to build lucene query URLs. * Class to build lucene query URLs.

View File

@ -1,6 +1,6 @@
const CouchDB = require("../../db") const CouchDB = require("../../db")
const { getScreenParams, generateScreenID } = require("../../db/utils") const { getScreenParams, generateScreenID } = require("../../db/utils")
const { AccessController } = require("@budibase/auth/roles") const { AccessController } = require("@budibase/backend-core/roles")
exports.fetch = async ctx => { exports.fetch = async ctx => {
const appId = ctx.appId const appId = ctx.appId

View File

@ -8,10 +8,13 @@ const { InternalTables } = require("../../db/utils")
const { getGlobalUsers, getRawGlobalUser } = require("../../utilities/global") const { getGlobalUsers, getRawGlobalUser } = require("../../utilities/global")
const { getFullUser } = require("../../utilities/users") const { getFullUser } = require("../../utilities/users")
const { isEqual } = require("lodash") const { isEqual } = require("lodash")
const { BUILTIN_ROLE_IDS } = require("@budibase/auth/roles") const { BUILTIN_ROLE_IDS } = require("@budibase/backend-core/roles")
const { getDevelopmentAppID, getDeployedAppIDs } = require("@budibase/auth/db") const {
getDevelopmentAppID,
getDeployedAppIDs,
} = require("@budibase/backend-core/db")
const { doesDatabaseExist } = require("../../utilities") const { doesDatabaseExist } = require("../../utilities")
const { UserStatus } = require("@budibase/auth/constants") const { UserStatus } = require("@budibase/backend-core/constants")
async function rawMetadata(db) { async function rawMetadata(db) {
return ( return (

View File

@ -3,7 +3,7 @@ const { generateWebhookID, getWebhookParams } = require("../../db/utils")
const toJsonSchema = require("to-json-schema") const toJsonSchema = require("to-json-schema")
const validate = require("jsonschema").validate const validate = require("jsonschema").validate
const triggers = require("../../automations/triggers") const triggers = require("../../automations/triggers")
const { getDeployedAppID } = require("@budibase/auth/db") const { getDeployedAppID } = require("@budibase/backend-core/db")
const AUTOMATION_DESCRIPTION = "Generated from Webhook Schema" const AUTOMATION_DESCRIPTION = "Generated from Webhook Schema"

View File

@ -4,7 +4,7 @@ const {
auditLog, auditLog,
buildTenancyMiddleware, buildTenancyMiddleware,
buildAppTenancyMiddleware, buildAppTenancyMiddleware,
} = require("@budibase/auth").auth } = require("@budibase/backend-core").auth
const currentApp = require("../middleware/currentapp") const currentApp = require("../middleware/currentapp")
const compress = require("koa-compress") const compress = require("koa-compress")
const zlib = require("zlib") const zlib = require("zlib")

View File

@ -1,7 +1,7 @@
const Router = require("@koa/router") const Router = require("@koa/router")
const controller = require("../controllers/apikeys") const controller = require("../controllers/apikeys")
const authorized = require("../../middleware/authorized") const authorized = require("../../middleware/authorized")
const { BUILDER } = require("@budibase/auth/permissions") const { BUILDER } = require("@budibase/backend-core/permissions")
const router = Router() const router = Router()

View File

@ -1,7 +1,7 @@
const Router = require("@koa/router") const Router = require("@koa/router")
const controller = require("../controllers/application") const controller = require("../controllers/application")
const authorized = require("../../middleware/authorized") const authorized = require("../../middleware/authorized")
const { BUILDER } = require("@budibase/auth/permissions") const { BUILDER } = require("@budibase/backend-core/permissions")
const usage = require("../../middleware/usageQuota") const usage = require("../../middleware/usageQuota")
const router = Router() const router = Router()

View File

@ -6,7 +6,7 @@ const {
BUILDER, BUILDER,
PermissionLevels, PermissionLevels,
PermissionTypes, PermissionTypes,
} = require("@budibase/auth/permissions") } = require("@budibase/backend-core/permissions")
const Joi = require("joi") const Joi = require("joi")
const { bodyResource, paramResource } = require("../../middleware/resourceId") const { bodyResource, paramResource } = require("../../middleware/resourceId")
const { const {

View File

@ -1,7 +1,7 @@
const Router = require("@koa/router") const Router = require("@koa/router")
const controller = require("../controllers/backup") const controller = require("../controllers/backup")
const authorized = require("../../middleware/authorized") const authorized = require("../../middleware/authorized")
const { BUILDER } = require("@budibase/auth/permissions") const { BUILDER } = require("@budibase/backend-core/permissions")
const router = Router() const router = Router()

View File

@ -1,7 +1,7 @@
const Router = require("@koa/router") const Router = require("@koa/router")
const controller = require("../controllers/cloud") const controller = require("../controllers/cloud")
const authorized = require("../../middleware/authorized") const authorized = require("../../middleware/authorized")
const { BUILDER } = require("@budibase/auth/permissions") const { BUILDER } = require("@budibase/backend-core/permissions")
const router = Router() const router = Router()

View File

@ -1,7 +1,7 @@
const Router = require("@koa/router") const Router = require("@koa/router")
const controller = require("../controllers/component") const controller = require("../controllers/component")
const authorized = require("../../middleware/authorized") const authorized = require("../../middleware/authorized")
const { BUILDER } = require("@budibase/auth/permissions") const { BUILDER } = require("@budibase/backend-core/permissions")
const router = Router() const router = Router()

View File

@ -6,7 +6,7 @@ const {
BUILDER, BUILDER,
PermissionLevels, PermissionLevels,
PermissionTypes, PermissionTypes,
} = require("@budibase/auth/permissions") } = require("@budibase/backend-core/permissions")
const Joi = require("joi") const Joi = require("joi")
const { DataSourceOperation } = require("../../constants") const { DataSourceOperation } = require("../../constants")

View File

@ -1,7 +1,7 @@
const Router = require("@koa/router") const Router = require("@koa/router")
const controller = require("../controllers/deploy") const controller = require("../controllers/deploy")
const authorized = require("../../middleware/authorized") const authorized = require("../../middleware/authorized")
const { BUILDER } = require("@budibase/auth/permissions") const { BUILDER } = require("@budibase/backend-core/permissions")
const router = Router() const router = Router()

View File

@ -2,7 +2,7 @@ const Router = require("@koa/router")
const controller = require("../controllers/dev") const controller = require("../controllers/dev")
const env = require("../../environment") const env = require("../../environment")
const authorized = require("../../middleware/authorized") const authorized = require("../../middleware/authorized")
const { BUILDER } = require("@budibase/auth/permissions") const { BUILDER } = require("@budibase/backend-core/permissions")
const router = Router() const router = Router()

View File

@ -1,7 +1,7 @@
const Router = require("@koa/router") const Router = require("@koa/router")
const controller = require("../controllers/hosting") const controller = require("../controllers/hosting")
const authorized = require("../../middleware/authorized") const authorized = require("../../middleware/authorized")
const { BUILDER } = require("@budibase/auth/permissions") const { BUILDER } = require("@budibase/backend-core/permissions")
const router = Router() const router = Router()

View File

@ -1,7 +1,7 @@
const Router = require("@koa/router") const Router = require("@koa/router")
const controller = require("../controllers/integration") const controller = require("../controllers/integration")
const authorized = require("../../middleware/authorized") const authorized = require("../../middleware/authorized")
const { BUILDER } = require("@budibase/auth/permissions") const { BUILDER } = require("@budibase/backend-core/permissions")
const router = Router() const router = Router()

View File

@ -1,6 +1,6 @@
const Router = require("@koa/router") const Router = require("@koa/router")
const authorized = require("../../middleware/authorized") const authorized = require("../../middleware/authorized")
const { BUILDER } = require("@budibase/auth/permissions") const { BUILDER } = require("@budibase/backend-core/permissions")
const controller = require("../controllers/layout") const controller = require("../controllers/layout")
const router = Router() const router = Router()

View File

@ -5,7 +5,7 @@ const {
AppType, AppType,
} = require("../../middleware/appInfo") } = require("../../middleware/appInfo")
const authorized = require("../../middleware/authorized") const authorized = require("../../middleware/authorized")
const { BUILDER } = require("@budibase/auth/permissions") const { BUILDER } = require("@budibase/backend-core/permissions")
const router = Router() const router = Router()

View File

@ -1,7 +1,10 @@
const Router = require("@koa/router") const Router = require("@koa/router")
const controller = require("../controllers/permission") const controller = require("../controllers/permission")
const authorized = require("../../middleware/authorized") const authorized = require("../../middleware/authorized")
const { BUILDER, PermissionLevels } = require("@budibase/auth/permissions") const {
BUILDER,
PermissionLevels,
} = require("@budibase/backend-core/permissions")
const Joi = require("joi") const Joi = require("joi")
const joiValidator = require("../../middleware/joi-validator") const joiValidator = require("../../middleware/joi-validator")

View File

@ -5,7 +5,7 @@ const {
PermissionLevels, PermissionLevels,
PermissionTypes, PermissionTypes,
BUILDER, BUILDER,
} = require("@budibase/auth/permissions") } = require("@budibase/backend-core/permissions")
const { const {
bodyResource, bodyResource,
bodySubResource, bodySubResource,

View File

@ -7,7 +7,7 @@ const {
BUILTIN_PERMISSION_IDS, BUILTIN_PERMISSION_IDS,
BUILDER, BUILDER,
PermissionLevels, PermissionLevels,
} = require("@budibase/auth/permissions") } = require("@budibase/backend-core/permissions")
const router = Router() const router = Router()

View File

@ -1,6 +1,6 @@
const Router = require("@koa/router") const Router = require("@koa/router")
const authorized = require("../../middleware/authorized") const authorized = require("../../middleware/authorized")
const { BUILDER } = require("@budibase/auth/permissions") const { BUILDER } = require("@budibase/backend-core/permissions")
const controller = require("../controllers/routing") const controller = require("../controllers/routing")
const router = Router() const router = Router()

View File

@ -9,7 +9,7 @@ const {
const { const {
PermissionLevels, PermissionLevels,
PermissionTypes, PermissionTypes,
} = require("@budibase/auth/permissions") } = require("@budibase/backend-core/permissions")
const router = Router() const router = Router()

Some files were not shown because too many files have changed in this diff Show More