Replace apiKey query params with Authorization header for cron endpoints (#1979)

Use Authorization header auth for cron endpoints
This commit is contained in:
Kiran K 2023-11-27 20:30:45 +05:30 committed by GitHub
parent 7d6829adb7
commit 260597e2e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 0 additions and 15 deletions

View File

@ -18,7 +18,6 @@ const unAuthenticatedApiRoutes = [
'/api/well-known/**',
'/api/setup/**',
'/api/branding',
'/api/scim/cron/**',
];
export async function middleware(req: NextRequest) {

View File

@ -1,17 +1,10 @@
import type { NextApiRequest, NextApiResponse } from 'next';
import jackson from '@lib/jackson';
import { validateApiKey } from '@lib/auth';
// Process the dsync events queue in Jackson
const handler = async (req: NextApiRequest, res: NextApiResponse) => {
const { apiKey } = req.query as { apiKey: string };
try {
if (validateApiKey(apiKey) === false) {
throw new Error('Please provide a valid Jackson API key');
}
const { directorySyncController } = await jackson();
await directorySyncController.events.batch.process();

View File

@ -1,17 +1,10 @@
import type { NextApiRequest, NextApiResponse } from 'next';
import jackson from '@lib/jackson';
import { validateApiKey } from '@lib/auth';
// Sync Google Workspace with Jackson
const handler = async (req: NextApiRequest, res: NextApiResponse) => {
const { apiKey } = req.query as { apiKey: string };
try {
if (validateApiKey(apiKey) === false) {
throw new Error('Please provide a valid Jackson API key');
}
const { directorySyncController } = await jackson();
await directorySyncController.sync(directorySyncController.events.callback);