mocksaml/pages/api/apps/metadata/index.ts

32 lines
857 B
TypeScript
Raw Normal View History

2022-02-17 06:57:50 +00:00
import type { NextApiRequest, NextApiResponse } from 'next';
2022-02-17 16:13:25 +00:00
import { createCertificate, createIdPSSOUrl } from '../../../../utils';
2022-02-17 06:57:50 +00:00
import { IdPMetadata } from '../../../../types';
import config from '../../../../lib/env'
export default async function handler(
req: NextApiRequest,
res: NextApiResponse<IdPMetadata | string>
) {
switch (req.method) {
case 'GET':
return await getMetadata();
default:
return res.status(405).end(`Method ${req.method} Not Allowed`);
}
// Get metadata for an app
async function getMetadata() {
//const {id} = req.query;
const appId = '0480c44e-f200-4f72-8af0-a5a57611fd2d';
const metadata = {
certificate: await createCertificate(),
fingerprint: '',
2022-02-17 16:13:25 +00:00
sso_url: createIdPSSOUrl(appId),
2022-02-17 06:57:50 +00:00
entity_id: config.entityId,
}
return res.json(metadata);
}
}