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,7 +13,8 @@ const Home: React.FC<{ metadata: IdPMetadata }> = ({ metadata }) => {
|
|||||||
<h1 className='text-center text-xl font-extrabold text-gray-900 md:text-2xl'>
|
<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.
|
A free SAML 2.0 Identity Provider for testing SAML SSO integrations.
|
||||||
</h1>
|
</h1>
|
||||||
<div className='flex flex-col justify-between md:flex-row'>
|
<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'>
|
<Link href='/api/saml/metadata/download'>
|
||||||
<a className='btn btn-active btn-primary'>
|
<a className='btn btn-active btn-primary'>
|
||||||
<svg
|
<svg
|
||||||
@ -32,6 +33,12 @@ const Home: React.FC<{ metadata: IdPMetadata }> = ({ metadata }) => {
|
|||||||
Download Metadata
|
Download Metadata
|
||||||
</a>
|
</a>
|
||||||
</Link>
|
</Link>
|
||||||
|
<Link href='/api/saml/metadata'>
|
||||||
|
<a className='btn btn-outline btn-primary' target='_blank'>
|
||||||
|
Metadata URL
|
||||||
|
</a>
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
<Link href='/saml/login'>
|
<Link href='/saml/login'>
|
||||||
<a className='btn btn-outline btn-primary'>Test IdP Login</a>
|
<a className='btn btn-outline btn-primary'>Test IdP Login</a>
|
||||||
</Link>
|
</Link>
|
||||||
|
|||||||
@ -43,5 +43,6 @@ a {
|
|||||||
|
|
||||||
.btn {
|
.btn {
|
||||||
@apply rounded;
|
@apply rounded;
|
||||||
|
text-transform: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user