Save the certificate to db

This commit is contained in:
Kiran 2022-02-17 14:51:19 +05:30
parent dc9b150304
commit 7919ef8fcc
3 changed files with 12 additions and 23 deletions

View File

@ -1,17 +1,7 @@
# Backlog # Mock SAML from BoxyHQ
- Form validation
- Feed some users
- Fix the download metadata
- Add the SAML response
- Fix the SAML metadata URL
- Improve the UI
https://github.com/prisma/prisma/issues/4571#issuecomment-747496127
http://localhost:4000/apps/saml?RelayState&SAMLRequest= http://localhost:4000/apps/saml?RelayState&SAMLRequest=
## Pages - Parse the SAML Request
- Create an app - Create the SAML Response
- List all app - Fix the certificate
- View individual app page (with Download Metadata button and Delete button)

View File

@ -1,6 +1,7 @@
import type { NextApiRequest, NextApiResponse } from 'next'; import type { NextApiRequest, NextApiResponse } from 'next';
import type { App, IdPMetadata } from '../../../types'; import type { App, IdPMetadata } from '../../../types';
import prisma from '../../../lib/prisma'; import prisma from '../../../lib/prisma';
import { createCertificate, createIdPMetadataXML } from '../../../utils';
export default async function handler( export default async function handler(
req: NextApiRequest, req: NextApiRequest,
@ -32,12 +33,15 @@ export default async function handler(
description = null, description = null,
} = req.body; } = req.body;
const certificate = await createCertificate();
const app = await prisma.app.create({ const app = await prisma.app.create({
data: { data: {
name, name,
acs_url, acs_url,
entity_id, entity_id,
description description,
certificate,
} }
}); });

View File

@ -1,6 +1,7 @@
import axios from 'axios'; import axios from 'axios';
import type { NextPage } from 'next'; import type { NextPage } from 'next';
import { ChangeEvent, FormEvent, useState } from 'react'; import { ChangeEvent, FormEvent, useState } from 'react';
import Router from 'next/router';
const Apps: NextPage = () => { const Apps: NextPage = () => {
const [formData, setFormData] = useState({ const [formData, setFormData] = useState({
@ -9,12 +10,6 @@ const Apps: NextPage = () => {
entity_id: null, entity_id: null,
}); });
const [metadata, setMetadata] = useState({
sso_url: null,
entity_id: null,
certificate: null,
});
const handleInputChange = (e: ChangeEvent<HTMLInputElement>) => { const handleInputChange = (e: ChangeEvent<HTMLInputElement>) => {
setFormData({ setFormData({
...formData, ...formData,
@ -25,11 +20,11 @@ const Apps: NextPage = () => {
const createApp = async (e: FormEvent) => { const createApp = async (e: FormEvent) => {
e.preventDefault(); e.preventDefault();
const {data} = await axios.post('/api/apps', { const { data: app } = await axios.post('/api/apps', {
...formData ...formData
}); });
setMetadata(data); await Router.push(`/apps/${app.id}`);
}; };
return ( return (