diff --git a/.env.example b/.env.example index f3271e560c..1c0f6152c1 100644 --- a/.env.example +++ b/.env.example @@ -1 +1,2 @@ -API_KEY_PREFIX=cal_ \ No newline at end of file +API_KEY_PREFIX=cal_ +DATABASE_URL="postgresql://postgres:@localhost:5450/calendso" diff --git a/lib/helpers/verifyApiKey.ts b/lib/helpers/verifyApiKey.ts index 6fe33c6ad3..008f3dc4f4 100644 --- a/lib/helpers/verifyApiKey.ts +++ b/lib/helpers/verifyApiKey.ts @@ -4,31 +4,31 @@ import { hashAPIKey } from "@calcom/ee/lib/api/apiKeys"; import prisma from "@calcom/prisma"; // Used to check if the API key is not expired, could be extracted if reused. but not for now. -export const dateInPast = function (firstDate: Date, secondDate: Date) { - if (firstDate.setHours(0, 0, 0, 0) <= secondDate.setHours(0, 0, 0, 0)) { +export const dateInPast = function (date: Date) { + const now = new Date(); + if (now.setHours(0, 0, 0, 0) <= date.setHours(0, 0, 0, 0)) { return true; } }; -const today = new Date(); // This verifies the API key and sets the user if it is valid. export const verifyApiKey: NextMiddleware = async (req, res, next) => { - if (!req.query.apiKey) res.status(401).json({ message: "No API key provided" }); - + if (!req.query.apiKey) res.status(401).json({ message: "No api key provided" }); + // We remove the prefix from the user provided api_key. If no env set default to "cal_" const strippedApiKey = `${req.query.apiKey}`.replace(process.env.API_KEY_PREFIX || "cal_", ""); + // Hash the key again before matching against the database records. const hashedKey = hashAPIKey(strippedApiKey); - - await prisma.apiKey - .findUnique({ where: { hashedKey } }) - .then(async (apiKey) => { - if (!apiKey) { - res.status(401).json({ error: "You did not provide an api key" }); - throw new Error("No api key found"); - } - if (apiKey.userId) res.setHeader("X-Calcom-User-ID", apiKey.userId); - if (apiKey.expiresAt && apiKey.userId && dateInPast(today, apiKey.expiresAt)) await next(); - }) - .catch((error) => { - res.status(401).json({ error: "Your api key is not valid" }); - }); + // Check if the hashed api key exists in database. + await prisma.apiKey.findUnique({ where: { hashedKey } }).then(async (apiKey) => { + // If we cannot find any api key. Throw a 401 Unauthorized. + if (!apiKey) res.status(401).json({ error: "Your api key is not valid" }); + if (apiKey && apiKey.expiresAt && dateInPast(apiKey.expiresAt) && apiKey.userId) { + // Right now API Keys are user centric, we only allow resources related to this userId throughout the application. + // if the api key is not expired, and the user id is present in the database. + // Set the user in the request. as x-calcom-user-id. + res.setHeader("X-Calcom-User-ID", apiKey.userId); + // Pass the request to the next middleware. + await next(); + } + }); }; diff --git a/pages/api/attendees/[id].ts b/pages/api/attendees/[id].ts index 50b6b10cec..a7b573cc87 100644 --- a/pages/api/attendees/[id].ts +++ b/pages/api/attendees/[id].ts @@ -23,6 +23,8 @@ import { * type: integer * required: true * description: Numeric ID of the attendee to get + * security: + * - ApiKeyAuth: [] * tags: * - attendees * responses: @@ -50,6 +52,8 @@ import { * type: integer * required: true * description: Numeric ID of the attendee to edit + * security: + * - ApiKeyAuth: [] * tags: * - attendees * responses: @@ -69,6 +73,8 @@ import { * type: integer * required: true * description: Numeric ID of the attendee to delete + * security: + * - ApiKeyAuth: [] * tags: * - attendees * responses: diff --git a/pages/api/attendees/index.ts b/pages/api/attendees/index.ts index 5185acda2c..ed0707d636 100644 --- a/pages/api/attendees/index.ts +++ b/pages/api/attendees/index.ts @@ -12,6 +12,8 @@ import { schemaAttendeeBodyParams, schemaAttendeePublic, withValidAttendee } fro * /v1/attendees: * get: * summary: Get all attendees + * security: + * - ApiKeyAuth: [] * tags: * - attendees * responses: @@ -23,6 +25,8 @@ import { schemaAttendeeBodyParams, schemaAttendeePublic, withValidAttendee } fro * description: No attendees were found * post: * summary: Creates a new attendee + * security: + * - ApiKeyAuth: [] * tags: * - attendees * responses: diff --git a/pages/api/availabilities/[id].ts b/pages/api/availabilities/[id].ts index db660b1074..feeef587c0 100644 --- a/pages/api/availabilities/[id].ts +++ b/pages/api/availabilities/[id].ts @@ -23,6 +23,8 @@ import { * type: integer * required: true * description: Numeric ID of the availability to get + * security: + * - ApiKeyAuth: [] * tags: * - availabilities * responses: @@ -50,6 +52,8 @@ import { * type: integer * required: true * description: Numeric ID of the availability to edit + * security: + * - ApiKeyAuth: [] * tags: * - availabilities * responses: @@ -69,6 +73,8 @@ import { * type: integer * required: true * description: Numeric ID of the availability to delete + * security: + * - ApiKeyAuth: [] * tags: * - availabilities * responses: diff --git a/pages/api/availabilities/index.ts b/pages/api/availabilities/index.ts index 45349b6b3f..558b948d30 100644 --- a/pages/api/availabilities/index.ts +++ b/pages/api/availabilities/index.ts @@ -12,6 +12,8 @@ import { schemaAvailabilityBodyParams, schemaAvailabilityPublic } from "@lib/val * /v1/availabilities: * get: * summary: Get all availabilities + * security: + * - ApiKeyAuth: [] * tags: * - availabilities * responses: @@ -23,6 +25,8 @@ import { schemaAvailabilityBodyParams, schemaAvailabilityPublic } from "@lib/val * description: No availabilities were found * post: * summary: Creates a new availability + * security: + * - ApiKeyAuth: [] * tags: * - availabilities * responses: diff --git a/pages/api/booking-references/[id].ts b/pages/api/booking-references/[id].ts index c9527e3f99..3067dc3c15 100644 --- a/pages/api/booking-references/[id].ts +++ b/pages/api/booking-references/[id].ts @@ -27,6 +27,8 @@ import { * type: integer * required: true * description: Numeric ID of the daily event reference to get + * security: + * - ApiKeyAuth: [] * tags: * - booking-references * responses: @@ -54,6 +56,8 @@ import { * type: integer * required: true * description: Numeric ID of the daily event reference to edit + * security: + * - ApiKeyAuth: [] * tags: * - booking-references * responses: @@ -73,6 +77,8 @@ import { * type: integer * required: true * description: Numeric ID of the daily event reference to delete + * security: + * - ApiKeyAuth: [] * tags: * - booking-references * responses: diff --git a/pages/api/booking-references/index.ts b/pages/api/booking-references/index.ts index 4fba496dd3..d256936ce5 100644 --- a/pages/api/booking-references/index.ts +++ b/pages/api/booking-references/index.ts @@ -15,6 +15,8 @@ import { * /v1/booking-references: * get: * summary: Get all booking references + * security: + * - ApiKeyAuth: [] * tags: * - booking-references * responses: @@ -26,6 +28,8 @@ import { * description: No booking references were found * post: * summary: Creates a new booking reference + * security: + * - ApiKeyAuth: [] * tags: * - booking-references * responses: diff --git a/pages/api/bookings/[id].ts b/pages/api/bookings/[id].ts index 54e21b5109..e3e56b9a36 100644 --- a/pages/api/bookings/[id].ts +++ b/pages/api/bookings/[id].ts @@ -23,6 +23,8 @@ import { * type: integer * required: true * description: Numeric ID of the booking to get + * security: + * - ApiKeyAuth: [] * tags: * - bookings * responses: @@ -50,6 +52,8 @@ import { * type: integer * required: true * description: Numeric ID of the booking to edit + * security: + * - ApiKeyAuth: [] * tags: * - bookings * responses: @@ -69,6 +73,8 @@ import { * type: integer * required: true * description: Numeric ID of the booking to delete + * security: + * - ApiKeyAuth: [] * tags: * - bookings * responses: diff --git a/pages/api/bookings/index.ts b/pages/api/bookings/index.ts index 2b2b55bf21..c3d11a91e0 100644 --- a/pages/api/bookings/index.ts +++ b/pages/api/bookings/index.ts @@ -12,6 +12,8 @@ import { schemaBookingBodyParams, schemaBookingPublic, withValidBooking } from " * /v1/bookings: * get: * summary: Get all bookings + * security: + * - ApiKeyAuth: [] * tags: * - bookings * responses: @@ -23,6 +25,8 @@ import { schemaBookingBodyParams, schemaBookingPublic, withValidBooking } from " * description: No bookings were found * post: * summary: Creates a new booking + * security: + * - ApiKeyAuth: [] * tags: * - bookings * responses: diff --git a/pages/api/credentials/[id].ts b/pages/api/credentials/[id].ts index 52c95fd023..279ad3c2b4 100644 --- a/pages/api/credentials/[id].ts +++ b/pages/api/credentials/[id].ts @@ -23,6 +23,8 @@ import { * type: integer * required: true * description: Numeric ID of the credential to get + * security: + * - ApiKeyAuth: [] * tags: * - credentials * responses: @@ -50,6 +52,8 @@ import { * type: integer * required: true * description: Numeric ID of the credential to edit + * security: + * - ApiKeyAuth: [] * tags: * - credentials * responses: @@ -69,6 +73,8 @@ import { * type: integer * required: true * description: Numeric ID of the credential to delete + * security: + * - ApiKeyAuth: [] * tags: * - credentials * responses: diff --git a/pages/api/credentials/index.ts b/pages/api/credentials/index.ts index d7b9ed651f..5e94ee17cd 100644 --- a/pages/api/credentials/index.ts +++ b/pages/api/credentials/index.ts @@ -12,6 +12,8 @@ import { schemaCredentialBodyParams, schemaCredentialPublic } from "@lib/validat * /api/credentials: * get: * summary: Get all credentials + * security: + * - ApiKeyAuth: [] * tags: * - credentials * responses: @@ -23,6 +25,8 @@ import { schemaCredentialBodyParams, schemaCredentialPublic } from "@lib/validat * description: No credentials were found * post: * summary: Creates a new credential + * security: + * - ApiKeyAuth: [] * tags: * - credentials * responses: diff --git a/pages/api/daily-event-references/[id].ts b/pages/api/daily-event-references/[id].ts index 482aab6ec1..17d6ced278 100644 --- a/pages/api/daily-event-references/[id].ts +++ b/pages/api/daily-event-references/[id].ts @@ -25,6 +25,8 @@ import { * type: integer * required: true * description: Numeric ID of the daily event reference to get + * security: + * - ApiKeyAuth: [] * tags: * - daily-event-references * responses: @@ -52,6 +54,8 @@ import { * type: integer * required: true * description: Numeric ID of the daily event reference to edit + * security: + * - ApiKeyAuth: [] * tags: * - daily-event-references * responses: @@ -71,6 +75,8 @@ import { * type: integer * required: true * description: Numeric ID of the daily event reference to delete + * security: + * - ApiKeyAuth: [] * tags: * - daily-event-references * responses: diff --git a/pages/api/daily-event-references/index.ts b/pages/api/daily-event-references/index.ts index 1a1762157d..aa60482bb1 100644 --- a/pages/api/daily-event-references/index.ts +++ b/pages/api/daily-event-references/index.ts @@ -14,6 +14,8 @@ import { * /v1/daily-event-references: * get: * summary: Get all daily event reference + * security: + * - ApiKeyAuth: [] * tags: * - daily-event-reference * responses: @@ -25,6 +27,8 @@ import { * description: No daily event references were found * post: * summary: Creates a new daily event reference + * security: + * - ApiKeyAuth: [] * tags: * - daily-event-reference * responses: diff --git a/pages/api/destination-calendars/[id].ts b/pages/api/destination-calendars/[id].ts index a72bcecba1..ef7712e525 100644 --- a/pages/api/destination-calendars/[id].ts +++ b/pages/api/destination-calendars/[id].ts @@ -25,6 +25,8 @@ import { * type: integer * required: true * description: Numeric ID of the destination calendar to get + * security: + * - ApiKeyAuth: [] * tags: * - destination-calendars * responses: @@ -52,6 +54,8 @@ import { * type: integer * required: true * description: Numeric ID of the destination calendar to edit + * security: + * - ApiKeyAuth: [] * tags: * - destination-calendars * responses: @@ -71,6 +75,8 @@ import { * type: integer * required: true * description: Numeric ID of the destination calendar to delete + * security: + * - ApiKeyAuth: [] * tags: * - destination-calendars * responses: diff --git a/pages/api/destination-calendars/index.ts b/pages/api/destination-calendars/index.ts index 3557272970..3980b3e203 100644 --- a/pages/api/destination-calendars/index.ts +++ b/pages/api/destination-calendars/index.ts @@ -14,6 +14,8 @@ import { * /v1/destination-calendars: * get: * summary: Get all destination calendars + * security: + * - ApiKeyAuth: [] * tags: * - destination-calendars * responses: @@ -25,6 +27,8 @@ import { * description: No destination calendars were found * post: * summary: Creates a new destination calendar + * security: + * - ApiKeyAuth: [] * tags: * - destination-calendars * responses: diff --git a/pages/api/docs.ts b/pages/api/docs.ts index d9aa75d18c..3c9f50cfed 100644 --- a/pages/api/docs.ts +++ b/pages/api/docs.ts @@ -9,8 +9,10 @@ const swaggerHandler = withSwagger({ title: `${pjson.name}: ${pjson.description}`, version: pjson.version, }, - components: { schemas: { ...jsonSchema.definitions } }, - definitions: jsonSchema.definitions, + components: { + securitySchemes: { ApiKeyAuth: { type: "apiKey", in: "query", name: "apiKey" } }, + schemas: { ...jsonSchema.definitions }, + }, }, apiFolder: "pages/api", tags: ["users", "teams", "memeberships"], diff --git a/pages/api/event-type-custom-inputs/[id].ts b/pages/api/event-type-custom-inputs/[id].ts index 62b61d9c92..d9dd21d112 100644 --- a/pages/api/event-type-custom-inputs/[id].ts +++ b/pages/api/event-type-custom-inputs/[id].ts @@ -25,6 +25,8 @@ import { * type: integer * required: true * description: Numeric ID of the eventTypeCustomInput to get + * security: + * - ApiKeyAuth: [] * tags: * - event-type-custom-inputs * responses: @@ -52,6 +54,8 @@ import { * type: integer * required: true * description: Numeric ID of the eventTypeCustomInput to edit + * security: + * - ApiKeyAuth: [] * tags: * - event-type-custom-inputs * responses: @@ -71,6 +75,8 @@ import { * type: integer * required: true * description: Numeric ID of the eventTypeCustomInput to delete + * security: + * - ApiKeyAuth: [] * tags: * - event-type-custom-inputs * responses: diff --git a/pages/api/event-type-custom-inputs/index.ts b/pages/api/event-type-custom-inputs/index.ts index f988adc281..806d3ca91e 100644 --- a/pages/api/event-type-custom-inputs/index.ts +++ b/pages/api/event-type-custom-inputs/index.ts @@ -14,6 +14,8 @@ import { * /v1/event-type-custom-inputs: * get: * summary: Get all eventTypeCustomInputs + * security: + * - ApiKeyAuth: [] * tags: * - event-type-custom-inputs * responses: @@ -25,6 +27,8 @@ import { * description: No eventTypeCustomInputs were found * post: * summary: Creates a new eventTypeCustomInput + * security: + * - ApiKeyAuth: [] * tags: * - event-type-custom-inputs * responses: diff --git a/pages/api/event-types/[id].ts b/pages/api/event-types/[id].ts index e3ffe87f9b..410cbbb5af 100644 --- a/pages/api/event-types/[id].ts +++ b/pages/api/event-types/[id].ts @@ -22,6 +22,8 @@ import { * type: integer * required: true * description: Numeric ID of the eventType to get + * security: + * - ApiKeyAuth: [] * tags: * - event-types * responses: @@ -49,6 +51,8 @@ import { * type: integer * required: true * description: Numeric ID of the eventType to edit + * security: + * - ApiKeyAuth: [] * tags: * - event-types * responses: @@ -68,6 +72,8 @@ import { * type: integer * required: true * description: Numeric ID of the eventType to delete + * security: + * - ApiKeyAuth: [] * tags: * - event-types * responses: diff --git a/pages/api/event-types/index.ts b/pages/api/event-types/index.ts index 724f0e9769..7f04a6a3de 100644 --- a/pages/api/event-types/index.ts +++ b/pages/api/event-types/index.ts @@ -11,6 +11,8 @@ import { schemaEventTypeBodyParams, schemaEventTypePublic } from "@lib/validatio * /v1/event-types: * get: * summary: Get all event types + * security: + * - ApiKeyAuth: [] * tags: * - event-types * responses: @@ -22,6 +24,8 @@ import { schemaEventTypeBodyParams, schemaEventTypePublic } from "@lib/validatio * description: No event types were found * post: * summary: Creates a new event type + * security: + * - ApiKeyAuth: [] * tags: * - event-types * responses: diff --git a/pages/api/memberships/[id].ts b/pages/api/memberships/[id].ts index a963c023f5..2fbb14bcdb 100644 --- a/pages/api/memberships/[id].ts +++ b/pages/api/memberships/[id].ts @@ -25,6 +25,8 @@ import { schemaQueryIdAsString, withValidQueryIdString } from "@lib/validations/ * type: integer * required: true * description: Numeric teamId of the membership to get + * security: + * - ApiKeyAuth: [] * tags: * - memberships * responses: @@ -58,6 +60,8 @@ import { schemaQueryIdAsString, withValidQueryIdString } from "@lib/validations/ * type: integer * required: true * description: Numeric teamId of the membership to get + * security: + * - ApiKeyAuth: [] * tags: * - memberships * responses: @@ -83,6 +87,8 @@ import { schemaQueryIdAsString, withValidQueryIdString } from "@lib/validations/ * type: integer * required: true * description: Numeric teamId of the membership to get + * security: + * - ApiKeyAuth: [] * tags: * - memberships * responses: diff --git a/pages/api/memberships/index.ts b/pages/api/memberships/index.ts index 54b6e70c16..85c2ddced1 100644 --- a/pages/api/memberships/index.ts +++ b/pages/api/memberships/index.ts @@ -11,6 +11,8 @@ import { schemaMembershipBodyParams, schemaMembershipPublic } from "@lib/validat * /v1/memberships: * get: * summary: Get all memberships + * security: + * - ApiKeyAuth: [] * tags: * - memberships * responses: @@ -22,6 +24,8 @@ import { schemaMembershipBodyParams, schemaMembershipPublic } from "@lib/validat * description: No memberships were found * post: * summary: Creates a new membership + * security: + * - ApiKeyAuth: [] * tags: * - memberships * responses: diff --git a/pages/api/payments/[id].ts b/pages/api/payments/[id].ts index cdedf473ec..f196b4cac0 100644 --- a/pages/api/payments/[id].ts +++ b/pages/api/payments/[id].ts @@ -23,6 +23,8 @@ import { * type: integer * required: true * description: Numeric ID of the payment to get + * security: + * - ApiKeyAuth: [] * tags: * - payments * responses: diff --git a/pages/api/payments/index.ts b/pages/api/payments/index.ts index 955cff0725..20028df180 100644 --- a/pages/api/payments/index.ts +++ b/pages/api/payments/index.ts @@ -12,6 +12,8 @@ import { schemaPaymentPublic } from "@lib/validations/payment"; * /v1/payments: * get: * summary: Get all payments + * security: + * - ApiKeyAuth: [] * tags: * - payments * responses: diff --git a/pages/api/reminder-mails/[id].ts b/pages/api/reminder-mails/[id].ts index 10c5dd41e6..e6627ef7b9 100644 --- a/pages/api/reminder-mails/[id].ts +++ b/pages/api/reminder-mails/[id].ts @@ -22,6 +22,8 @@ import { * type: integer * required: true * description: Numeric ID of the reminderMail to get + * security: + * - ApiKeyAuth: [] * tags: * - reminder-mails * responses: @@ -49,6 +51,8 @@ import { * type: integer * required: true * description: Numeric ID of the reminderMail to edit + * security: + * - ApiKeyAuth: [] * tags: * - reminder-mails * responses: @@ -68,6 +72,8 @@ import { * type: integer * required: true * description: Numeric ID of the reminderMail to delete + * security: + * - ApiKeyAuth: [] * tags: * - reminder-mails * responses: diff --git a/pages/api/reminder-mails/index.ts b/pages/api/reminder-mails/index.ts index 2c743c0474..22c4f63dab 100644 --- a/pages/api/reminder-mails/index.ts +++ b/pages/api/reminder-mails/index.ts @@ -15,6 +15,8 @@ import { * /v1/reminder-mails: * get: * summary: Get all reminder mails + * security: + * - ApiKeyAuth: [] * tags: * - reminder-mails * responses: @@ -26,6 +28,8 @@ import { * description: No reminder mails were found * post: * summary: Creates a new reminder mail + * security: + * - ApiKeyAuth: [] * tags: * - reminder-mails * responses: diff --git a/pages/api/schedules/[id].ts b/pages/api/schedules/[id].ts index c75034e5d1..eb87d13949 100644 --- a/pages/api/schedules/[id].ts +++ b/pages/api/schedules/[id].ts @@ -22,6 +22,8 @@ import { * type: integer * required: true * description: Numeric ID of the schedule to get + * security: + * - ApiKeyAuth: [] * tags: * - schedules * responses: @@ -49,6 +51,8 @@ import { * type: integer * required: true * description: Numeric ID of the schedule to edit + * security: + * - ApiKeyAuth: [] * tags: * - schedules * responses: @@ -68,6 +72,8 @@ import { * type: integer * required: true * description: Numeric ID of the schedule to delete + * security: + * - ApiKeyAuth: [] * tags: * - schedules * responses: diff --git a/pages/api/schedules/index.ts b/pages/api/schedules/index.ts index f8eedf599f..3f5761e30d 100644 --- a/pages/api/schedules/index.ts +++ b/pages/api/schedules/index.ts @@ -11,6 +11,8 @@ import { schemaScheduleBodyParams, schemaSchedulePublic, withValidSchedule } fro * /v1/schedules: * get: * summary: Get all schedules + * security: + * - ApiKeyAuth: [] * tags: * - schedules * responses: @@ -22,6 +24,8 @@ import { schemaScheduleBodyParams, schemaSchedulePublic, withValidSchedule } fro * description: No schedules were found * post: * summary: Creates a new schedule + * security: + * - ApiKeyAuth: [] * tags: * - schedules * responses: diff --git a/pages/api/selected-calendars/[id].ts b/pages/api/selected-calendars/[id].ts index b66fc5a888..219d51dc4c 100644 --- a/pages/api/selected-calendars/[id].ts +++ b/pages/api/selected-calendars/[id].ts @@ -34,6 +34,8 @@ import { schemaQueryIdAsString, withValidQueryIdString } from "@lib/validations/ * type: string * required: true * description: integration of the selected calendar to get + * security: + * - ApiKeyAuth: [] * tags: * - selected-calendars * responses: @@ -73,6 +75,8 @@ import { schemaQueryIdAsString, withValidQueryIdString } from "@lib/validations/ * type: string * required: true * description: integration of the selected calendar to get + * security: + * - ApiKeyAuth: [] * tags: * - selected-calendars * responses: @@ -104,6 +108,8 @@ import { schemaQueryIdAsString, withValidQueryIdString } from "@lib/validations/ * type: string * required: true * description: integration of the selected calendar to get + * security: + * - ApiKeyAuth: [] * tags: * - selected-calendars * responses: diff --git a/pages/api/selected-calendars/index.ts b/pages/api/selected-calendars/index.ts index a6a8a39c16..15daead8a2 100644 --- a/pages/api/selected-calendars/index.ts +++ b/pages/api/selected-calendars/index.ts @@ -15,6 +15,8 @@ import { * /v1/selected-calendars: * get: * summary: Get all selected calendars + * security: + * - ApiKeyAuth: [] * tags: * - selected-calendars * responses: @@ -26,6 +28,8 @@ import { * description: No selected calendars were found * post: * summary: Creates a new selected calendar + * security: + * - ApiKeyAuth: [] * tags: * - selected-calendars * responses: diff --git a/pages/api/teams/[id].ts b/pages/api/teams/[id].ts index 70f88c1b35..07da2e2870 100644 --- a/pages/api/teams/[id].ts +++ b/pages/api/teams/[id].ts @@ -23,6 +23,8 @@ import { schemaTeamBodyParams, schemaTeamPublic } from "@lib/validations/team"; * type: integer * required: true * description: Numeric ID of the team to get + * security: + * - ApiKeyAuth: [] * tags: * - teams * responses: @@ -50,6 +52,8 @@ import { schemaTeamBodyParams, schemaTeamPublic } from "@lib/validations/team"; * type: integer * required: true * description: Numeric ID of the team to edit + * security: + * - ApiKeyAuth: [] * tags: * - teams * responses: @@ -69,6 +73,8 @@ import { schemaTeamBodyParams, schemaTeamPublic } from "@lib/validations/team"; * type: integer * required: true * description: Numeric ID of the team to delete + * security: + * - ApiKeyAuth: [] * tags: * - teams * responses: diff --git a/pages/api/teams/index.ts b/pages/api/teams/index.ts index 8007e2fea0..d1c24bf8b8 100644 --- a/pages/api/teams/index.ts +++ b/pages/api/teams/index.ts @@ -12,6 +12,8 @@ import { schemaTeamBodyParams, schemaTeamPublic, withValidTeam } from "@lib/vali * /v1/teams: * get: * summary: Get all teams + * security: + * - ApiKeyAuth: [] * tags: * - teams * responses: @@ -23,6 +25,8 @@ import { schemaTeamBodyParams, schemaTeamPublic, withValidTeam } from "@lib/vali * description: No teams were found * post: * summary: Creates a new team + * security: + * - ApiKeyAuth: [] * tags: * - teams * responses: diff --git a/pages/api/users/[id].ts b/pages/api/users/[id].ts index a5c55095e5..5beaf442df 100644 --- a/pages/api/users/[id].ts +++ b/pages/api/users/[id].ts @@ -23,6 +23,8 @@ import { schemaUserBodyParams, schemaUserPublic } from "@lib/validations/user"; * type: integer * required: true * description: Numeric ID of the user to get + * security: + * - ApiKeyAuth: [] * tags: * - users * responses: @@ -50,6 +52,8 @@ import { schemaUserBodyParams, schemaUserPublic } from "@lib/validations/user"; * type: integer * required: true * description: Numeric ID of the user to edit + * security: + * - ApiKeyAuth: [] * tags: * - users * responses: @@ -69,6 +73,8 @@ import { schemaUserBodyParams, schemaUserPublic } from "@lib/validations/user"; * type: integer * required: true * description: Numeric ID of the user to delete + * security: + * - ApiKeyAuth: [] * tags: * - users * responses: diff --git a/pages/api/users/index.ts b/pages/api/users/index.ts index 138395adba..84c2e7ec57 100644 --- a/pages/api/users/index.ts +++ b/pages/api/users/index.ts @@ -12,6 +12,8 @@ import { schemaUserPublic } from "@lib/validations/user"; * /v1/users: * get: * summary: Get all users (admin only), returns your user if regular user. + * security: + * - ApiKeyAuth: [] * tags: * - users * responses: diff --git a/templates/endpoints/[id]/delete.ts b/templates/endpoints/[id]/delete.ts index 2b59baee90..5cf646aee0 100644 --- a/templates/endpoints/[id]/delete.ts +++ b/templates/endpoints/[id]/delete.ts @@ -21,6 +21,8 @@ import { * type: integer * required: true * description: Numeric ID of the resource to delete + * security: + * - ApiKeyAuth: [] * tags: * - resources * responses: diff --git a/templates/endpoints/[id]/edit.ts b/templates/endpoints/[id]/edit.ts index 0e73604fb4..54b8fec540 100644 --- a/templates/endpoints/[id]/edit.ts +++ b/templates/endpoints/[id]/edit.ts @@ -22,6 +22,8 @@ import { * type: integer * required: true * description: Numeric ID of the resource to edit + * security: + * - ApiKeyAuth: [] * tags: * - resources * responses: diff --git a/templates/endpoints/[id]/index.ts b/templates/endpoints/[id]/index.ts index 31393a7a6a..66e7ab105c 100644 --- a/templates/endpoints/[id]/index.ts +++ b/templates/endpoints/[id]/index.ts @@ -22,6 +22,8 @@ import { * type: integer * required: true * description: Numeric ID of the resource to get + * security: + * - ApiKeyAuth: [] * tags: * - resources * responses: diff --git a/templates/endpoints/get_all.ts b/templates/endpoints/get_all.ts index 490381501e..b3b9257e9a 100644 --- a/templates/endpoints/get_all.ts +++ b/templates/endpoints/get_all.ts @@ -11,6 +11,8 @@ import { schemaResourcePublic } from "@lib/validations/resource"; * /v1/resources: * get: * summary: Get all resources + * security: + * - ApiKeyAuth: [] * tags: * - resources * responses: diff --git a/templates/endpoints/get_all_and_post.ts b/templates/endpoints/get_all_and_post.ts index 25115ff859..bf6fee016f 100644 --- a/templates/endpoints/get_all_and_post.ts +++ b/templates/endpoints/get_all_and_post.ts @@ -11,6 +11,8 @@ import { schemaPaymentBodyParams, schemaPaymentPublic } from "@lib/validations/p * /v1/payments: * get: * summary: Get all payments + * security: + * - ApiKeyAuth: [] * tags: * - payments * responses: @@ -22,6 +24,8 @@ import { schemaPaymentBodyParams, schemaPaymentPublic } from "@lib/validations/p * description: No payments were found * post: * summary: Creates a new payment + * security: + * - ApiKeyAuth: [] * tags: * - payments * responses: diff --git a/templates/endpoints/post.ts b/templates/endpoints/post.ts index af0644a7a8..e2b9e17683 100644 --- a/templates/endpoints/post.ts +++ b/templates/endpoints/post.ts @@ -18,6 +18,8 @@ import { schemaResourceBodyParams, schemaResourcePublic, withValidResource } fro * application/json: * schema: * $ref: '#/components/schemas/Resource' + * security: + * - ApiKeyAuth: [] * tags: * - resources * responses: