mirror of https://github.com/boxyhq/jackson.git
Replace apiKey query params with Authorization header for cron endpoints (#1979)
Use Authorization header auth for cron endpoints
This commit is contained in:
parent
7d6829adb7
commit
260597e2e7
|
@ -18,7 +18,6 @@ const unAuthenticatedApiRoutes = [
|
||||||
'/api/well-known/**',
|
'/api/well-known/**',
|
||||||
'/api/setup/**',
|
'/api/setup/**',
|
||||||
'/api/branding',
|
'/api/branding',
|
||||||
'/api/scim/cron/**',
|
|
||||||
];
|
];
|
||||||
|
|
||||||
export async function middleware(req: NextRequest) {
|
export async function middleware(req: NextRequest) {
|
||||||
|
|
|
@ -1,17 +1,10 @@
|
||||||
import type { NextApiRequest, NextApiResponse } from 'next';
|
import type { NextApiRequest, NextApiResponse } from 'next';
|
||||||
|
|
||||||
import jackson from '@lib/jackson';
|
import jackson from '@lib/jackson';
|
||||||
import { validateApiKey } from '@lib/auth';
|
|
||||||
|
|
||||||
// Process the dsync events queue in Jackson
|
// Process the dsync events queue in Jackson
|
||||||
const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
||||||
const { apiKey } = req.query as { apiKey: string };
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (validateApiKey(apiKey) === false) {
|
|
||||||
throw new Error('Please provide a valid Jackson API key');
|
|
||||||
}
|
|
||||||
|
|
||||||
const { directorySyncController } = await jackson();
|
const { directorySyncController } = await jackson();
|
||||||
|
|
||||||
await directorySyncController.events.batch.process();
|
await directorySyncController.events.batch.process();
|
||||||
|
|
|
@ -1,17 +1,10 @@
|
||||||
import type { NextApiRequest, NextApiResponse } from 'next';
|
import type { NextApiRequest, NextApiResponse } from 'next';
|
||||||
|
|
||||||
import jackson from '@lib/jackson';
|
import jackson from '@lib/jackson';
|
||||||
import { validateApiKey } from '@lib/auth';
|
|
||||||
|
|
||||||
// Sync Google Workspace with Jackson
|
// Sync Google Workspace with Jackson
|
||||||
const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
||||||
const { apiKey } = req.query as { apiKey: string };
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (validateApiKey(apiKey) === false) {
|
|
||||||
throw new Error('Please provide a valid Jackson API key');
|
|
||||||
}
|
|
||||||
|
|
||||||
const { directorySyncController } = await jackson();
|
const { directorySyncController } = await jackson();
|
||||||
|
|
||||||
await directorySyncController.sync(directorySyncController.events.callback);
|
await directorySyncController.sync(directorySyncController.events.callback);
|
||||||
|
|
Loading…
Reference in New Issue