Download metadata url (#91)
* Bump eslint from 8.23.1 to 8.24.0 Bumps [eslint](https://github.com/eslint/eslint) from 8.23.1 to 8.24.0. - [Release notes](https://github.com/eslint/eslint/releases) - [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md) - [Commits](https://github.com/eslint/eslint/compare/v8.23.1...v8.24.0) --- updated-dependencies: - dependency-name: eslint dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * Bump next from 12.3.0 to 12.3.1 Bumps [next](https://github.com/vercel/next.js) from 12.3.0 to 12.3.1. - [Release notes](https://github.com/vercel/next.js/releases) - [Changelog](https://github.com/vercel/next.js/blob/canary/release.js) - [Commits](https://github.com/vercel/next.js/compare/v12.3.0...v12.3.1) --- updated-dependencies: - dependency-name: next dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * Add Download Metadata URL Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This commit is contained in:
parent
d7ef3bf3db
commit
c5ab7761d1
27
pages/api/saml/metadata/index.ts
Normal file
27
pages/api/saml/metadata/index.ts
Normal file
@ -0,0 +1,27 @@
|
||||
import type { NextApiRequest, NextApiResponse } from 'next';
|
||||
import saml from '@boxyhq/saml20';
|
||||
|
||||
import config from 'lib/env';
|
||||
import type { IdPMetadata } from 'types';
|
||||
import { createIdPMetadataXML } from 'utils';
|
||||
|
||||
export default async function handler(req: NextApiRequest, res: NextApiResponse<IdPMetadata | string>) {
|
||||
switch (req.method) {
|
||||
case 'GET':
|
||||
return await MetadataUrl();
|
||||
default:
|
||||
return res.status(405).end(`Method ${req.method} Not Allowed`);
|
||||
}
|
||||
|
||||
// Metadata URL
|
||||
async function MetadataUrl() {
|
||||
const xml = await createIdPMetadataXML({
|
||||
idpEntityId: config.entityId,
|
||||
idpSsoUrl: config.ssoUrl,
|
||||
certificate: saml.stripCertHeaderAndFooter(config.publicKey),
|
||||
});
|
||||
|
||||
res.setHeader('Content-type', 'text/xml');
|
||||
res.send(xml);
|
||||
}
|
||||
}
|
||||
@ -13,25 +13,32 @@ const Home: React.FC<{ metadata: IdPMetadata }> = ({ metadata }) => {
|
||||
<h1 className='text-center text-xl font-extrabold text-gray-900 md:text-2xl'>
|
||||
A free SAML 2.0 Identity Provider for testing SAML SSO integrations.
|
||||
</h1>
|
||||
<div className='flex flex-col justify-between md:flex-row'>
|
||||
<Link href='/api/saml/metadata/download'>
|
||||
<a className='btn btn-active btn-primary'>
|
||||
<svg
|
||||
className='mr-1 inline-block h-6 w-6'
|
||||
fill='none'
|
||||
viewBox='0 0 24 24'
|
||||
stroke='currentColor'
|
||||
aria-hidden
|
||||
strokeWidth='2'>
|
||||
<path
|
||||
strokeLinecap='round'
|
||||
strokeLinejoin='round'
|
||||
d='M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4'
|
||||
/>
|
||||
</svg>
|
||||
Download Metadata
|
||||
</a>
|
||||
</Link>
|
||||
<div className='flex flex-col justify-between space-y-5 md:flex-row md:space-y-0'>
|
||||
<div className='flex flex-col space-y-5 md:flex-row md:space-x-5 md:space-y-0'>
|
||||
<Link href='/api/saml/metadata/download'>
|
||||
<a className='btn btn-active btn-primary'>
|
||||
<svg
|
||||
className='mr-1 inline-block h-6 w-6'
|
||||
fill='none'
|
||||
viewBox='0 0 24 24'
|
||||
stroke='currentColor'
|
||||
aria-hidden
|
||||
strokeWidth='2'>
|
||||
<path
|
||||
strokeLinecap='round'
|
||||
strokeLinejoin='round'
|
||||
d='M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4'
|
||||
/>
|
||||
</svg>
|
||||
Download Metadata
|
||||
</a>
|
||||
</Link>
|
||||
<Link href='/api/saml/metadata'>
|
||||
<a className='btn btn-outline btn-primary' target='_blank'>
|
||||
Metadata URL
|
||||
</a>
|
||||
</Link>
|
||||
</div>
|
||||
<Link href='/saml/login'>
|
||||
<a className='btn btn-outline btn-primary'>Test IdP Login</a>
|
||||
</Link>
|
||||
|
||||
@ -43,5 +43,6 @@ a {
|
||||
|
||||
.btn {
|
||||
@apply rounded;
|
||||
text-transform: none;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user