diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index adfbc29008..d1e373003a 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -179,36 +179,7 @@ To enable this mode, use: yarn mode:account ``` ### CI - -#### PR Job - -After your pr is submitted a github action (can be found at `.github/workflows/budibase_ci.yml`) will run to perform some checks against the changes such as linting, build and test. - -The job will run when changes are pushed to or targetted at `master` and `develop` -#### Release Develop - -To test changes before a release, a prerelease action (can be found at `.github/workflows/release-develop.yml`) will run to build and release develop versions of npm packages and docker images. On each subsequent commit to develop a new alpha version of npm packages will be created and released. - -For example: - -- `feature1` -> `develop` = `v0.9.160-alpha.1` -- `feature2` -> `develop` = `v0.9.160-alpha.0` - -The job will run when changes are pushed to `develop` -#### Release Job - -To release changes a release job (can be found at `.github/workflows/release.yml`) will run to create final versions of npm packages and docker images. - -Following the example above: - -- `develop` -> `master` = `v0.9.160` - -The job will run when changes are pushed to `master` - -#### Release Self Host Job - -To release the self hosted version of docker images, an additional job (can be found at `.github/workflows/release-selfhost.yml`) must be ran manually. This will releaae docker images to docker hub under the tag `latest` to be picked up by self hosted installations. - + An overview of the CI pipelines can be found [here](./workflows/README.md) ### Troubleshooting Sometimes, things go wrong. This can be due to incompatible updates on the budibase platform. To clear down your development environment and start again follow **Step 6. Cleanup**, then proceed from **Step 3. Install and Build** in the setup guide above. You should have a fresh Budibase installation. diff --git a/.github/stale.yml b/.github/stale.yml index 3112dfa8e7..5875ed1282 100644 --- a/.github/stale.yml +++ b/.github/stale.yml @@ -1,7 +1,9 @@ -# Number of days of inactivity before an issue becomes stale +# Configuration for probot-stale - https://github.com/probot/stale +# Number of days of inactivity before an Issue or Pull Request becomes stale daysUntilStale: 60 -# Number of days of inactivity before a stale issue is closed -daysUntilClose: 7 +# Number of days of inactivity before an Issue or Pull Request with the stale label is closed. +# Set to false to disable. If disabled, issues still need to be closed manually, but will remain marked as stale. +daysUntilClose: false # Issues with these labels will never be considered stale exemptLabels: - pinned diff --git a/.github/README.md b/.github/workflows/README.md similarity index 100% rename from .github/README.md rename to .github/workflows/README.md diff --git a/.github/workflows/deploy-cloud.yaml b/.github/workflows/deploy-cloud.yaml index 26422a2e7b..d54e6c9c68 100644 --- a/.github/workflows/deploy-cloud.yaml +++ b/.github/workflows/deploy-cloud.yaml @@ -12,6 +12,12 @@ jobs: runs-on: ubuntu-latest steps: + - name: Fail if branch is not master + if: github.ref != 'refs/heads/master' + run: | + echo "Ref is not master, you must run this job from master." + exit 1 + - uses: actions/checkout@v2 - name: Pull values.yaml from budibase-infra diff --git a/.github/workflows/release-develop.yml b/.github/workflows/release-develop.yml index b0f052f68f..4467cd6c81 100644 --- a/.github/workflows/release-develop.yml +++ b/.github/workflows/release-develop.yml @@ -4,6 +4,16 @@ on: push: branches: - develop + paths: + - '.aws/**' + - '.github/**' + - 'charts/**' + - 'packages/**' + - 'scripts/**' + - 'package.json' + - 'yarn.lock' + - 'package.json' + - 'yarn.lock' env: POSTHOG_TOKEN: ${{ secrets.POSTHOG_TOKEN }} diff --git a/.github/workflows/release-selfhost.yml b/.github/workflows/release-selfhost.yml index 5223fc6864..e842da9d7c 100644 --- a/.github/workflows/release-selfhost.yml +++ b/.github/workflows/release-selfhost.yml @@ -10,6 +10,7 @@ jobs: steps: - uses: actions/checkout@v2 with: + node-version: 14.x fetch_depth: 0 - name: Tag and release Docker images (Self Host) @@ -37,6 +38,13 @@ jobs: DOCKER_PASSWORD: ${{ secrets.DOCKER_API_KEY }} SELFHOST_TAG: latest + - name: Build CLI executables + run: | + pushd packages/cli + yarn + yarn build + popd + - name: Setup Helm uses: azure/setup-helm@v1 id: helm-install @@ -61,4 +69,8 @@ jobs: with: name: v${{ env.RELEASE_VERSION }} tag_name: v${{ env.RELEASE_VERSION }} - generate_release_notes: true \ No newline at end of file + generate_release_notes: true + files: | + packages/cli/build/cli-win.exe + packages/cli/build/cli-linux + packages/cli/build/cli-macos \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 71432c2403..82848c78e4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,6 +4,16 @@ on: push: branches: - master + paths: + - '.aws/**' + - '.github/**' + - 'charts/**' + - 'packages/**' + - 'scripts/**' + - 'package.json' + - 'yarn.lock' + - 'package.json' + - 'yarn.lock' env: POSTHOG_TOKEN: ${{ secrets.POSTHOG_TOKEN }} diff --git a/.gitignore b/.gitignore index 086813c97e..6ba2f61ed7 100644 --- a/.gitignore +++ b/.gitignore @@ -93,3 +93,5 @@ hosting/.generated-envoy.dev.yaml # Sublime text *.sublime-project *.sublime-workspace + +bin/ diff --git a/charts/budibase/templates/proxy-service-service.yaml b/charts/budibase/templates/proxy-service-service.yaml index 8f14d97862..bf2b199ee5 100644 --- a/charts/budibase/templates/proxy-service-service.yaml +++ b/charts/budibase/templates/proxy-service-service.yaml @@ -9,12 +9,11 @@ metadata: app.kubernetes.io/name: budibase-proxy name: proxy-service spec: - type: NodePort ports: - - port: {{ .Values.services.proxy.port }} + - name: {{ .Values.services.proxy.port | quote }} + port: {{ .Values.services.proxy.port }} targetPort: {{ .Values.services.proxy.port }} - protocol: TCP selector: app.kubernetes.io/name: budibase-proxy status: - loadBalancer: {} + loadBalancer: {} \ No newline at end of file diff --git a/i18n/README.fr.md b/i18n/README.fr.md new file mode 100644 index 0000000000..12abd4d073 --- /dev/null +++ b/i18n/README.fr.md @@ -0,0 +1,214 @@ +

+ + Budibase + +

+

+ Budibase +

+ +

+ La plateform low-code que vous aimerez utiliser +

+

+ Budibase est une plateforme low-code open source et c'est la façon la plus facile de créer des outils internes qui améliore la productivité. +

+ +

+ 🤖 🎨 🚀 +

+
+ +

+ Budibase design ui +

+ +

+ + GitHub toutes les releases + + + GitHub release (par ordre chronologique) + + + Suivre @budibase + + Code de conduite + + + +

+ +

+ Commencer + · + Documentation + · + Demandes d'amélioration + · + Signaler un bug + · + Support: Discussions +

+ +

+## ✨ Fontionnalités + +### Construire et déployer un vrai logiciel +Contrairement à d'autres plateformes, avec Budibase vous construisez et déployez des applications one-page. Les applications Budibase sont très perfomantes et peuvent être designées de manière responsive, offrant ainsi à vos utilisateurs une expérience exceptionnelle. +

+ +### Source libre et extensible +Budibase est un logiciel libre - sous licence GPL v3. Cela devrait vous rassurer sur le fait que Budibase sera toujours là. Vous pouvez également coder dans Budibase ou le forker et apporter des modifications à votre guise, ce qui en fera une expérience conviviale pour les développeurs. +

+ +### Importer les données ou partir de zéro +Budibase peut tirer ses données de plusieurs sources, dont MongoDB, CouchDB, PostgreSQL, MySQL, Airtable, S3, DynamoDB ou une API REST. Et contrairement à d'autres plateformes, avec Budibase, vous pouvez partir de zéro et créer des applications métier sans aucune source de données. [Demander une nouvelle source de données](https://github.com/Budibase/budibase/discussions?discussions_q=category%3AIdeas). + +

+ Budibase data +

+

+ +### Concevoir et créer des applications à l'aide de composants prédéfinis. + +Budibase est livré avec des composants joliment conçus et puissants que vous pouvez utiliser comme des blocs de construction pour bâtir votre interface utilisateur. Nous exposons également un grand nombre de vos options de style CSS préférées afin que vous puissiez faire preuve d'une créativité accrue. [Demander un nouveau composant](https://github.com/Budibase/budibase/discussions?discussions_q=category%3AIdeas). + +

+ Budibase design +

+

+ +### Automatiser les processus, intégrer d'autres outils et se connecter à des webhooks +Gagnez du temps en automatisant les processus manuels et les flux de travail. Qu'il s'agisse de se connecter à des webhooks ou d'automatiser des e-mails, il suffit de dire à Budibase ce qu'il doit faire et de le laisser travailler pour vous. Vous pouvez aisément [créer une nouvelle automatisation pour Budibase ici](https://github.com/Budibase/automations) ou [Demander une nouvelle automatisation](https://github.com/Budibase/budibase/discussions?discussions_q=category%3AIdeas). + +

+ Budibase automations +

+

+ +### Intégration avec vos outils préférés +Budibase s'intègre à un certain nombre d'outils populaires, ce qui vous permet de créer des applications qui s'adaptent parfaitement à votre pile technologique. + +

+ Budibase integrations +

+

+ +### Paradis des admins +Budibase est conçu pour évoluer. Avec Budibase, vous pouvez vous auto-héberger sur votre propre infrastructure et gérer globalement les utilisateurs, l'accueil, le SMTP, les applications, les groupes, l'apparence et plus encore. Vous pouvez également fournir aux utilisateurs/groupes un portail d'applications et confier la gestion des utilisateurs au responsable du groupe. + +- Regardez la vidéo de promotion: https://youtu.be/xoljVpty_Kw + +


+ +## 🏁 Commencer + + + +Déployez Budibase en auto-hébergement dans votre infrastructure existante, en utilisant Docker, Kubernetes et Digital Ocean. +Ou utilisez Budibase Cloud si vous n'avez pas besoin de vous auto-héberger, et que vous souhaitez démarrer rapidement. + +### [Commencer avec Budibase](https://budibase.com) + + +

+ +## 🎓 Apprendre Budibase + +La documentation Budibase [est ic](https://docs.budibase.com). +
+ + +

+ +## 💬 Communauté + +Si vous avez une question ou si vous souhaitez discuter avec d'autres utilisateurs de Budibase et rejoindre notre communauté, veuillez vous rendre à l'adresse suivante : [Discussions Github](https://github.com/Budibase/budibase/discussions) + +


+ + +## ❗ Code de conduite + +Budibase s'engage à offrir à chacun une expérience accueillante, diversifiée et exempte de harcèlement. Nous attendons de tous les membres de la communauté Budibase qu'ils se conforment aux principes de notre [**Code de conduite**](https://github.com/Budibase/budibase/blob/HEAD/.github/CODE_OF_CONDUCT.md). Merci de le lire. +
+ + +

+ + +## 🙌 Contribuer à Budibase + +Qu'il s'agisse d'ouvrir un rapport de bug ou de créer une Pull request, toute contribution est appréciée et bienvenue. Si vous envisagez de mettre en œuvre une nouvelle fonctionnalité ou de modifier l'API, veuillez d'abord créer un Issue. Nous pourrons ainsi nous assurer que votre travail n'est pas vain. + +### Vous ne savez pas par où commencer ? +Un bon endroit pour commencer à contribuer, c'est ici : [Projets en cours](https://github.com/Budibase/budibase/projects/22). + +### Comment le repo est-il organisé ? +Budibase est une monorepo gérée par lerna. Lerna gère la construction et la publication des paquets de Budibase. Voici, à un haut niveau, les paquets qui composent Budibase. + +- [packages/builder](https://github.com/Budibase/budibase/tree/HEAD/packages/builder) - contient le code pour l'application svelte côté client du budibase builder. + +- [packages/client](https://github.com/Budibase/budibase/tree/HEAD/packages/client) - Un module qui s'exécute dans le navigateur et qui est chargé de lire les définitions JSON et de créer des applications web vivantes à partir de celles-ci.. + +- [packages/server](https://github.com/Budibase/budibase/tree/HEAD/packages/server) - Le serveur budibase. Cette application Koa est responsable de servir le JS pour les applications builder et budibase, ainsi que de fournir l'API pour l'interaction avec la base de données et le système de fichiers. + +Pour plus d'informations, voir [CONTRIBUTING.md](https://github.com/Budibase/budibase/blob/HEAD/.github/CONTRIBUTING.md) + +

+ + +## 📝 Licence + +Budibase est open source, sous licence de [GPL v3](https://www.gnu.org/licenses/gpl-3.0.en.html). Les bibliothèques du client et des composants sont sous licence [MPL](https://directory.fsf.org/wiki/License:MPL-2.0) - afin que les applications que vous créez puissent être utilisées sous licence comme vous le souhaitez. + +

+ +## ⭐ Stargazers dans le temps + +[![Stargazers dans le temps](https://starchart.cc/Budibase/budibase.svg)](https://starchart.cc/Budibase/budibase) + +Si vous rencontrez des problèmes entre les mises à jour du builder, veuillez utiliser le guide suivant [ici](https://github.com/Budibase/budibase/blob/HEAD/.github/CONTRIBUTING.md#troubleshooting) pour nettoyer votre environnement. + +

+ +## Contributeurs ✨ + +Merci à ces personnes merveilleuses ([emoji key](https://allcontributors.org/docs/en/emoji-key)): + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Martin McKeaveney

💻 📖 ⚠️ 🚇

Michael Drury

📖 💻 ⚠️ 🚇

Andrew Kingston

📖 💻 ⚠️ 🎨

Michael Shanks

📖 💻 ⚠️

Kevin Åberg Kultalahti

📖 💻 ⚠️

Joe

📖 💻 🖋 🎨

Rory Powell

💻 📖 ⚠️

Peter Clement

💻 📖 ⚠️

Conor_Mack

💻 ⚠️

pngwn

💻 ⚠️

HugoLd

💻

victoriasloan

💻

yashank09

💻

SOVLOOKUP

💻

seoulaja

🌍

Maurits Lourens

⚠️ 💻

Rory Powell

🚇 ⚠️ 💻
+ + + + + + +Ce projet suit la spécification [all-contributors](https://allcontributors.org/docs/fr/overview). Les contributions de toute nature sont les bienvenues ! diff --git a/lerna.json b/lerna.json index c937239de0..9c19e33343 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "1.0.30", + "version": "1.0.41", "npmClient": "yarn", "packages": [ "packages/*" diff --git a/packages/auth/.gitignore b/packages/backend-core/.gitignore similarity index 100% rename from packages/auth/.gitignore rename to packages/backend-core/.gitignore diff --git a/packages/auth/LICENSE b/packages/backend-core/LICENSE similarity index 100% rename from packages/auth/LICENSE rename to packages/backend-core/LICENSE diff --git a/packages/auth/README.md b/packages/backend-core/README.md similarity index 78% rename from packages/auth/README.md rename to packages/backend-core/README.md index 4c6a474b5b..f36f80f84d 100644 --- a/packages/auth/README.md +++ b/packages/backend-core/README.md @@ -4,7 +4,7 @@ This library contains core functionality, like auth and security features which are shared between backend services. #### 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. For these files they should be limited to a single `require` of the file that should diff --git a/packages/auth/accounts.js b/packages/backend-core/accounts.js similarity index 100% rename from packages/auth/accounts.js rename to packages/backend-core/accounts.js diff --git a/packages/backend-core/auth.js b/packages/backend-core/auth.js new file mode 100644 index 0000000000..bbfe3d41dd --- /dev/null +++ b/packages/backend-core/auth.js @@ -0,0 +1 @@ +module.exports = require("./src/auth") diff --git a/packages/auth/cache.js b/packages/backend-core/cache.js similarity index 100% rename from packages/auth/cache.js rename to packages/backend-core/cache.js diff --git a/packages/auth/constants.js b/packages/backend-core/constants.js similarity index 100% rename from packages/auth/constants.js rename to packages/backend-core/constants.js diff --git a/packages/auth/db.js b/packages/backend-core/db.js similarity index 100% rename from packages/auth/db.js rename to packages/backend-core/db.js diff --git a/packages/auth/deprovision.js b/packages/backend-core/deprovision.js similarity index 100% rename from packages/auth/deprovision.js rename to packages/backend-core/deprovision.js diff --git a/packages/backend-core/middleware.js b/packages/backend-core/middleware.js new file mode 100644 index 0000000000..30fec96239 --- /dev/null +++ b/packages/backend-core/middleware.js @@ -0,0 +1 @@ +module.exports = require("./src/middleware") diff --git a/packages/backend-core/objectStore.js b/packages/backend-core/objectStore.js new file mode 100644 index 0000000000..3ee433f224 --- /dev/null +++ b/packages/backend-core/objectStore.js @@ -0,0 +1,4 @@ +module.exports = { + ...require("./src/objectStore"), + ...require("./src/objectStore/utils"), +} diff --git a/packages/auth/package.json b/packages/backend-core/package.json similarity index 88% rename from packages/auth/package.json rename to packages/backend-core/package.json index 688a839555..03b215be56 100644 --- a/packages/auth/package.json +++ b/packages/backend-core/package.json @@ -1,7 +1,7 @@ { - "name": "@budibase/auth", - "version": "1.0.30", - "description": "Authentication middlewares for budibase builder and apps", + "name": "@budibase/backend-core", + "version": "1.0.41", + "description": "Budibase backend core libraries used in server and worker", "main": "src/index.js", "author": "Budibase", "license": "GPL-3.0", diff --git a/packages/auth/permissions.js b/packages/backend-core/permissions.js similarity index 100% rename from packages/auth/permissions.js rename to packages/backend-core/permissions.js diff --git a/packages/auth/redis.js b/packages/backend-core/redis.js similarity index 100% rename from packages/auth/redis.js rename to packages/backend-core/redis.js diff --git a/packages/auth/roles.js b/packages/backend-core/roles.js similarity index 100% rename from packages/auth/roles.js rename to packages/backend-core/roles.js diff --git a/packages/auth/scripts/jestSetup.js b/packages/backend-core/scripts/jestSetup.js similarity index 100% rename from packages/auth/scripts/jestSetup.js rename to packages/backend-core/scripts/jestSetup.js diff --git a/packages/auth/sessions.js b/packages/backend-core/sessions.js similarity index 100% rename from packages/auth/sessions.js rename to packages/backend-core/sessions.js diff --git a/packages/auth/src/index.js b/packages/backend-core/src/auth.js similarity index 52% rename from packages/auth/src/index.js rename to packages/backend-core/src/auth.js index 4aa2c8ab96..7f66d887ae 100644 --- a/packages/auth/src/index.js +++ b/packages/backend-core/src/auth.js @@ -1,7 +1,6 @@ const passport = require("koa-passport") const LocalStrategy = require("passport-local").Strategy const JwtStrategy = require("passport-jwt").Strategy -const { StaticDatabases } = require("./db/utils") const { getGlobalDB } = require("./tenancy") const { jwt, @@ -14,8 +13,6 @@ const { appTenancy, authError, } = require("./middleware") -const { setDB } = require("./db") -const userCache = require("./cache/user") // Strategies passport.use(new LocalStrategy(local.options, local.authenticate)) @@ -36,36 +33,13 @@ passport.deserializeUser(async (user, done) => { }) module.exports = { - init(pouch) { - setDB(pouch) - }, - db: require("./db/utils"), - redis: { - Client: require("./redis"), - utils: require("./redis/utils"), - }, - objectStore: { - ...require("./objectStore"), - ...require("./objectStore/utils"), - }, - utils: { - ...require("./utils"), - ...require("./hashing"), - }, - auth: { - buildAuthMiddleware: authenticated, - passport, - google, - oidc, - jwt: require("jsonwebtoken"), - buildTenancyMiddleware: tenancy, - buildAppTenancyMiddleware: appTenancy, - auditLog, - authError, - }, - cache: { - user: userCache, - }, - StaticDatabases, - constants: require("./constants"), + buildAuthMiddleware: authenticated, + passport, + google, + oidc, + jwt: require("jsonwebtoken"), + buildTenancyMiddleware: tenancy, + buildAppTenancyMiddleware: appTenancy, + auditLog, + authError, } diff --git a/packages/auth/src/cache/appMetadata.js b/packages/backend-core/src/cache/appMetadata.js similarity index 100% rename from packages/auth/src/cache/appMetadata.js rename to packages/backend-core/src/cache/appMetadata.js diff --git a/packages/auth/src/cache/user.js b/packages/backend-core/src/cache/user.js similarity index 100% rename from packages/auth/src/cache/user.js rename to packages/backend-core/src/cache/user.js diff --git a/packages/auth/src/cloud/accounts.js b/packages/backend-core/src/cloud/accounts.js similarity index 100% rename from packages/auth/src/cloud/accounts.js rename to packages/backend-core/src/cloud/accounts.js diff --git a/packages/auth/src/cloud/api.js b/packages/backend-core/src/cloud/api.js similarity index 100% rename from packages/auth/src/cloud/api.js rename to packages/backend-core/src/cloud/api.js diff --git a/packages/auth/src/constants.js b/packages/backend-core/src/constants.js similarity index 96% rename from packages/auth/src/constants.js rename to packages/backend-core/src/constants.js index 363274eda5..28b9ced49b 100644 --- a/packages/auth/src/constants.js +++ b/packages/backend-core/src/constants.js @@ -16,6 +16,7 @@ exports.Headers = { APP_ID: "x-budibase-app-id", TYPE: "x-budibase-type", TENANT_ID: "x-budibase-tenant-id", + TOKEN: "x-budibase-token", } exports.GlobalRoles = { diff --git a/packages/auth/src/db/Replication.js b/packages/backend-core/src/db/Replication.js similarity index 100% rename from packages/auth/src/db/Replication.js rename to packages/backend-core/src/db/Replication.js diff --git a/packages/auth/src/db/constants.js b/packages/backend-core/src/db/constants.js similarity index 100% rename from packages/auth/src/db/constants.js rename to packages/backend-core/src/db/constants.js diff --git a/packages/auth/src/db/index.js b/packages/backend-core/src/db/index.js similarity index 100% rename from packages/auth/src/db/index.js rename to packages/backend-core/src/db/index.js diff --git a/packages/auth/src/db/utils.js b/packages/backend-core/src/db/utils.js similarity index 97% rename from packages/auth/src/db/utils.js rename to packages/backend-core/src/db/utils.js index 2bad09c306..5830de4721 100644 --- a/packages/auth/src/db/utils.js +++ b/packages/backend-core/src/db/utils.js @@ -224,8 +224,15 @@ exports.getAllDbs = async () => { } } let couchUrl = `${exports.getCouchUrl()}/_all_dbs` - if (env.MULTI_TENANCY) { - let tenantId = getTenantId() + let tenantId = getTenantId() + if (!env.MULTI_TENANCY || tenantId == DEFAULT_TENANT_ID) { + // just get all DBs when: + // - single tenancy + // - default tenant + // - apps dbs don't contain tenant id + // - non-default tenant dbs are filtered out application side in getAllApps + await addDbs(couchUrl) + } else { // get prod apps await addDbs( exports.getStartEndKeyURL(couchUrl, DocumentTypes.APP, tenantId) @@ -236,9 +243,6 @@ exports.getAllDbs = async () => { ) // add global db name dbs.push(getGlobalDBName(tenantId)) - } else { - // just get all DBs in self host - await addDbs(couchUrl) } return dbs } diff --git a/packages/auth/src/db/views.js b/packages/backend-core/src/db/views.js similarity index 100% rename from packages/auth/src/db/views.js rename to packages/backend-core/src/db/views.js diff --git a/packages/auth/src/environment.js b/packages/backend-core/src/environment.js similarity index 88% rename from packages/auth/src/environment.js rename to packages/backend-core/src/environment.js index c26ad1c199..3db59ab321 100644 --- a/packages/auth/src/environment.js +++ b/packages/backend-core/src/environment.js @@ -6,6 +6,13 @@ function isTest() { ) } +function isDev() { + return ( + process.env.NODE_ENV !== "production" && + process.env.BUDIBASE_ENVIRONMENT !== "production" + ) +} + module.exports = { JWT_SECRET: process.env.JWT_SECRET, COUCH_DB_URL: process.env.COUCH_DB_URL, @@ -27,6 +34,7 @@ module.exports = { COOKIE_DOMAIN: process.env.COOKIE_DOMAIN, PLATFORM_URL: process.env.PLATFORM_URL, isTest, + isDev, _set(key, value) { process.env[key] = value module.exports[key] = value diff --git a/packages/auth/src/hashing.js b/packages/backend-core/src/hashing.js similarity index 100% rename from packages/auth/src/hashing.js rename to packages/backend-core/src/hashing.js diff --git a/packages/auth/src/helpers.js b/packages/backend-core/src/helpers.js similarity index 100% rename from packages/auth/src/helpers.js rename to packages/backend-core/src/helpers.js diff --git a/packages/backend-core/src/index.js b/packages/backend-core/src/index.js new file mode 100644 index 0000000000..cd3a3f5c97 --- /dev/null +++ b/packages/backend-core/src/index.js @@ -0,0 +1,17 @@ +const { setDB } = require("./db") + +module.exports = { + init(pouch) { + setDB(pouch) + }, + // some default exports from the library, however these ideally shouldn't + // be used, instead the syntax require("@budibase/backend-core/db") should be used + StaticDatabases: require("./db/utils").StaticDatabases, + db: require("../db"), + redis: require("../redis"), + objectStore: require("../objectStore"), + utils: require("../utils"), + cache: require("../cache"), + auth: require("../auth"), + constants: require("../constants"), +} diff --git a/packages/auth/src/middleware/appTenancy.js b/packages/backend-core/src/middleware/appTenancy.js similarity index 100% rename from packages/auth/src/middleware/appTenancy.js rename to packages/backend-core/src/middleware/appTenancy.js diff --git a/packages/auth/src/middleware/auditLog.js b/packages/backend-core/src/middleware/auditLog.js similarity index 100% rename from packages/auth/src/middleware/auditLog.js rename to packages/backend-core/src/middleware/auditLog.js diff --git a/packages/auth/src/middleware/authenticated.js b/packages/backend-core/src/middleware/authenticated.js similarity index 92% rename from packages/auth/src/middleware/authenticated.js rename to packages/backend-core/src/middleware/authenticated.js index f0fb6e21c5..87bd4d35ce 100644 --- a/packages/auth/src/middleware/authenticated.js +++ b/packages/backend-core/src/middleware/authenticated.js @@ -1,5 +1,5 @@ const { Cookies, Headers } = require("../constants") -const { getCookie, clearCookie } = require("../utils") +const { getCookie, clearCookie, openJwt } = require("../utils") const { getUser } = require("../cache/user") const { getSession, updateSessionTTL } = require("../security/sessions") const { buildMatcherRegex, matches } = require("./matchers") @@ -35,8 +35,9 @@ module.exports = ( publicEndpoint = true } try { - // check the actual user is authenticated first - const authCookie = getCookie(ctx, Cookies.Auth) + // check the actual user is authenticated first, try header or cookie + const headerToken = ctx.request.headers[Headers.TOKEN] + const authCookie = getCookie(ctx, Cookies.Auth) || openJwt(headerToken) let authenticated = false, user = null, internal = false diff --git a/packages/auth/src/middleware/index.js b/packages/backend-core/src/middleware/index.js similarity index 100% rename from packages/auth/src/middleware/index.js rename to packages/backend-core/src/middleware/index.js diff --git a/packages/auth/src/middleware/matchers.js b/packages/backend-core/src/middleware/matchers.js similarity index 100% rename from packages/auth/src/middleware/matchers.js rename to packages/backend-core/src/middleware/matchers.js diff --git a/packages/auth/src/middleware/passport/google.js b/packages/backend-core/src/middleware/passport/google.js similarity index 100% rename from packages/auth/src/middleware/passport/google.js rename to packages/backend-core/src/middleware/passport/google.js diff --git a/packages/auth/src/middleware/passport/jwt.js b/packages/backend-core/src/middleware/passport/jwt.js similarity index 100% rename from packages/auth/src/middleware/passport/jwt.js rename to packages/backend-core/src/middleware/passport/jwt.js diff --git a/packages/auth/src/middleware/passport/local.js b/packages/backend-core/src/middleware/passport/local.js similarity index 100% rename from packages/auth/src/middleware/passport/local.js rename to packages/backend-core/src/middleware/passport/local.js diff --git a/packages/auth/src/middleware/passport/oidc.js b/packages/backend-core/src/middleware/passport/oidc.js similarity index 100% rename from packages/auth/src/middleware/passport/oidc.js rename to packages/backend-core/src/middleware/passport/oidc.js diff --git a/packages/auth/src/middleware/passport/tests/google.spec.js b/packages/backend-core/src/middleware/passport/tests/google.spec.js similarity index 100% rename from packages/auth/src/middleware/passport/tests/google.spec.js rename to packages/backend-core/src/middleware/passport/tests/google.spec.js diff --git a/packages/auth/src/middleware/passport/tests/oidc.spec.js b/packages/backend-core/src/middleware/passport/tests/oidc.spec.js similarity index 100% rename from packages/auth/src/middleware/passport/tests/oidc.spec.js rename to packages/backend-core/src/middleware/passport/tests/oidc.spec.js diff --git a/packages/auth/src/middleware/passport/tests/third-party-common.spec.js b/packages/backend-core/src/middleware/passport/tests/third-party-common.spec.js similarity index 100% rename from packages/auth/src/middleware/passport/tests/third-party-common.spec.js rename to packages/backend-core/src/middleware/passport/tests/third-party-common.spec.js diff --git a/packages/auth/src/middleware/passport/tests/utilities/mock-data.js b/packages/backend-core/src/middleware/passport/tests/utilities/mock-data.js similarity index 100% rename from packages/auth/src/middleware/passport/tests/utilities/mock-data.js rename to packages/backend-core/src/middleware/passport/tests/utilities/mock-data.js diff --git a/packages/auth/src/middleware/passport/third-party-common.js b/packages/backend-core/src/middleware/passport/third-party-common.js similarity index 100% rename from packages/auth/src/middleware/passport/third-party-common.js rename to packages/backend-core/src/middleware/passport/third-party-common.js diff --git a/packages/auth/src/middleware/passport/utils.js b/packages/backend-core/src/middleware/passport/utils.js similarity index 100% rename from packages/auth/src/middleware/passport/utils.js rename to packages/backend-core/src/middleware/passport/utils.js diff --git a/packages/auth/src/middleware/tenancy.js b/packages/backend-core/src/middleware/tenancy.js similarity index 100% rename from packages/auth/src/middleware/tenancy.js rename to packages/backend-core/src/middleware/tenancy.js diff --git a/packages/auth/src/migrations/index.js b/packages/backend-core/src/migrations/index.js similarity index 100% rename from packages/auth/src/migrations/index.js rename to packages/backend-core/src/migrations/index.js diff --git a/packages/auth/src/migrations/tests/__snapshots__/index.spec.js.snap b/packages/backend-core/src/migrations/tests/__snapshots__/index.spec.js.snap similarity index 100% rename from packages/auth/src/migrations/tests/__snapshots__/index.spec.js.snap rename to packages/backend-core/src/migrations/tests/__snapshots__/index.spec.js.snap diff --git a/packages/auth/src/migrations/tests/index.spec.js b/packages/backend-core/src/migrations/tests/index.spec.js similarity index 100% rename from packages/auth/src/migrations/tests/index.spec.js rename to packages/backend-core/src/migrations/tests/index.spec.js diff --git a/packages/auth/src/objectStore/index.js b/packages/backend-core/src/objectStore/index.js similarity index 91% rename from packages/auth/src/objectStore/index.js rename to packages/backend-core/src/objectStore/index.js index 87b67d464e..b5d8475cee 100644 --- a/packages/auth/src/objectStore/index.js +++ b/packages/backend-core/src/objectStore/index.js @@ -206,6 +206,34 @@ exports.retrieveToTmp = async (bucketName, filepath) => { return outputPath } +/** + * Delete a single file. + */ +exports.deleteFile = async (bucketName, filepath) => { + const objectStore = exports.ObjectStore(bucketName) + await exports.makeSureBucketExists(objectStore, bucketName) + const params = { + Bucket: bucketName, + Key: filepath, + } + return objectStore.deleteObject(params) +} + +exports.deleteFiles = async (bucketName, filepaths) => { + const objectStore = exports.ObjectStore(bucketName) + await exports.makeSureBucketExists(objectStore, bucketName) + const params = { + Bucket: bucketName, + Delete: { + Objects: filepaths.map(path => ({ Key: path })), + }, + } + return objectStore.deleteObjects(params).promise() +} + +/** + * Delete a path, including everything within. + */ exports.deleteFolder = async (bucketName, folder) => { bucketName = sanitizeBucket(bucketName) folder = sanitizeKey(folder) diff --git a/packages/auth/src/objectStore/utils.js b/packages/backend-core/src/objectStore/utils.js similarity index 100% rename from packages/auth/src/objectStore/utils.js rename to packages/backend-core/src/objectStore/utils.js diff --git a/packages/auth/src/redis/authRedis.js b/packages/backend-core/src/redis/authRedis.js similarity index 100% rename from packages/auth/src/redis/authRedis.js rename to packages/backend-core/src/redis/authRedis.js diff --git a/packages/auth/src/redis/index.js b/packages/backend-core/src/redis/index.js similarity index 100% rename from packages/auth/src/redis/index.js rename to packages/backend-core/src/redis/index.js diff --git a/packages/auth/src/redis/utils.js b/packages/backend-core/src/redis/utils.js similarity index 98% rename from packages/auth/src/redis/utils.js rename to packages/backend-core/src/redis/utils.js index 466b117e96..3461d2a511 100644 --- a/packages/auth/src/redis/utils.js +++ b/packages/backend-core/src/redis/utils.js @@ -16,6 +16,7 @@ exports.Databases = { USER_CACHE: "users", FLAGS: "flags", APP_METADATA: "appMetadata", + QUERY_VARS: "queryVars", } exports.SEPARATOR = SEPARATOR diff --git a/packages/auth/src/security/permissions.js b/packages/backend-core/src/security/permissions.js similarity index 100% rename from packages/auth/src/security/permissions.js rename to packages/backend-core/src/security/permissions.js diff --git a/packages/auth/src/security/roles.js b/packages/backend-core/src/security/roles.js similarity index 100% rename from packages/auth/src/security/roles.js rename to packages/backend-core/src/security/roles.js diff --git a/packages/auth/src/security/sessions.js b/packages/backend-core/src/security/sessions.js similarity index 100% rename from packages/auth/src/security/sessions.js rename to packages/backend-core/src/security/sessions.js diff --git a/packages/auth/src/tenancy/FunctionContext.js b/packages/backend-core/src/tenancy/FunctionContext.js similarity index 100% rename from packages/auth/src/tenancy/FunctionContext.js rename to packages/backend-core/src/tenancy/FunctionContext.js diff --git a/packages/auth/src/tenancy/context.js b/packages/backend-core/src/tenancy/context.js similarity index 100% rename from packages/auth/src/tenancy/context.js rename to packages/backend-core/src/tenancy/context.js diff --git a/packages/auth/src/tenancy/deprovision.js b/packages/backend-core/src/tenancy/deprovision.js similarity index 100% rename from packages/auth/src/tenancy/deprovision.js rename to packages/backend-core/src/tenancy/deprovision.js diff --git a/packages/auth/src/tenancy/index.js b/packages/backend-core/src/tenancy/index.js similarity index 100% rename from packages/auth/src/tenancy/index.js rename to packages/backend-core/src/tenancy/index.js diff --git a/packages/auth/src/tenancy/tenancy.js b/packages/backend-core/src/tenancy/tenancy.js similarity index 100% rename from packages/auth/src/tenancy/tenancy.js rename to packages/backend-core/src/tenancy/tenancy.js diff --git a/packages/auth/src/tests/utilities/db.js b/packages/backend-core/src/tests/utilities/db.js similarity index 100% rename from packages/auth/src/tests/utilities/db.js rename to packages/backend-core/src/tests/utilities/db.js diff --git a/packages/auth/src/tests/utilities/dbConfig.js b/packages/backend-core/src/tests/utilities/dbConfig.js similarity index 100% rename from packages/auth/src/tests/utilities/dbConfig.js rename to packages/backend-core/src/tests/utilities/dbConfig.js diff --git a/packages/auth/src/utils.js b/packages/backend-core/src/utils.js similarity index 95% rename from packages/auth/src/utils.js rename to packages/backend-core/src/utils.js index b8fa7b9588..37193885f1 100644 --- a/packages/auth/src/utils.js +++ b/packages/backend-core/src/utils.js @@ -23,6 +23,7 @@ const { getUserSessions, invalidateSessions } = require("./security/sessions") const { migrateIfRequired } = require("./migrations") const { USER_EMAIL_VIEW_CASING } = require("./migrations").MIGRATIONS const { GLOBAL_DB } = require("./migrations").MIGRATION_DBS +const { isDev, isTest } = require("./environment") const APP_PREFIX = DocumentTypes.APP + SEPARATOR @@ -63,6 +64,17 @@ exports.getAppId = ctx => { return appId } +/** + * opens the contents of the specified encrypted JWT. + * @return {object} the contents of the token. + */ +exports.openJwt = token => { + if (!token) { + return token + } + return jwt.verify(token, options.secretOrKey) +} + /** * Get a cookie from context, and decrypt if necessary. * @param {object} ctx The request which is to be manipulated. @@ -75,7 +87,7 @@ exports.getCookie = (ctx, name) => { return cookie } - return jwt.verify(cookie, options.secretOrKey) + return exports.openJwt(cookie) } /** @@ -97,6 +109,11 @@ exports.setCookie = (ctx, value, name = "builder", opts = { sign: true }) => { overwrite: true, } + if (!isDev() && !isTest()) { + config.sameSite = "none" + config.secure = true + } + if (environment.COOKIE_DOMAIN) { config.domain = environment.COOKIE_DOMAIN } diff --git a/packages/auth/tenancy.js b/packages/backend-core/tenancy.js similarity index 100% rename from packages/auth/tenancy.js rename to packages/backend-core/tenancy.js diff --git a/packages/backend-core/utils.js b/packages/backend-core/utils.js new file mode 100644 index 0000000000..2ef920e103 --- /dev/null +++ b/packages/backend-core/utils.js @@ -0,0 +1,4 @@ +module.exports = { + ...require("./src/utils"), + ...require("./src/hashing"), +} diff --git a/packages/auth/yarn.lock b/packages/backend-core/yarn.lock similarity index 100% rename from packages/auth/yarn.lock rename to packages/backend-core/yarn.lock diff --git a/packages/bbui/package.json b/packages/bbui/package.json index cad4db6aac..02a1f3fdb5 100644 --- a/packages/bbui/package.json +++ b/packages/bbui/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/bbui", "description": "A UI solution used in the different Budibase projects.", - "version": "1.0.30", + "version": "1.0.41", "license": "MPL-2.0", "svelte": "src/index.js", "module": "dist/bbui.es.js", diff --git a/packages/bbui/src/ActionButton/ActionButton.svelte b/packages/bbui/src/ActionButton/ActionButton.svelte index b518ac3d92..5ab7a7f047 100644 --- a/packages/bbui/src/ActionButton/ActionButton.svelte +++ b/packages/bbui/src/ActionButton/ActionButton.svelte @@ -80,4 +80,8 @@ .active svg { color: var(--spectrum-global-color-blue-600); } + + .spectrum-ActionButton-label { + padding-bottom: 2px; + } diff --git a/packages/bbui/src/Banner/Banner.svelte b/packages/bbui/src/Banner/Banner.svelte new file mode 100644 index 0000000000..f28ee09d9c --- /dev/null +++ b/packages/bbui/src/Banner/Banner.svelte @@ -0,0 +1,59 @@ + + +{#if show} +
+ +
+
+ +
+ {#if extraButtonText && extraButtonAction} + + {/if} +
+
+ +
+
+{/if} diff --git a/packages/bbui/src/Drawer/Drawer.svelte b/packages/bbui/src/Drawer/Drawer.svelte index 5e3de88e61..4bc8a69445 100644 --- a/packages/bbui/src/Drawer/Drawer.svelte +++ b/packages/bbui/src/Drawer/Drawer.svelte @@ -21,16 +21,8 @@ } visible = false } - - function handleKey(e) { - if (visible && e.key === "Escape") { - hide() - } - } - - {#if visible}
diff --git a/packages/bbui/src/Form/Core/Dropzone.svelte b/packages/bbui/src/Form/Core/Dropzone.svelte index a543dea1d4..bbaf5a3ff9 100644 --- a/packages/bbui/src/Form/Core/Dropzone.svelte +++ b/packages/bbui/src/Form/Core/Dropzone.svelte @@ -6,6 +6,8 @@ import { generateID } from "../../utils/helpers" import Icon from "../../Icon/Icon.svelte" import Link from "../../Link/Link.svelte" + import Tag from "../../Tags/Tag.svelte" + import Tags from "../../Tags/Tags.svelte" const BYTES_IN_KB = 1000 const BYTES_IN_MB = 1000000 @@ -18,6 +20,8 @@ export let handleFileTooLarge = null export let gallery = true export let error = null + export let fileTags = [] + export let maximum = null const dispatch = createEventDispatcher() const imageExtensions = [ @@ -184,103 +188,118 @@ {/each} {/if} {/if} -
-
- - - - - - +
+ - - - - - - - - - - -

- Drag and drop your file -

- {#if !disabled} -

- -
- from your computer -

- {/if} + + + + + + + + + + + + + + +

+ Drag and drop your file +

+ {#if !disabled} +

+ +
+ from your computer +

+ {#if fileTags.length} + +
+ {#each fileTags as tag} +
+ + {tag} + +
+ {/each} +
+
+ {/if} + {/if} +
-
+ {/if} diff --git a/packages/bbui/src/Form/Core/Search.svelte b/packages/bbui/src/Form/Core/Search.svelte index dd70f1eaca..e6384e242a 100644 --- a/packages/bbui/src/Form/Core/Search.svelte +++ b/packages/bbui/src/Form/Core/Search.svelte @@ -7,7 +7,7 @@ export let disabled = false export let id = null export let updateOnChange = true - + export let quiet = false const dispatch = createEventDispatcher() let focus = false @@ -41,6 +41,7 @@