diff --git a/.env.example b/.env.example index eec3f283f7..c5354bfd7d 100644 --- a/.env.example +++ b/.env.example @@ -1,3 +1,6 @@ API_KEY_PREFIX=cal_ DATABASE_URL="postgresql://postgres:@localhost:5450/calendso" -NEXT_PUBLIC_WEBAPP_URL=http://localhost:3000 \ No newline at end of file +NEXT_PUBLIC_WEBAPP_URL=http://localhost:3000 + +# Get it in console.cal.com +CALCOM_LICENSE_KEY="" diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000..fa89efec90 --- /dev/null +++ b/LICENSE @@ -0,0 +1,42 @@ +The Cal.com Enterprise Edition (EE) license (the “EE License”) +Copyright (c) 2020-present Cal.com, Inc + +With regard to the Cal.com Software: + +This software and associated documentation files (the "Software") may only be +used in production, if you (and any entity that you represent) have agreed to, +and are in compliance with, the Cal.com Subscription Terms available +at https://cal.com/terms (the “EE Terms”), or other agreements governing +the use of the Software, as mutually agreed by you and Cal.com, Inc ("Cal.com"), +and otherwise have a valid Cal.com Enterprise Edition subscription ("EE Subscription") +for the correct number of hosts as defined in the EE Terms ("Hosts"). Subject to the foregoing sentence, +you are free to modify this Software and publish patches to the Software. You agree +that Cal.com and/or its licensors (as applicable) retain all right, title and interest in +and to all such modifications and/or patches, and all such modifications and/or +patches may only be used, copied, modified, displayed, distributed, or otherwise +exploited with a valid EE Subscription for the correct number of hosts. +Notwithstanding the foregoing, you may copy and modify the Software for development +and testing purposes, without requiring a subscription. You agree that Cal.com and/or +its licensors (as applicable) retain all right, title and interest in and to all such +modifications. You are not granted any other rights beyond what is expressly stated herein. +Subject to the foregoing, it is forbidden to copy, merge, publish, distribute, sublicense, +and/or sell the Software. + +This EE License applies only to the part of this Software that is not distributed under +the AGPLv3 license. Any part of this Software distributed under the MIT license or which +is served client-side as an image, font, cascading stylesheet (CSS), file which produces +or is compiled, arranged, augmented, or combined into client-side JavaScript, in whole or +in part, is copyrighted under the AGPLv3 license. The full text of this EE License shall +be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +For all third party components incorporated into the Cal.com Software, those +components are licensed under the original license provided by the owner of the +applicable component. \ No newline at end of file diff --git a/README.md b/README.md index 7c2ce6e9ad..262feb851d 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,19 @@ -# Cal.com Public API (Enterprise Only) + +
+ + Logo + + + Get Started with Enterprise +
+ +# Cal.com Public API - Enterprise Edition + +Welcome to the Public API Enterprise Edition ("/apps/api") of the Cal.com Public API. + +The [/apps/api](https://github.com/calcom/cal.com/tree/main/apps/api) subfolder is the place for our Public API, which we serve at api.cal.com, and enterprise customers can also run [enterprise-grade](https://cal.com/enterprise) + +> _❗ WARNING: This repository is copyrighted (unlike our [main repo](https://github.com/calcom/cal.com)). You are not allowed to use this code to host your own version of app.cal.com without obtaining a proper [license](https://cal.com/pricing?infra) first❗_ This is the public REST api for cal.com. It exposes CRUD Endpoints of all our most important resources. @@ -203,4 +218,4 @@ See `scripts/vercel-deploy.sh` for more info on how the deployment is done. ## Environment variables -Lastly API requires an env var for `DATABASE_URL` +Lastly API requires an env var for `DATABASE_URL` and `CALCOM_LICENSE_KEY` diff --git a/lib/helpers/verifyApiKey.ts b/lib/helpers/verifyApiKey.ts index b915df6626..408cc55356 100644 --- a/lib/helpers/verifyApiKey.ts +++ b/lib/helpers/verifyApiKey.ts @@ -1,6 +1,7 @@ import { NextMiddleware } from "next-api-middleware"; import { hashAPIKey } from "@calcom/features/ee/api-keys/lib/apiKeys"; +import checkLicense from "@calcom/features/ee/common/server/checkLicense"; import { isAdminGuard } from "@lib/utils/isAdmin"; @@ -14,6 +15,9 @@ export const dateNotInPast = function (date: Date) { // This verifies the apiKey and sets the user if it is valid. export const verifyApiKey: NextMiddleware = async (req, res, next) => { + const hasValidLicense = await checkLicense(process.env.CALCOM_LICENSE_KEY || ""); + if (!hasValidLicense) + return res.status(401).json({ error: "Invalid or missing CALCOM_LICENSE_KEY environment variable" }); const { prisma, userId, isAdmin } = req; // If the user is an admin and using a license key (from customPrisma), skip the apiKey check. if (userId === 0 && isAdmin) { diff --git a/package.json b/package.json index e3a07595bb..ac5d07df25 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,6 @@ "node-mocks-http": "^1.11.0" }, "dependencies": { - "@calcom/app-store-cli": "*", "@calcom/prisma": "*", "@calcom/trpc": "*", "@sentry/nextjs": "^6.19.7",